Skip to content

Comments

Wire up logging for each Reconciler#50

Merged
ggkhrmv merged 2 commits intoargoproj-labs:mainfrom
k4r1:fix/logging
Jul 15, 2025
Merged

Wire up logging for each Reconciler#50
ggkhrmv merged 2 commits intoargoproj-labs:mainfrom
k4r1:fix/logging

Conversation

@k4r1
Copy link
Contributor

@k4r1 k4r1 commented Jul 12, 2025

What type of PR is this?

/kind bug

What does this PR do / why we need it:
This PR wires up logging for each individual reconciler and fixes some broken usage of the log function which results in odd number of arguments passed as key-value pairs for logging:

2025-07-12T10:57:41Z ERROR Observed a panic {"controller": "argocdrole", "controllerGroup": "rbac-operator.argoproj-labs.io", "controllerKind": "ArgoCDRole", "ArgoCDRole": {"name":"argocd-admins","namespace":"engine"}, "namespace": "engine", "name": "argocd-admins", "reconcileID": "043aef1e-7a40-4320-b043-d786033ef197", "panic": "odd number of arguments passed as key-value pairs for logging", "stacktrace": "goroutine 105 [running]:\nk8s.io/apimachinery/pkg/util/runtime.logPanic({0x2c5c0e8, 0xc0007dba10}, {0x216c540, 0xc000505010})\n\t/go/pkg/mod/k8s.io/apimachinery@v0.33.1/pkg/util/runtime/runtime.go:132 +0xbc\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile.func1()\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:107 +0x112\npanic({0x216c540?, 0xc000505010?})\n\t/usr/local/go/src/runtime/panic.go:792 +0x132\ngo.uber.org/zap/zapcore.CheckWriteAction.OnWrite(0x26?, 0xb?, {0x0?, 0x0?, 0xc0008054e0?})\n\t/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/entry.go:196 +0x54\ngo.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0006ede10, {0xc0009ca580, 0x1, 0x1})\n\t/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/entry.go:262 +0x24a\ngo.uber.org/zap.(*Logger).DPanic(0x26c0e26?, {0x273fcc4?, 0x216c540?}, {0xc0009ca580, 0x1, 0x1})\n\t/go/pkg/mod/go.uber.org/zap@v1.27.0/logger.go:275 +0x4b\ngithub.com/go-logr/zapr.(*zapLogger).handleFields(0xc00049a6f0, 0x0, {0xc000504fc0, 0x1, 0x252d3a0?}, {0x0, 0x0, 0x5?})\n\t/go/pkg/mod/github.com/go-logr/zapr@v1.3.0/zapr.go:147 +0xd45\ngithub.com/go-logr/zapr.(*zapLogger).Info(0xc00049a6f0, 0x0, {0x26dd3e6?, 0x1?}, {0xc000504fc0, 0x1, 0x1})\n\t/go/pkg/mod/github.com/go-logr/zapr@v1.3.0/zapr.go:201 +0x89\ngithub.com/go-logr/logr.Logger.Info({{0x2c627b0?, 0xc00049a6f0?}, 0x2?}, {0x26dd3e6, 0x19}, {0xc000504fc0, 0x1, 0x1})\n\t/go/pkg/mod/github.com/go-logr/logr@v1.4.3/logr.go:280 +0xf3\ngithub.com/argoproj-labs/argocd-rbac-operator/internal/controller.(*ArgoCDRoleReconciler).Reconcile(0xc00001ebe0, {0x2c5c0e8, 0xc0007dba10}, {{{0xc0003aaec6, 0x6}, {0xc0003aaed0, 0xd}}})\n\t/workspace/internal/controller/argocdrole_controller.go:58 +0x16f\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile(0xc0007db980?, {0x2c5c0e8?, 0xc0007dba10?}, {{{0xc0003aaec6?, 0x0?}, {0xc0003aaed0?, 0x0?}}})\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:118 +0xbf\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler(0x2c72ea0, {0x2c5c120, 0xc00001eb40}, {{{0xc0003aaec6, 0x6}, {0xc0003aaed0, 0xd}}})\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:328 +0x3a5\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem(0x2c72ea0, {0x2c5c120, 0xc00001eb40})\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:288 +0x20d\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2()\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:249 +0x85\ncreated by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2 in goroutine 84\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.1/pkg/internal/controller/controller.go:245 +0x6b5\n"}

How to test changes / Special notes to the reviewer:
Run the image with --zap-log-level=debug and observe the output.

Signed-off-by: Karl Taylor <16408267+k4r1@users.noreply.github.com>
Copy link
Collaborator

@ggkhrmv ggkhrmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the fix @k4r1

@ggkhrmv ggkhrmv merged commit 1c07d46 into argoproj-labs:main Jul 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants