fix: zero PodUpdatePolicy and PodUpgradePolicy in cmpdHash to prevent immutable-hash mismatch#10095
Conversation
… immutable-hash mismatch
|
Auto Cherry-pick Instructions |
|
I checked the history, and podUpdatePolicy / podUpgradePolicy were introduced into the v1 ComponentDefinition API in the 1.0 release line starting from v1.0.2, not v1.0.0 or v1.0.1. So the real compatibility case here is for v1 ComponentDefinition objects created on v1.0.0 / v1.0.1, whose stored immutable hash was generated before these fields existed. After upgrading to a version where these fields are present, the newly computed hash may differ even if the user did not change the object. Given that, the controller-side fix in this PR makes sense. But this is independent of whether addon manifests explicitly set podUpdatePolicy: PreferInPlace. Once cmpdHash() excludes these fields, the compatibility issue is addressed. Explicitly adding the default value in addon charts does not contribute to fixing this problem, so I do not think the companion addon PR is necessary. |
|
/pick release-1.0 |
|
/pick release-1.1 |
|
/approve |
|
Thanks for the contribution. I will merge this PR and cherry-pick it to release-1.0 and release-1.1. |
|
/cherry-pick release-1.0 |
|
/cherry-pick release-1.1 |
|
🤖 says: cherry pick action finished successfully 🎉! |
|
🤖 says: cherry pick action finished successfully 🎉! |
Summary
When addon charts don't explicitly set
podUpdatePolicyin their ComponentDefinition templates, the operator defaults it toPreferInPlaceafter creation. This changes theapps.kubeblocks.io/immutable-hashannotation, causing reconciliation to fail with"immutable fields can't be updated".PodManagementPolicyis already treated as mutable (zeroed before hashing incmpdHash()). This PR applies the same treatment toPodUpdatePolicyandPodUpgradePolicy.Root Cause
The
podUpdatePolicyfield was added toComponentDefinitionSpecwith defaultPreferInPlace, butcmpdHash()was not updated to exclude it from the immutable hash. Any ComponentDefinition created before the field existed (or by an addon chart that doesn't set it) gets a different hash after the operator defaults the field — triggering immutability violations.Changes
controllers/apps/componentdefinition_controller.go: zeroPodUpdatePolicyandPodUpgradePolicyincmpdHash()alongsidePodManagementPolicyCompanion PR
podUpdatePolicy: PreferInPlaceto all 122 cmpd templates (prevents the defaulting from happening)