Skip to content

Commit 9bbad37

Browse files
committed
🌱 Allows to redefine ETCD client logger
1 parent a8e4187 commit 9bbad37

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

controlplane/kubeadm/controllers/alias.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"time"
2222

23+
"go.uber.org/zap"
24+
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal/etcd"
2325
ctrl "sigs.k8s.io/controller-runtime"
2426
"sigs.k8s.io/controller-runtime/pkg/client"
2527
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -55,3 +57,8 @@ func (r *KubeadmControlPlaneReconciler) SetupWithManager(ctx context.Context, mg
5557
RemoteConditionsGracePeriod: r.RemoteConditionsGracePeriod,
5658
}).SetupWithManager(ctx, mgr, options)
5759
}
60+
61+
// SetEtcdLogger allows to redefine ETCD client logger.
62+
func SetEtcdLogger(logger *zap.Logger) {
63+
etcd.SetLogger(logger)
64+
}

controlplane/kubeadm/internal/etcd/etcd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"go.etcd.io/etcd/api/v3/etcdserverpb"
2727
"go.etcd.io/etcd/client/pkg/v3/logutil"
2828
clientv3 "go.etcd.io/etcd/client/v3"
29+
"go.uber.org/zap"
2930
"go.uber.org/zap/zapcore"
3031
"google.golang.org/grpc"
3132
kerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -141,6 +142,11 @@ var (
141142
etcdClientLogger, _ = logutil.CreateDefaultZapLogger(zapcore.InfoLevel)
142143
)
143144

145+
// SetLogger allows to redefine ETCD client logger.
146+
func SetLogger(logger *zap.Logger) {
147+
etcdClientLogger = logger
148+
}
149+
144150
// NewClient creates a new etcd client with the given configuration.
145151
func NewClient(ctx context.Context, config ClientConfiguration) (*Client, error) {
146152
dialer, err := proxy.NewDialer(config.Proxy)

0 commit comments

Comments
 (0)