controller/workload: Clean up status reporting helpers and test infrastructure#2197
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughConsolidates error-message construction in the workload controller via a new helper, uses k8s.io/utils/ptr to default replica counts, and updates tests (helper rename, fixture simplifications, and an expectation tweak) to match the refactored messages and behavior. ChangesWorkload status/error and replica handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/operator/apiserver/controller/workload/workload_test.go (1)
56-70:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winVersion-recorder checks are wired but effectively never exercised.
validateVersionRecorderis optional, and in the current scenario table it stays nil, so recorder assertions are skipped. Also, without at least one scenario settingoperatorConfigAtHighestRevision: true, theSetVersionpath remains untested.Suggested patch
- if scenario.validateVersionRecorder != nil { - if err := scenario.validateVersionRecorder(recorder); err != nil { - t.Fatal(err) - } - } + validateVersionRecorder := scenario.validateVersionRecorder + if validateVersionRecorder == nil { + validateVersionRecorder = expectVersionNotRecorded + } + if err := validateVersionRecorder(recorder); err != nil { + t.Fatal(err) + }And add at least one positive case, e.g. in a fully healthy rollout scenario:
+ operatorConfigAtHighestRevision: true, + validateVersionRecorder: expectVersionRecorded,Also applies to: 732-736
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/operator/apiserver/controller/workload/workload_test.go` around lines 56 - 70, Add a test case in TestUpdateOperatorStatus that exercises the SetVersion path by setting operatorConfigAtHighestRevision: true and providing a non-nil validateVersionRecorder to assert the fakeVersionRecorder observed SetVersion calls; locate the scenario table in TestUpdateOperatorStatus and add a fully healthy rollout scenario (healthy workload, pods, no errors) that sets operatorConfigAtHighestRevision = true and implements validateVersionRecorder to check the fakeVersionRecorder state (e.g., version/name/count) so the recorder wiring is actually verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/operator/apiserver/controller/workload/workload.go`:
- Around line 380-387: The helper function errMessage should guard against nil
entries in the errs slice to avoid panics: inside errMessage, before calling
err.Error() (iterate over errs in the existing loop), check if err == nil and
either skip that element or append a placeholder like "<nil>" instead of calling
Error(); keep the existing newline logic and strings.Builder usage so behavior
and formatting remain unchanged.
---
Outside diff comments:
In `@pkg/operator/apiserver/controller/workload/workload_test.go`:
- Around line 56-70: Add a test case in TestUpdateOperatorStatus that exercises
the SetVersion path by setting operatorConfigAtHighestRevision: true and
providing a non-nil validateVersionRecorder to assert the fakeVersionRecorder
observed SetVersion calls; locate the scenario table in TestUpdateOperatorStatus
and add a fully healthy rollout scenario (healthy workload, pods, no errors)
that sets operatorConfigAtHighestRevision = true and implements
validateVersionRecorder to check the fakeVersionRecorder state (e.g.,
version/name/count) so the recorder wiring is actually verified.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 50c0f1a1-5711-46e2-837a-0d39d5d1bc5f
📒 Files selected for processing (2)
pkg/operator/apiserver/controller/workload/workload.gopkg/operator/apiserver/controller/workload/workload_test.go
bb83bb4 to
5b539f5
Compare
5b539f5 to
fcdbbf6
Compare
fcdbbf6 to
aed55e5
Compare
Replace inline error message loops with errors.Join, use ptr.Deref for replicas, fix areCondidtionsEqual typo. Remove unnecessary Template/Labels from test fixtures.
aed55e5 to
1f03ec2
Compare
|
@tchap: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: p0lyn0mial, tchap 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 |
This is being split from #2128
errors.Joinptr.Dereffor replicasareCondidtionsEqualtypoSummary by CodeRabbit
Refactor
Tests