onosproject / onos-config

Configuration subsystem for ONOS (µONOS Architecture)
45 stars 57 forks source link

Duplicate logs when Error or Warning #393

Closed Andrea-Campanella closed 5 years ago

Andrea-Campanella commented 5 years ago

Describe the bug Logging is duplicated when is Error or Warning

To Reproduce Steps to reproduce the behavior:

  1. Run make run-docker
  2. docker logs
  3. check any error or warning log.

Expected behavior The log should be issued just once.

Screenshots W0624 12:43:20.940243 1 synchronizer.go:60] could not create a gNMI client: Dialer(localhost:50001, 5s): context deadline exceeded W0624 12:43:20.940243 1 synchronizer.go:60] could not create a gNMI client: Dialer(localhost:50001, 5s): context deadline exceeded W0624 12:43:20.940358 1 factory.go:43] Error in connecting to client: could not create a gNMI client: Dialer(localhost:50001, 5s): context deadline exceeded W0624 12:43:20.940358 1 factory.go:43] Error in connecting to client: could not create a gNMI client: Dialer(localhost:50001, 5s)

Andrea-Campanella commented 5 years ago

log.SetOutput(os.Stdout) line 93 of onos-config

Andrea-Campanella commented 5 years ago

this could be easily fixed by doing

log.InitFlags(nil) for klog but if other projects in the dependency set import glog the two are not compatibile and an error is thrown at runtime

/var/folders/4q/4x8mxbcd6hxbg79vtn04jjsr0000gn/T/go-build901010861/b001/exe/onos-config flag redefined: log_dir
panic: /var/folders/4q/4x8mxbcd6hxbg79vtn04jjsr0000gn/T/go-build901010861/b001/exe/onos-config flag redefined: log_dir

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc000092120, 0x46cd6c0, 0x4acfa90, 0x460dd8c, 0x7, 0x4625087, 0x2f)
    /usr/local/go/src/flag/flag.go:850 +0x4af
flag.(*FlagSet).StringVar(...)
    /usr/local/go/src/flag/flag.go:753
k8s.io/klog.InitFlags(0x0)
    /Users/andrea/go/pkg/mod/k8s.io/klog@v0.3.3/klog.go:427 +0x9d
main.main()
    /Users/andrea/go/src/github.com/onosproject/onos-config/cmd/onos-config/onos-config.go:76 +0x3f

This is a know problem see: https://github.com/kubernetes/client-go/issues/83 https://github.com/kubernetes/client-go/issues/19 The solution proposed in #398 was found here https://github.com/kubernetes/klog/blob/master/README.md https://github.com/kubernetes/klog/blob/master/examples/coexist_glog/coexist_glog.go