Skip to content

Commit 18fd852

Browse files
committed
Enabling grpc logging.
1 parent 70e7568 commit 18fd852

File tree

1 file changed

+12
-0
lines changed
  • staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory

1 file changed

+12
-0
lines changed

staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"go.uber.org/zap/zapcore"
4040
"golang.org/x/time/rate"
4141
"google.golang.org/grpc"
42+
"google.golang.org/grpc/grpclog"
4243
"k8s.io/klog/v2"
4344

4445
roundrobin "google.golang.org/grpc/balancer/roundrobin" // named import (not blank)
@@ -101,6 +102,15 @@ func init() {
101102
resolver.Register(dnsresolver.NewBuilder())
102103
resolver.SetDefaultScheme("dns")
103104
_ = roundrobin.Name
105+
106+
// Enable gRPC logging for debugging health checks and connection state
107+
// Check for debug environment variables
108+
if os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL") != "" || os.Getenv("GRPC_TRACE") != "" {
109+
// Enable gRPC logging to stderr
110+
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
111+
klog.Infof("gRPC debug logging enabled: VERBOSITY=%s TRACE=%s",
112+
os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL"), os.Getenv("GRPC_TRACE"))
113+
}
104114
}
105115

106116
// etcdClientDebugLevel translates ETCD_CLIENT_DEBUG into zap log level.
@@ -418,6 +428,8 @@ var newETCD3Client = func(c storagebackend.TransportConfig) (*kubernetes.Client,
418428
}
419429

420430
klog.Infof("----------------Created successfully")
431+
klog.Infof("etcd client endpoints: %v", k.Endpoints())
432+
klog.Infof("Health checking: enabled (serviceName=''), TCP keepalives: time=%v timeout=%v", keepaliveTime, keepaliveTimeout)
421433

422434
return k, err
423435
}

0 commit comments

Comments
 (0)