-
Notifications
You must be signed in to change notification settings - Fork 802
allow adding/removing VCTs for StatefulSet with OnPodRollingUpdate #2043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
allow adding/removing VCTs for StatefulSet with OnPodRollingUpdate #2043
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @ninavdl! It looks like this is your first PR to openkruise/kruise 🎉 |
9f1b0df
to
10ab9e8
Compare
…tatefulSet with OnPodRollingUpdate changes Signed-off-by: Nina van der Linden <[email protected]>
10ab9e8
to
04f73b9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2043 +/- ##
==========================================
+ Coverage 43.77% 43.90% +0.12%
==========================================
Files 316 316
Lines 31615 31670 +55
==========================================
+ Hits 13841 13906 +65
+ Misses 16373 16368 -5
+ Partials 1401 1396 -5
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:
|
e7fed35
to
f2e9155
Compare
Signed-off-by: Nina van der Linden <[email protected]>
f2e9155
to
ea2a91d
Compare
Hi, @ninavdl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @ninavdl .
Great job! Your contribution is highly appreciated.
Here are some suggestions to make it even better.
if !canInPlace { | ||
return nil | ||
} | ||
if opts.RecreatePodWhenChangedVolumeClaimTemplate && !opts.IgnoreVolumeClaimTemplatesHashDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to make this change? It doesn't seem essential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The hash is only recorded for the CloneSet.
- When adding or removing VCTs in a StatefulSet, users may need to add or remove corresponding volume mounts. This implies that the Pod cannot be updated in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.RecreatePodWhenChangedVolumeClaimTemplate
is true if the feature gate RecreatePodWhenChangeVCTInCloneSetGate
or RecreatePodWhenChangeVCTInStatefulSetGate
is enabled
@@ -918,6 +918,110 @@ var _ = SIGDescribe("AppStatefulSetStorage", func() { | |||
sst.WaitForStatusPVCReadyReplicas(ss, 1) | |||
}) | |||
}) | |||
|
|||
ginkgo.Describe("Recreate Pod when modifying volumeClaimTemplate with OnPodRollingUpdate", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add cases about sts withInPlaceUpdateReady
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a case about rename volume name in vcts and volumeMounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a case for renaming VCTs.
What do you mean by sts withInPlaceUpdateReady?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry.
By default, the StatefulSets created by NewStatefulSet
use the Recreate update strategy.
We should add test cases to cover all scenarios (adding, removing, and renaming) for StatefulSets with InPlaceIfPossiblePodUpdateStrategyType
update strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may refer to
kruise/test/e2e/apps/statefulset.go
Lines 85 to 91 in e85fa5b
injectSC := func(podUpdatePolicy appsv1beta1.PodUpdateStrategyType, ss *appsv1beta1.StatefulSet, volumeClaimUpdateStrategy appsv1beta1.VolumeClaimUpdateStrategyType, scNames ...string) { | |
if podUpdatePolicy == appsv1beta1.InPlaceIfPossiblePodUpdateStrategyType { | |
ss.Spec.UpdateStrategy.RollingUpdate = &appsv1beta1.RollingUpdateStatefulSetStrategy{ | |
PodUpdatePolicy: podUpdatePolicy, | |
} | |
ss.Spec.Template.Spec.ReadinessGates = append(ss.Spec.Template.Spec.ReadinessGates, v1.PodReadinessGate{ConditionType: appspub.InPlaceUpdateReady}) | |
} |
Please add a TODO item near |
Perhaps we can add a label to help users identify these PVCs. |
Signed-off-by: Nina van der Linden <[email protected]>
Signed-off-by: Nina van der Linden <[email protected]>
45518a9
to
e85fa5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ninavdl this patch only ensure the pod is recreated if VCT of statefulset changes, but it does not address the problem of changing existing PVC. currently PVC is only deleted when statefulset scale down or statefulset itself get deleted. So we may have to add another PersistentVolumeClaimRetentionPolicyType to make the patch really work
@@ -377,7 +379,8 @@ func ValidateVolumeClaimTemplateUpdate(c client.Client, sts, oldSts *appsv1beta1 | |||
sts.Spec.VolumeClaimUpdateStrategy.Type == appsv1beta1.OnPVCDeleteVolumeClaimUpdateStrategyType { | |||
return nil | |||
} | |||
if len(sts.Spec.VolumeClaimTemplates) != len(oldSts.Spec.VolumeClaimTemplates) { | |||
if len(sts.Spec.VolumeClaimTemplates) != len(oldSts.Spec.VolumeClaimTemplates) && | |||
!utilfeature.DefaultFeatureGate.Enabled(features.RecreatePodWhenChangeVCTInStatefulSetGate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can check against the feature gate features.RecreatePodWhenChangeVCTInStatefulSetGate and return nil early in L379
@ninavdl: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Ⅰ. Describe what this PR does
Currently, when
OnPodRollingUpdate
is enabled, as per https://openkruise.io/docs/user-manuals/advancedstatefulset#validation-rules-onpodrollingupdate-mode it is not supported to add/remove volumeClaimTemplates to an existing Advanced StatefulSet.This PR adds a feature flag
RecreatePodWhenChangeVCTInStatefulSetGate
(similar to the already existingRecreatePodWhenChangeVCTInCloneSetGate
), with which VCTs can be added to an existingStatefulSet
withOnPodRollingUpdate
. Adding/removing a VCT then causes the Pods to be recreated.Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how to verify it
StatefulSet
withOnPodRollingUpdate
StatefulSet
and mount it in a Pod templateⅣ. Special notes for reviews