diff --git a/cmd/hepto/config.go b/cmd/hepto/config.go index 6555500c24beaeed05bd6689a01e4c7bfef061c6..bd0079289cd0d90d0857adf25272e91009babee8 100644 --- a/cmd/hepto/config.go +++ b/cmd/hepto/config.go @@ -73,13 +73,14 @@ func (c Config) dataPath(subPath string) string { func (c *Config) Complete() error { // Initialize logging - logger, err := zap.NewProduction() + logger, err := zap.NewDevelopment() if err != nil { return err } c.Logger = zapr.NewLogger(logger) c.Container.Logger = c.Logger c.Cluster.Logger = c.Logger + c.Cluster.ZapLogger = logger // Setup paths and container settings c.Container.Root = c.dataPath("root") c.Container.Data = c.dataPath("containers") diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 552c775e15362163b4a1e3345cb839e89f8d8c1c..96e7f7fabddab869cc3b1a547560525ae28b7861 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -9,6 +9,7 @@ import ( "forge.tedomum.net/acides/hepto/hepto/pkg/pki" "forge.tedomum.net/acides/hepto/hepto/pkg/sml" "forge.tedomum.net/acides/hepto/hepto/pkg/wg" + "k8s.io/klog/v2" ) type Cluster struct { @@ -44,6 +45,7 @@ func (c *Cluster) Run() { c.initCerts() c.initEnv() c.ml.Meta.Role = string(c.node.Role) + klog.SetLogger(c.settings.Logger) // Start waiting for events events := c.ml.Events() err := c.ml.Start() diff --git a/pkg/cluster/config.go b/pkg/cluster/config.go index a9f8a6507279bba5c04dcf73ca9915c7b3cf6b0f..d19ddb578068b7c19a90eb26fc3ce86d039bd922 100644 --- a/pkg/cluster/config.go +++ b/pkg/cluster/config.go @@ -5,11 +5,14 @@ import ( "net" "github.com/go-logr/logr" + "go.uber.org/zap" ) type ClusterSettings struct { // Logger interface Logger logr.Logger + // Concrete zap logger for etcd + ZapLogger *zap.Logger // Cluster name, should be locally unique Name string // Cluster key, must be shared across nodes diff --git a/pkg/cluster/kubeconfig.go b/pkg/cluster/kubeconfig.go index 88f8c8390c2d498f87bea4ddd1404898ea05a3fb..b93825fff1012951e000538a837317af6b7cb2de 100644 --- a/pkg/cluster/kubeconfig.go +++ b/pkg/cluster/kubeconfig.go @@ -23,7 +23,7 @@ func (c *Cluster) WriteConfig(config WriteableConfig, dest string) { os.Exit(1) } defer file.Close() - err = t.Execute(file, c) + err = t.Execute(file, config) if err != nil { c.settings.Logger.Error(err, "could not generate config") os.Exit(1) diff --git a/pkg/cluster/services.go b/pkg/cluster/services.go index a54fc5c533484e8691e375df9ce6c309edf143a3..62080fcfc69f8a5400d9c0bf3561ff03ff25e649 100644 --- a/pkg/cluster/services.go +++ b/pkg/cluster/services.go @@ -45,6 +45,7 @@ func (c *Cluster) updateServices() { func (c *Cluster) startEtcd() { etcdConfig := embed.NewConfig() etcdConfig.Dir = "/etcd" + etcdConfig.ZapLoggerBuilder = embed.NewZapLoggerBuilder(c.settings.ZapLogger) service, err := wrappers.ETCd(c.serviceCtx, etcdConfig) if err != nil { c.settings.Logger.Error(err, "failed to start etcd") diff --git a/pkg/cluster/vpn.go b/pkg/cluster/vpn.go index 998de64fecd878e6b6c3b5b977dbacfa08b1ed5c..6f0499bad6c95ade4ad0a069bb0a5e2b9fd81bc3 100644 --- a/pkg/cluster/vpn.go +++ b/pkg/cluster/vpn.go @@ -2,7 +2,8 @@ package cluster import ( "net" - "os" + "os" + "strconv" "forge.tedomum.net/acides/hepto/hepto/pkg/wg" ) @@ -39,6 +40,6 @@ func (c *Cluster) updateVPN() { } peers = append(peers, peer) } - c.settings.Logger.Info("updating VPN mesh", peers, len(peers), "mtu", c.networking.MTU) + c.settings.Logger.Info("updating VPN mesh", "peers", strconv.Itoa(len(peers)), "mtu", strconv.Itoa(c.networking.MTU)) c.vpn.Update(peers, c.networking.MTU) }