-
Notifications
You must be signed in to change notification settings - Fork 771
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
func getStatefulSetReplicasCountAndReserveOrdinals(set *appsv1beta1.StatefulSet) (int, sets.Int) { | ||
reserveOrdinals := sets.NewInt(set.Spec.ReserveOrdinals...) | ||
replicaCount := 0 |
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.
replicaCount -> ordinal
@@ -693,3 +718,15 @@ func decreaseAndCheckMaxUnavailable(maxUnavailable *int) bool { | |||
*maxUnavailable = val | |||
return val <= 0 | |||
} | |||
|
|||
func getStatefulSetReplicasCountAndReserveOrdinals(set *appsv1beta1.StatefulSet) (int, sets.Int) { |
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.
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: |
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.
we can move this comment before the func definition of getStatefulSetReplicasCountAndReserveOrdinals
}, | ||
}, | ||
{ | ||
name: "reserveOrdinals is [2,3], scaleDown=false, whenScaled=Retain, whenDeleted=Delete", |
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.
what about make reserveOrdinals cover the boundary case,e.g. "reserveOrdinals is [2,4]"
Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
e7c7296
to
fadb1fe
Compare
/lgtm |
/approve |
[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 |
Ⅰ. Describe what this PR does
#1530
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how to verify it
Ⅳ. Special notes for reviews