From 9f57e39daaf679bdd14de9a00ac073179d12b75b Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Mon, 15 Apr 2024 10:39:45 +0200 Subject: [PATCH] fix: [controller-runtime] log.SetLogger(...) was never called --- go.mod | 1 + go.sum | 2 ++ pkg/flux/reconcile.go | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/go.mod b/go.mod index 870f225..3cdaae6 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bombsimon/logrusr/v4 v4.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect github.com/containerd/containerd v1.7.13 // indirect diff --git a/go.sum b/go.sum index e16c55a..e7ea044 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bombsimon/logrusr/v4 v4.1.0 h1:uZNPbwusB0eUXlO8hIUwStE6Lr5bLN6IgYgG+75kuh4= +github.com/bombsimon/logrusr/v4 v4.1.0/go.mod h1:pjfHC5e59CvjTBIU3V3sGhFWFAnsnhOR03TRc6im0l8= github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= diff --git a/pkg/flux/reconcile.go b/pkg/flux/reconcile.go index 36b31cc..7c4ea26 100644 --- a/pkg/flux/reconcile.go +++ b/pkg/flux/reconcile.go @@ -21,6 +21,7 @@ import ( "context" "time" + "github.com/bombsimon/logrusr/v4" helmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1" kustomizationv1 "github.com/fluxcd/kustomize-controller/api/v1" "github.com/fluxcd/pkg/apis/meta" @@ -38,6 +39,7 @@ import ( "k8s.io/client-go/util/retry" kstatus "sigs.k8s.io/cli-utils/pkg/kstatus/status" "sigs.k8s.io/controller-runtime/pkg/client" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) type reconcileCommand struct { @@ -109,6 +111,9 @@ func (r *reconcileCommand) Run(config *rest.Config, namespace, name string) { kustomizationv1.AddToScheme(scheme) helmv2beta1.AddToScheme(scheme) + log := logrusr.New(logrus.New()) + logf.SetLogger(log) + kubeClient, err := client.NewWithWatch(config, client.Options{ Scheme: scheme, })