fix(operator): skip no-op VirtualMCPServer Deployment updates - #6377
fix(operator): skip no-op VirtualMCPServer Deployment updates#6377RaviTharuma wants to merge 5 commits into
Conversation
statusReportingInterval requeues were treated as drift when a user PodTemplateSpec left extra labels on the live template. Compare metadata as a subset, use semantic env equality, and skip Update when the pod template is unchanged so generation stops bumping every interval. Fixes stacklok#6340
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Signed-off-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
Signed-off-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6377 +/- ##
=======================================
Coverage 77.69% 77.70%
=======================================
Files 752 756 +4
Lines 72717 72800 +83
=======================================
+ Hits 56500 56569 +69
- Misses 16212 16226 +14
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Nice fix for the root cause — the subset check + semantic env comparison directly address the drift false-positive from #6340, and the regression test follows the reconcile-twice/assert- One question on the "second line of defense" skip-write gate added in if equality.Semantic.DeepEqual(deployment.Spec.Template, newDeployment.Spec.Template) &&
maps.Equal(deployment.Labels, newDeployment.Labels) &&
maps.Equal(deployment.Annotations, mergedAnnotations) &&
replicasUnchanged {
return ctrl.Result{}, nil
}
Since the actual fix already lives in |
Cross-links
Summary
VirtualMCPServer
statusReportingIntervalrequeues (including the CRD 30sdefault) called
Updateon the Deployment even when the pod template wasunchanged. That bumped
metadata.generationand emittedDeploymentUpdatedwith no new ReplicaSet — and only for vMCPs that had a unique
podTemplateSpec.Root cause:
podTemplateMetadataNeedsUpdateusedmaps.Equalon the fulllabel/annotation maps. User
PodTemplateSpecmerge leaves extra keys on thelive template, so every status tick looked like drift.
MapIsSubset(expected ⊆ live)equality.Semantic.DeepEqual(K8s defaulting)annotations, and replicas are unchanged
Fixes #6340
Type of change
Test plan
go test -ldflags=-extldflags=-Wl,-w ./cmd/thv-operator/controllers/ -run 'TestVirtualMCPServerEnsureDeployment_PodTemplateSpecSteadyState|TestVirtualMCPServerPodTemplateSpec'podTemplateSpecshouldnot emit
DeploymentUpdatedon everystatusReportingIntervaltickAPI Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.No CRD schema change.
Does this introduce a user-facing change?
Yes. VirtualMCPServer Deployments no longer get a no-op Update (and a
generation bump) on every status-interval reconcile.
Special notes for reviewers
Matches the suggested fix on #6340: do not treat the status requeue itself as
drift. The subset check is what stops
podTemplateSpecextras from lookinglike a spec change; the skip-write is a second line of defense if
deploymentNeedsUpdateis still true for a non-template reason.