Skip to content
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

Fix when statefulset reserveOrdinals exist, scale down pvc failed #1531

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

zmberg
Copy link
Member

@zmberg zmberg commented Mar 21, 2024

Ⅰ. Describe what this PR does

#1530

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

@kruise-bot kruise-bot requested review from Fei-Guo and FillZpp March 21, 2024 02:37
@kruise-bot kruise-bot added the size/L size/L: 100-499 label Mar 21, 2024
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.91%. Comparing base (7270f40) to head (fadb1fe).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1531      +/-   ##
==========================================
+ Coverage   47.90%   47.91%   +0.01%     
==========================================
  Files         162      162              
  Lines       23482    23491       +9     
==========================================
+ Hits        11248    11256       +8     
- Misses      11013    11014       +1     
  Partials     1221     1221              
Flag Coverage Δ
unittests 47.91% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


func getStatefulSetReplicasCountAndReserveOrdinals(set *appsv1beta1.StatefulSet) (int, sets.Int) {
reserveOrdinals := sets.NewInt(set.Spec.ReserveOrdinals...)
replicaCount := 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replicaCount -> ordinal

@@ -693,3 +718,15 @@ func decreaseAndCheckMaxUnavailable(maxUnavailable *int) bool {
*maxUnavailable = val
return val <= 0
}

func getStatefulSetReplicasCountAndReserveOrdinals(set *appsv1beta1.StatefulSet) (int, sets.Int) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getStatefulSetReplicasCountAndReserveOrdinals -> getStatefulSetReplicasRange

plz leave comment in the code about the return value ,e.g ordinalCount, reservedOrdinals

@@ -203,6 +216,18 @@ func updateClaimOwnerRefForSetAndPod(claim *v1.PersistentVolumeClaim, set *appsv
updateMeta(&podMeta, "Pod")
setMeta := set.TypeMeta
updateMeta(&setMeta, "StatefulSet")
// replicaCount and reserveOrdinals are used to support reserveOrdinals scenarios as follows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move this comment before the func definition of getStatefulSetReplicasCountAndReserveOrdinals

},
},
{
name: "reserveOrdinals is [2,3], scaleDown=false, whenScaled=Retain, whenDeleted=Delete",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about make reserveOrdinals cover the boundary case,e.g. "reserveOrdinals is [2,4]"

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
@zmberg zmberg force-pushed the fix-gc-pvc-failed branch from e7c7296 to fadb1fe Compare March 21, 2024 05:29
@furykerry
Copy link
Member

/lgtm

@zmberg
Copy link
Member Author

zmberg commented Mar 21, 2024

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot merged commit f843b85 into openkruise:master Mar 21, 2024
33 of 34 checks passed
zmberg added a commit that referenced this pull request Mar 21, 2024
)

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
zmberg added a commit that referenced this pull request Mar 21, 2024
)

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants