fix(controller): patch CR metadata without owning spec#10264
Conversation
|
Auto Cherry-pick Instructions |
|
LGTM (peer review, 不能 formal approve 因为共享 GitHub identity). Code-level second review verified:
Scope verification (high-leverage fix):
Non-blocker observations (future follow-up):
Test boundary: plain Go tests assert patch-data contract at byte level (envtest BeforeSuite unavailable due to missing mergeStateStatus=BLOCKED expected (only formal review gate); CI just queued. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10264 +/- ##
==========================================
- Coverage 52.73% 52.69% -0.05%
==========================================
Files 534 534
Lines 61231 61234 +3
==========================================
- Hits 32288 32265 -23
- Misses 25691 25706 +15
- Partials 3252 3263 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Live verification cross-reference (release-1.0 backport PR #10265) — release-1.0 backport with identical production diff was patch-imaged, sideloaded to idc2, and validated against the SQL Server addon's mix-A-1 v18 in-place helm upgrade scenario.
Since this PR (main) and #10265 (release-1.0) carry identical production diff (verified via |
|
/pick release-1.1 release-1.0 |
Summary
Context
Helm server-side apply upgrades can conflict when controller metadata updates are submitted as full-object updates. The apiserver may then record the controller manager as owning spec fields that were rendered by the chart, such as
ComponentVersion.spec.releasesorOpsDefinition.spec.actions.This change keeps the controller write path scoped to metadata for those reconciliation steps.
HandleCRDeletionis used by multiple CR reconcilers, including ComponentVersion, OpsDefinition, OpsRequest, Addon, Restore, BackupRepo, ActionSet, BackupSchedule, BackupPolicy, and legacy parameter config rendering paths, so the fix prevents the same managedFields ownership drift across those metadata-only finalizer paths.Validation
go test ./pkg/controllerutil -run TestHandleCRDeletionPatchesFinalizerMetadata -count=1 -vgo test ./controllers/apps -run TestComponentVersionSupportedCompDefLabelsUsesMetadataPatch -count=1 -vgo test -c ./controllers/appsgo test -c ./controllers/operationsgo test -c ./pkg/controllerutilgit diff --checkBoundary
Local tests assert the generated patch payload contains metadata changes and does not contain
spec. Live managedFields and Helm in-place upgrade validation should be run with a patch image against the addon upgrade scenario.