mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Copy etcd client debug level logic from upstream
Replicated from https://github.com/etcd-io/etcd/blob/v3.5.4/client/v3/logger.go#L47 The logic of this function doesn't make a lot of sense to me, but copying it will avoid any behaviour change. Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
parent
f54d260633
commit
c1aa7a0fe7
@ -19,8 +19,10 @@ package factory
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -82,13 +84,29 @@ func init() {
|
|||||||
legacyregistry.RawMustRegister(grpcprom.DefaultClientMetrics)
|
legacyregistry.RawMustRegister(grpcprom.DefaultClientMetrics)
|
||||||
dbMetricsMonitors = make(map[string]struct{})
|
dbMetricsMonitors = make(map[string]struct{})
|
||||||
|
|
||||||
l, err := logutil.CreateDefaultZapLogger(zapcore.InfoLevel)
|
l, err := logutil.CreateDefaultZapLogger(etcdClientDebugLevel())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l = zap.NewNop()
|
l = zap.NewNop()
|
||||||
}
|
}
|
||||||
etcd3ClientLogger = l.Named("etcd-client")
|
etcd3ClientLogger = l.Named("etcd-client")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// etcdClientDebugLevel translates ETCD_CLIENT_DEBUG into zap log level.
|
||||||
|
// NOTE(negz): This is a copy of a private etcd client function:
|
||||||
|
// https://github.com/etcd-io/etcd/blob/v3.5.4/client/v3/logger.go#L47
|
||||||
|
func etcdClientDebugLevel() zapcore.Level {
|
||||||
|
envLevel := os.Getenv("ETCD_CLIENT_DEBUG")
|
||||||
|
if envLevel == "" || envLevel == "true" {
|
||||||
|
return zapcore.InfoLevel
|
||||||
|
}
|
||||||
|
var l zapcore.Level
|
||||||
|
if err := l.Set(envLevel); err == nil {
|
||||||
|
log.Printf("Deprecated env ETCD_CLIENT_DEBUG value. Using default level: 'info'")
|
||||||
|
return zapcore.InfoLevel
|
||||||
|
}
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
func newETCD3HealthCheck(c storagebackend.Config, stopCh <-chan struct{}) (func() error, error) {
|
func newETCD3HealthCheck(c storagebackend.Config, stopCh <-chan struct{}) (func() error, error) {
|
||||||
timeout := storagebackend.DefaultHealthcheckTimeout
|
timeout := storagebackend.DefaultHealthcheckTimeout
|
||||||
if c.HealthcheckTimeout != time.Duration(0) {
|
if c.HealthcheckTimeout != time.Duration(0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user