Persist config ref condition on recovery from transient errors#4533
Persist config ref condition on recovery from transient errors#4533ChrisJBurns merged 2 commits intomainfrom
Conversation
When a referenced MCPOIDCConfig or MCPTelemetryConfig became temporarily unavailable and then returned with the same content hash, the OIDCConfigRefValidated/TelemetryConfigRefValidated condition was set to True in memory but never persisted because the status update only ran inside the "hash changed" branch. Track whether the condition is transitioning from non-True to True and include that in the "needs update" decision. Extract fetch-and-validate logic into helper methods to keep cyclomatic complexity within limits. Fixes #4511 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@claude Please review this with the agents. only raise critical/high issues and medium issues that are non controversial. ignore low/informational style / nits. recommend approval or rejection. |
|
Claude finished @ChrisJBurns's task in 2m 4s —— View job Code Review
SummaryThe fix is correct and the approach is sound. One medium issue found with the regression test; no critical or high issues. Medium Issue: Regression Test Doesn't Actually Verify PersistenceFile: The new test case for _, cond := range tt.mcpServer.Status.Conditions {
if cond.Type == mcpv1alpha1.ConditionOIDCConfigRefValidated {
assert.Equal(t, string(*tt.expectConditionStatus), string(cond.Status))
To actually prove the condition is persisted, the test must re-read from the fake client after the call: var persisted mcpv1alpha1.MCPServer
require.NoError(t, fakeClient.Get(ctx, client.ObjectKeyFromObject(tt.mcpServer), &persisted))
// then check persisted.Status.ConditionsWithout this, the regression test does not guard against a future revert of the What's Right
Recommendation: Approve with fix requestedThe logic fix is correct and the refactoring is safe. The medium issue (test checks in-memory state instead of persisted state) should be addressed before merging to ensure the regression test actually catches future regressions. No blocking correctness issues. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4533 +/- ##
=======================================
Coverage 68.83% 68.83%
=======================================
Files 505 505
Lines 52322 52342 +20
=======================================
+ Hits 36015 36030 +15
- Misses 13514 13521 +7
+ Partials 2793 2791 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The previous regression test checked the in-memory Go struct after handleOIDCConfig, which would pass even without the fix since meta.SetStatusCondition mutates in memory before Status().Update() is called. Replace with a standalone test that re-reads the MCPServer from the fake client to verify the condition was actually persisted to the API server. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@claude Please re-review to check if the original review comments has been addressed |
|
Claude finished @ChrisJBurns's task in 42s —— View job Re-review
Medium Issue: ResolvedThe original concern was that the regression test checked The fix: A new dedicated test function
This is exactly what the review requested. The test will now fail if the Recommendation: ApproveThe core logic fix is correct, the regression test now properly verifies persistence against the fake client, and linting/unit tests pass. The secondary suggestion (adding analogous persistence tests for |
…lok#4533) * Persist config ref condition on recovery from transient errors When a referenced MCPOIDCConfig or MCPTelemetryConfig became temporarily unavailable and then returned with the same content hash, the OIDCConfigRefValidated/TelemetryConfigRefValidated condition was set to True in memory but never persisted because the status update only ran inside the "hash changed" branch. Track whether the condition is transitioning from non-True to True and include that in the "needs update" decision. Extract fetch-and-validate logic into helper methods to keep cyclomatic complexity within limits. Fixes stacklok#4511 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Verify condition persistence via fake client in regression test The previous regression test checked the in-memory Go struct after handleOIDCConfig, which would pass even without the fix since meta.SetStatusCondition mutates in memory before Status().Update() is called. Replace with a standalone test that re-reads the MCPServer from the fake client to verify the condition was actually persisted to the API server. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
When a referenced MCPOIDCConfig or MCPTelemetryConfig became temporarily unavailable and then returned with the same content hash, the
OIDCConfigRefValidated/TelemetryConfigRefValidatedcondition was set to True in memory but never persisted — theStatus().Update()call only ran inside the "hash changed" branch. This left a staleFalsecondition visible inkubectluntil the next hash-changing event.The fix tracks whether the condition is transitioning from non-True to True and includes that in the "needs status update" decision. The fetch-and-validate logic is extracted into helper methods to keep cyclomatic complexity within the linter threshold.
Fixes #4511
Type of change
Changes
mcpserver_controller.gofetchAndValidateOIDCConfighelper; persist status when condition transitions to Truemcpremoteproxy_controller.gofetchAndValidateOIDCConfighelper; same condition persistence fixmcpserver_telemetryconfig.gomcpserver_oidcconfig_test.goTest plan
task test) — all pass, including new regression testtask lint) — 0 issuesSpecial notes for reviewers
StatusManagerthat persists conditions independently of the hash-change branch.fetchAndValidateOIDCConfigextraction is a no-op refactor that moves existing error-handling logic to reduce cyclomatic complexity in the mainhandleOIDCConfigmethods.Generated with Claude Code