Fix MCPRegistry operator to update deployments on spec changes#4237
Merged
Fix MCPRegistry operator to update deployments on spec changes#4237
Conversation
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4237 +/- ##
==========================================
- Coverage 69.32% 69.27% -0.05%
==========================================
Files 470 470
Lines 47189 47240 +51
==========================================
+ Hits 32712 32726 +14
- Misses 11957 11965 +8
- Partials 2520 2549 +29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Contributor
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
ChrisJBurns
approved these changes
Mar 19, 2026
Sanskarzz
pushed a commit
to Sanskarzz/toolhive
that referenced
this pull request
Mar 23, 2026
…lok#4237) * Fix MCPRegistry operator to update deployments on spec changes Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> * Add integration tests Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> * Add more integration tests Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com> --------- Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
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
The MCPRegistry controller was ignoring changes to
spec.podTemplateSpec(and all other spec fields) after the initial Deployment creation. TheensureDeploymentmethod had a TODO that returned the stale existing Deployment without applying updates, so fields likeimagePullSecretsand containerenvfrompodTemplateSpecwere silently dropped.This fix adds hash-based change detection (matching the VirtualMCPServer controller pattern) and selective Deployment updates when changes are detected.
Type of change
Changes
cmd/thv-operator/pkg/registryapi/deployment.godeploymentNeedsUpdatefunction, implement selective Deployment update logiccmd/thv-operator/pkg/registryapi/deployment_test.godeploymentNeedsUpdate(8 cases) and PodTemplateSpec hash computation (3 cases),Test plan
task lintpasses with 0 issuestask test— all registryapi package tests passTestDeploymentNeedsUpdatecovers nil, identical, config hash change, PTS hash change/add/remove, and image change scenariosTestBuildRegistryAPIDeployment_PodTemplateSpecHashverifies hash presence/absence and uniquenessSpecial notes for reviewers
podtemplatespec hashannotation + config checksum)Spec.Replicasis preserved on the existing Deployment to avoid conflicts with HPALarge PR Justification