Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[m3cluster/etcd] Use zap logger for etcd integration test store #2915

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/cespare/xxhash/v2 v2.1.1
github.com/cheekybits/genny v1.0.0 // indirect
github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
github.com/davecgh/go-spew v1.1.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/fatih/color v1.10.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions src/aggregator/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package server

import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -63,10 +64,7 @@ func Run(opts RunOptions) {
// Create logger and metrics scope.
logger, err := cfg.Logging.BuildLogger()
if err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error creating logger: %v\n", err)
os.Exit(1)
log.Fatalf("error creating logger: %v", err)
}
defer logger.Sync()

Expand Down
3 changes: 2 additions & 1 deletion src/cluster/integration/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func New(opts Options) (EmbeddedKV, error) {
}
cfg := embed.NewConfig()
cfg.Dir = dir
cfg.Logger = "zap"

setRandomPorts(cfg)
e, err := embed.StartEtcd(cfg)
Expand Down Expand Up @@ -108,7 +109,7 @@ func (e *embeddedKV) Start() error {
}

// ensure v3 api endpoints are available, https://github.com/coreos/etcd/pull/7075
apiVersionEndpoint := fmt.Sprintf("http://%s/version", e.etcd.Clients[0].Addr().String())
apiVersionEndpoint := fmt.Sprintf("http://%s/version", e.etcd.Clients[0].Addr().String())
fn := func() bool { return version3Available(apiVersionEndpoint) }
ok := xclock.WaitUntil(fn, timeout)
if !ok {
Expand Down
5 changes: 0 additions & 5 deletions src/cluster/kv/etcd/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,13 @@ import (
xclock "github.com/m3db/m3/src/x/clock"
"github.com/m3db/m3/src/x/retry"

"github.com/coreos/pkg/capnslog"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/require"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/integration"
"golang.org/x/net/context"
)

func init() {
capnslog.SetGlobalLogLevel(capnslog.WARNING)
}

func TestValue(t *testing.T) {
v1 := newValue(nil, 2, 100)
require.Equal(t, 2, v1.Version())
Expand Down
12 changes: 2 additions & 10 deletions src/cmd/services/m3aggregator/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ package main

import (
"flag"
"fmt"
"log"
_ "net/http/pprof" // pprof: for debug listen server if configured
"os"

"github.com/m3db/m3/src/aggregator/server"
"github.com/m3db/m3/src/cmd/services/m3aggregator/config"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
)

func main() {
Expand All @@ -39,15 +37,9 @@ func main() {

flag.Parse()

// Set globals for etcd related packages.
etcd.SetGlobals()

var cfg config.Configuration
if err := cfgOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

server.Run(server.RunOptions{
Expand Down
12 changes: 2 additions & 10 deletions src/cmd/services/m3collector/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ package main

import (
"flag"
"fmt"
"log"
_ "net/http/pprof" // pprof: for debug listen server if configured
"os"

"github.com/m3db/m3/src/cmd/services/m3collector/config"
"github.com/m3db/m3/src/collector/server"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
)

func main() {
Expand All @@ -41,15 +39,9 @@ func main() {

var cfg config.Configuration
if err := configOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

// Set globals for etcd related packages.
etcd.SetGlobals()

server.Run(server.RunOptions{
Config: cfg,
})
Expand Down
12 changes: 2 additions & 10 deletions src/cmd/services/m3coordinator/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ package main

import (
"flag"
"fmt"
"log"
_ "net/http/pprof" // pprof: for debug listen server if configured
"os"

"github.com/m3db/m3/src/cmd/services/m3query/config"
"github.com/m3db/m3/src/query/server"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
)

func main() {
Expand All @@ -39,15 +37,9 @@ func main() {

flag.Parse()

// Set globals for etcd related packages.
etcd.SetGlobals()

var cfg config.Configuration
if err := cfgOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

server.Run(server.RunOptions{
Expand Down
16 changes: 3 additions & 13 deletions src/cmd/services/m3dbnode/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package main

import (
"flag"
"fmt"
"log"
_ "net/http/pprof" // pprof: for debug listen server if configured
"os"
"os/signal"
Expand All @@ -35,7 +35,6 @@ import (
coordinatorserver "github.com/m3db/m3/src/query/server"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
xos "github.com/m3db/m3/src/x/os"
)

Expand All @@ -45,22 +44,13 @@ func main() {

flag.Parse()

// Set globals for etcd related packages.
etcd.SetGlobals()

var cfg config.Configuration
if err := cfgOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

if err := cfg.Validate(); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "erro validating config: %v\n", err)
os.Exit(1)
log.Fatalf("error validating config: %v", err)
}

var (
Expand Down
12 changes: 2 additions & 10 deletions src/cmd/services/m3query/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ package main

import (
"flag"
"fmt"
"log"
_ "net/http/pprof" // pprof: for debug listen server if configured
"os"

"github.com/m3db/m3/src/cmd/services/m3query/config"
"github.com/m3db/m3/src/query/server"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
)

func main() {
Expand All @@ -39,15 +37,9 @@ func main() {

flag.Parse()

// Set globals for etcd related packages.
etcd.SetGlobals()

var cfg config.Configuration
if err := configOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

server.Run(server.RunOptions{
Expand Down
15 changes: 3 additions & 12 deletions src/cmd/services/r2ctl/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"strconv"
Expand All @@ -37,7 +38,6 @@ import (
"github.com/m3db/m3/src/x/clock"
xconfig "github.com/m3db/m3/src/x/config"
"github.com/m3db/m3/src/x/config/configflag"
"github.com/m3db/m3/src/x/etcd"
"github.com/m3db/m3/src/x/instrument"
)

Expand All @@ -56,23 +56,14 @@ func main() {

flag.Parse()

// Set globals for etcd related packages.
etcd.SetGlobals()

var cfg config.Configuration
if err := configOpts.MainLoad(&cfg, xconfig.Options{}); err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
log.Fatalf("error loading config: %v", err)
}

rawLogger, err := cfg.Logging.BuildLogger()
if err != nil {
// NB(r): Use fmt.Fprintf(os.Stderr, ...) to avoid etcd.SetGlobals()
// sending stdlib "log" to black hole. Don't remove unless with good reason.
fmt.Fprintf(os.Stderr, "error creating logger: %v\n", err)
os.Exit(1)
log.Fatalf("error creating logger: %v", err)
}
defer rawLogger.Sync()

Expand Down
34 changes: 0 additions & 34 deletions src/x/etcd/globals.go

This file was deleted.