CNF-26102: Fix istiocsr updateCondition error aggregation bug - #462
CNF-26102: Fix istiocsr updateCondition error aggregation bug#462sebrandon1 wants to merge 1 commit into
Conversation
|
@sebrandon1: This pull request references CNF-26102 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
ChangesupdateCondition error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sebrandon1 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 |
874b029 to
45ba1c0
Compare
b2f16d3 to
95cc6a2
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/controller/istiocsr/utils_test.go (1)
576-589: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winSimulate the status-write failure in the status-error cases.
Lines 576-579 return a
Geterror.updateConditiontherefore does not reachCtrlClient.StatusUpdatein these cases. Configure a successfulGetCallsstub and pass an error toStatusUpdateReturnswhentt.statusErris true. This verifies the actual status-write failure path and its error aggregation.Proposed test setup
- if tt.statusErr { - fakeClient.GetCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) error { - return fmt.Errorf("simulated get error") - }) - } else { - fakeClient.GetCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) error { - switch o := obj.(type) { - case *v1alpha1.IstioCSR: - testIstioCSR().DeepCopyInto(o) - } - return nil - }) - fakeClient.StatusUpdateReturns(nil) - } + fakeClient.GetCalls(func(_ context.Context, _ types.NamespacedName, obj client.Object) error { + switch o := obj.(type) { + case *v1alpha1.IstioCSR: + testIstioCSR().DeepCopyInto(o) + } + return nil + }) + if tt.statusErr { + fakeClient.StatusUpdateReturns(fmt.Errorf("simulated status update error")) + } else { + fakeClient.StatusUpdateReturns(nil) + }🤖 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/controller/istiocsr/utils_test.go` around lines 576 - 589, Update the test setup around the tt.statusErr branch so fakeClient.GetCalls always returns a valid IstioCSR, then configure fakeClient.StatusUpdateReturns with an error when tt.statusErr is true and nil otherwise. Preserve the existing successful GetCalls behavior and ensure the test exercises the status-write failure and error aggregation path in updateCondition.
🤖 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.
Nitpick comments:
In `@pkg/controller/istiocsr/utils_test.go`:
- Around line 576-589: Update the test setup around the tt.statusErr branch so
fakeClient.GetCalls always returns a valid IstioCSR, then configure
fakeClient.StatusUpdateReturns with an error when tt.statusErr is true and nil
otherwise. Preserve the existing successful GetCalls behavior and ensure the
test exercises the status-write failure and error aggregation path in
updateCondition.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 62437282-b49a-4ae4-b03c-82d5dd959580
📒 Files selected for processing (1)
pkg/controller/istiocsr/utils_test.go
The updateCondition method was passing the status-update error instead of the original prependErr into the aggregate, silently dropping the caller's error. Includes table-driven tests covering all four branches.
1b7838f to
922b9c5
Compare
|
/retest |
|
@sebrandon1: The following test failed, say
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. |
Summary
updateConditioninpkg/controller/istiocsr/utils.go:484aggregated{err, errUpdate}instead of{prependErr, errUpdate}, silently dropping the original reconcile error when both the reconciliation and status update fail simultaneouslypkg/controller/trustmanager/utils.go:134) correctly usesprependErr; this aligns the istiocsr implementation to matchupdateCondition(nil/non-nil prependErr x success/failure status update)Related PRs
Jira
Test Plan
go test ./pkg/controller/istiocsr/... -count=1-- 117 passed)make lintclean