From 9b9e7429caa5298dd54eedffca5362b43160ebf1 Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Sat, 14 Sep 2024 18:13:19 +0200 Subject: [PATCH] fix leader election stack trace fixes #11 Signed-off-by: Markus Blaschke --- autopilot/main.go | 5 +++++ go.mod | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autopilot/main.go b/autopilot/main.go index b2b9fd5..e15b959 100644 --- a/autopilot/main.go +++ b/autopilot/main.go @@ -22,6 +22,9 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + "sigs.k8s.io/controller-runtime/pkg/log" + + "github.com/go-logr/zapr" "github.com/webdevopos/azure-k8s-autopilot/config" "github.com/webdevopos/azure-k8s-autopilot/k8s" @@ -160,6 +163,8 @@ func (r *AzureK8sAutopilot) initK8s() { if err != nil { panic(err.Error()) } + + log.SetLogger(zapr.NewLogger(r.Logger.Desugar())) } func (r *AzureK8sAutopilot) initMetricsGeneral() { diff --git a/go.mod b/go.mod index 7069aa8..fb9530d 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/KimMachineGun/automemlimit v0.6.1 github.com/containrrr/shoutrrr v0.8.0 github.com/dustin/go-humanize v1.0.1 + github.com/go-logr/zapr v1.3.0 github.com/jessevdk/go-flags v1.6.1 github.com/jinzhu/copier v0.4.0 github.com/operator-framework/operator-lib v0.15.0 @@ -20,6 +21,7 @@ require ( k8s.io/api v0.31.1 k8s.io/apimachinery v0.31.1 k8s.io/client-go v0.31.1 + sigs.k8s.io/controller-runtime v0.19.0 ) require ( @@ -89,7 +91,6 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect - sigs.k8s.io/controller-runtime v0.19.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect