Repository navigation
Stop the external auth mirror from clearing conditions it did not write - #7162
Merged
ChrisJBurns merged 3 commits intoNov 25, 2026
Conversation
Collaborator
|
Thanks for the PR @im-jari-niskala , you'll have to rebase with main though and resolve some conflicts |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7162 +/- ##
==========================================
+ Coverage 82.10% 82.15% +0.04%
==========================================
Files 931 931
Lines 94306 94309 +3
==========================================
+ Hits 77434 77479 +45
+ Misses 16867 16825 -42
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mirrorInvalidOnMCPServer and mirrorInvalidOnRemoteProxy run on every reconcile. When the referenced MCPExternalAuthConfig is healthy they removed the consumer's ExternalAuthConfigValidated condition unless ownedByLocalValidation claimed it. isLocalValidationFailure only claims False conditions, so that included the healthy condition (True, ExternalAuthConfigValid), which handleExternalAuthConfig re-adds a few lines later with a fresh LastTransitionTime. Every reconcile of a healthy MCPServer or MCPRemoteProxy with an externalAuthConfigRef therefore wrote status, and the write triggered the next reconcile through the consumer's own watch. The mirror only ever writes Status=False, so clear the condition only when it is False and no local validation owns it (clearStaleMirror). The single-upstream check (MultiUpstreamNotSupported) re-derives its condition after the mirror runs in the same way, so isLocalValidationFailure now claims it too. The same-hash guards in the set*ExternalAuthConfigValid writers still hold only InvalidConfig, so they are unchanged. Signed-off-by: Jari Niskala <[email protected]>
im-jari-niskala
force-pushed
the
fix/external-auth-mirror-keeps-healthy-condition
branch
from
November 25, 2026 20:41
3e439b6 to
29225ae
Compare
ChrisJBurns
approved these changes
Nov 25, 2026
ChrisJBurns
added a commit
to 3nesdeniz/toolhive
that referenced
this pull request
Nov 26, 2026
Resolve conflicts with the OSS Entra OBO port (stacklok#7201) and the external auth mirror rework (stacklok#7162): - Keep the UnsupportedAuthType check alongside main's OBO incoming-auth check in MCPServer, and treat UnsupportedAuthType as a local-validation reason in isLocalValidationFailure. - Route the MCPServer terminal-error path through main's markExternalAuthConfigFailed, keeping the PR's skip of unchanged status writes. - Drop "obo when an enterprise handler is registered" wording and the deprecated EnterpriseRequired reason from the PR's godoc and tests; obo is now built in. - Move the support-matrix dispatch test into a fresh tokenexchange_test.go (main deleted the old file) and pass the consumer in main's OBO tests. - Regenerate CRD manifests and API docs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Chris Burns <[email protected]>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a referenced MCPExternalAuthConfig is healthy,
mirrorInvalidOnMCPServerandmirrorInvalidOnRemoteProxyremoved the consumer'sExternalAuthConfigValidatedcondition unlessownedByLocalValidationclaimed it.isLocalValidationFailureclaims onlyFalseconditions, so that included the healthy condition (True,ExternalAuthConfigValid), whichhandleExternalAuthConfigre-adds a few lines later with a freshLastTransitionTime. Every reconcile of a healthy MCPServer or MCPRemoteProxy with anexternalAuthConfigReftherefore wrote status, and the write triggered the next reconcile through the consumer's own watch, and a reconcile of every controller that watches MCPServers, such as MCPGroup.clearStaleMirrorremoves the condition only when it isFalseandownedByLocalValidationdoes not attribute it to another owner. The mirror only ever writesFalse, so aTruecondition is never a stale mirror.isLocalValidationFailurealso recognisesMultiUpstreamNotSupported(ConditionReasonExternalAuthConfigMultiUpstream, the same string as the MCPRemoteProxy constant), unless its message carriesmirroredMessagePrefix. The single-upstream check re-derives that condition after the mirror runs, like the two existing owners, so it flapped the same way. The same-hash guards insetMCPServerExternalAuthConfigValidConditionandsetMCPRemoteProxyExternalAuthConfigValidConditionalso requireReason == InvalidConfig, so they behave as before.clearStaleMirror. The heal path is unchanged: a stale mirroredFalseis still removed once the source is valid, which the existing "stale mirror is cleared when source has healed" case covers.VirtualMCPServer needs no change. It uses
mirroredExternalAuthConfigInvalidonly to build errors, and its status collector keeps one entry per condition type, so a remove followed by a set collapses into a set.Fixes #7161
Type of change
Test plan
task test)task test-e2e)task lint-fix)New table tests
TestMCPServerReconciler_handleExternalAuthConfig_DoesNotFlapLastTransitionTimeandTestMCPRemoteProxyReconciler_handleExternalAuthConfig_DoesNotFlapLastTransitionTimeseed the condition with aLastTransitionTimean hour in the past, the same technique asTestMCPServerReconciler_InvalidCABundleDoesNotFlapLastTransitionTime, and check thathandleExternalAuthConfigleaves it unchanged, for the healthyTruecondition and for theMultiUpstreamNotSupportedfailure.TestIsLocalValidationFailuregains a local and a mirroredMultiUpstreamNotSupportedcase. After rebasing ontomainat e7570b0: all three tests fail onmain'sexternal_auth_mirror.goand pass with this change, andgo testpasses for every unit-test package undercmd/thv-operator(the envtest suites undertest-integrationwere not run locally).golangci-lintv2.15.0 reported 0 issues oncmd/thv-operator/controllersbefore the rebase and was not re-run after it.Manual: a build of v0.63.0 with this change was deployed to the cluster described in #7161. Afterwards all 14 MCPServers kept the same
resourceVersionover 30 s, and operator CPU went from about 311m to about 8m. That deploy also restarted the operator, which on a second cluster appeared to quiet the churn on its own for a while, so the unit tests above are the direct evidence for the change.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Does this introduce a user-facing change?
Yes. An MCPServer or MCPRemoteProxy that references a healthy MCPExternalAuthConfig no longer has its status rewritten on every reconcile, so its
ExternalAuthConfigValidatedcondition keeps itslastTransitionTime, and the operator's reconcile rate, CPU use and log volume drop to what the cluster's real changes cause.🤖 Generated with Claude Code