-
Notifications
You must be signed in to change notification settings - Fork 119
✨ Route controller logs through shared helpers #2971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @MaxRink. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces a centralized logging infrastructure to improve observability and consistency across all Metal3 controllers. By routing every reconciliation path through shared logging helpers (logReconcileOutcome, logLogicGate, and logAndReturnError), the changes ensure that controller logic gates, error conditions, and reconciliation outcomes are uniformly instrumented.
Key Changes:
- Introduces three new logging helper functions in
controllers/logging_helpers.goto standardize debug-level lifecycle logging, error logging, and decision point tracking - Updates all seven controllers (
metal3cluster,metal3machine,metal3machinetemplate,metal3data,metal3datatemplate,metal3labelsync,metal3remediation) to use deferred outcome logging and route errors through centralized helpers - Modifies reconcile helper function signatures (
reconcileNormal,reconcileDelete) across all controllers to accept explicit logger parameters, with corresponding test updates to passklogr.New()loggers
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| controllers/logging_helpers.go | Defines three new shared logging utilities: logReconcileOutcome for deferred reconciliation completion/failure logging, logLogicGate for debug-level decision point tracking, and logAndReturnError for compact error logging and return |
| controllers/metal3cluster_controller.go | Adds deferred outcome logging, routes errors through logAndReturnError, adds logic gate tracking, and updates reconcileNormal/reconcileDelete signatures to accept logger parameter |
| controllers/metal3cluster_controller_test.go | Updates test calls to reconcileNormal and reconcileDelete to pass klogr.New() logger matching new signatures |
| controllers/metal3machine_controller.go | Adds deferred outcome logging, routes errors through logAndReturnError, adds extensive logic gate tracking throughout normal and delete flows, and updates reconcile function signatures |
| controllers/metal3machine_controller_test.go | Updates test calls to reconcileNormal and reconcileDelete to pass klogr.New() logger |
| controllers/metal3machinetemplate_controller.go | Adds deferred outcome logging, converts Info to Error for patch failures, routes errors through logAndReturnError, adds logic gate tracking, and updates reconcileNormal signature |
| controllers/metal3machinetemplate_controller_test.go | Updates test call to reconcileNormal to pass klogr.New() logger |
| controllers/metal3data_controller.go | Adds deferred outcome logging, converts Info to Error for patch failures, routes errors through logAndReturnError, adds logic gate tracking, and updates reconcile function signatures |
| controllers/metal3data_controller_test.go | Updates test calls to reconcileNormal and reconcileDelete to pass klogr.New() logger |
| controllers/metal3datatemplate_controller.go | Adds deferred outcome logging, converts Info to Error for patch failures, routes errors through logAndReturnError, adds logic gate tracking, updates reconcile signatures, and modifies checkReconcileError to accept logger |
| controllers/metal3datatemplate_controller_test.go | Updates test calls to reconcileNormal, reconcileDelete, and checkReconcileError to pass klogr.New() logger |
| controllers/metal3labelsync_controller.go | Adds deferred outcome logging, converts Info to Error for patch and fetch failures, routes errors through logAndReturnError, and adds logic gate tracking |
| controllers/metal3remediation_controller.go | Adds deferred outcome logging, routes errors through logAndReturnError, replaces r.Log with passed logger in reconcileNormal, adds logic gate tracking, and updates reconcileNormal signature |
| controllers/metal3remediation_controller_test.go | Updates test call to reconcileNormal to pass klogr.New() logger |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f251ee3 to
7729980
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7729980 to
8c1e417
Compare
* route every controller reconcile path through the shared logging helpers, ensuring consistent outcome/errors/logic-gate instrumentation * update controller unit tests to pass explicit loggers after the helper signature changes Signed-off-by: Maximilian Rink <[email protected]>
8c1e417 to
9456abe
Compare
tuminoid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
/cc @adilGhaffarDev @lentzi90 @kashifest
PTAL
|
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main |
Signed-off-by: Maximilian Rink <[email protected]>
|
/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main |
|
|
||
| // logLogicGate makes it easy to record decision points at debug level while keeping | ||
| // a consistent verbosity across controllers. | ||
| func logLogicGate(logger logr.Logger, message string, keysAndValues ...any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this function? Can we just use logger.V everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need logging_helpers.go file?
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What this PR does / why we need it
metal3cluster,metal3machine,metal3data,metal3datatemplate,metal3machinetemplate,metal3labelsync, andmetal3remediation.Why this matters
Before this change, many reconcile branches emitted no structured output at all—several delete helpers only logged fatal errors while success paths were silent, and other branches mixed ad-hoc
Info/Errorcalls without tying together controller name, gate decisions, or the final outcome. That made it difficult to correlate events in debug sessions, especially when helper functions (reconcileNormal,reconcileDelete, metadata association, pause handling, etc.) returned early. By funneling each controller throughlogReconcileOutcome,logLogicGate, andlogAndReturnError, every decision point now leaves a predictable debug-level trail, and all error returns are logged exactly once with contextual keys. The updated tests ensure helpers keep receiving loggers so future refactors can’t drop this coverage inadvertently.Fixes
Fixes #
Checklist