🌱 Use contextual logger in base controller - #165
Conversation
Signed-off-by: Jian Qiu <jqiu@redhat.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiujian16 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughThe PR refactors logging throughout the base controller to be context-aware, replacing direct klog calls with context-bound logger calls. It updates error handling to use utilruntime.HandleErrorWithContext with contextual information and modifies queue cancellation to derive from parent context instead of a TODO context. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/lgtm |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/basecontroller/factory/base_controller.go (1)
83-84: Clarify worker log field names
numberOfWorkerssuggests the total worker count, yet the value here is the loop index (1, 2, …). That makes the structured log misleading when inspecting metrics. Rename the field to reflect it’s an identifier (and optionally log the total worker count) to keep the log semantics straight.Apply this diff:
- logger.Info("Starting worker of controller ...", "numberOfWorkers", i) + logger.Info("Starting worker of controller ...", "workerID", i, "workerCount", workers)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/basecontroller/factory/base_controller.go(6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/basecontroller/factory/base_controller.go (1)
vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go (1)
HandleErrorWithContext(202-204)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: integration
- GitHub Check: unit
- GitHub Check: verify
105041a
into
open-cluster-management-io:main
Summary
Related issue(s)
Fixes #
Summary by CodeRabbit