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 bug: allow optional filed maxunavilable to be nil in ads, and set default … #1007

Merged

Conversation

ABNER-1
Copy link
Member

@ABNER-1 ABNER-1 commented Jun 27, 2022

fix bug: allow optional filed max unavilable in ads, and set default value 1

Ⅰ. Describe what this PR does

  1. allow optional filed max unavilable to be nil in ads
  2. set max unavilable default value to 1

Ⅱ. Does this pull request fix one issue?

fixes #1006

Ⅲ. Describe how to verify it

update ads with nil MaxUnavailable.

Ⅳ. Special notes for reviews

@kruise-bot kruise-bot requested review from Fei-Guo and furykerry June 27, 2022 15:23
@kruise-bot
Copy link

Welcome @ABNER-1! It looks like this is your first PR to openkruise/kruise 🎉

@kruise-bot kruise-bot added the size/XS size/XS: 0-9 label Jun 27, 2022
@ABNER-1 ABNER-1 force-pushed the bugfix/allow_optional_field_in_ads branch 2 times, most recently from 9409636 to 83a4ffe Compare June 27, 2022 15:27
…value as 1

Signed-off-by: ABNER-1 <abner199709@gmail.com>
Signed-off-by: yuanyuxing <yuanyuxing@bilibili.com>
@ABNER-1 ABNER-1 force-pushed the bugfix/allow_optional_field_in_ads branch from 83a4ffe to 45c8ce2 Compare June 27, 2022 15:28
@ABNER-1 ABNER-1 changed the title fix bug: allow optional filed max unavilable in ads, and set default … fix bug: allow optional filed maxunavilable to be nil in ads, and set default … Jun 27, 2022
@@ -254,7 +254,10 @@ func unavailableCount(ds *appsv1alpha1.DaemonSet, numberToSchedule int) (int, er
}
r := ds.Spec.UpdateStrategy.RollingUpdate
if r == nil {
return 0, nil
return 1, nil
Copy link
Member

Choose a reason for hiding this comment

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

This should not be changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just refer to the implementation of max surge and return the default value of maxunavilable in the doc.
Sorry to change this because I did not read all codes in ds reconcile function.

return 1, nil
}
if r.MaxUnavailable == nil {
return 1, nil
Copy link
Member

Choose a reason for hiding this comment

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

It should return 0 which is same as maxSurge (here), and then controller will set maxUnavailable to 1 if they are all 0 (here).

…mally

Signed-off-by: yuanyuxing <yuanyuxing@bilibili.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1007 (9d3cc4f) into master (345c292) will increase coverage by 0.56%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
+ Coverage   49.10%   49.66%   +0.56%     
==========================================
  Files         125      124       -1     
  Lines       12062    12090      +28     
==========================================
+ Hits         5923     6005      +82     
+ Misses       5235     5166      -69     
- Partials      904      919      +15     
Flag Coverage Δ
unittests 49.66% <50.00%> (+0.56%) ⬆️

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

Impacted Files Coverage Δ
pkg/controller/daemonset/daemonset_util.go 57.85% <50.00%> (+0.82%) ⬆️
pkg/controller/cloneset/cloneset_event_handler.go 78.68% <0.00%> (-0.78%) ⬇️
pkg/webhook/pod/mutating/pod_readiness.go 0.00% <0.00%> (ø)
pkg/webhook/pod/mutating/workloadspread.go 0.00% <0.00%> (ø)
pkg/controller/cloneset/cloneset_controller.go 54.15% <0.00%> (ø)
.../webhook/pod/mutating/pod_create_update_handler.go 0.00% <0.00%> (ø)
...roller/workloadspread/workloadspread_controller.go 61.11% <0.00%> (ø)
...sistentpodstate/persistent_pod_state_controller.go 31.10% <0.00%> (ø)
pkg/util/client.go
pkg/controller/cloneset/sync/cloneset_update.go 47.71% <0.00%> (+0.42%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 345c292...9d3cc4f. Read the comment docs.

Copy link
Member

@FillZpp FillZpp left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FillZpp

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 6b4691c into openkruise:master Jul 18, 2022
@FillZpp FillZpp added this to the v1.3.0 milestone Jul 21, 2022
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Sep 14, 2022
… default … (openkruise#1007)

* fix bug: allow optional filed max unavilable in ads, and set default value as 1

Signed-off-by: ABNER-1 <abner199709@gmail.com>
Signed-off-by: yuanyuxing <yuanyuxing@bilibili.com>

* return 0 when max unavailable is nil and make the validation work normally

Signed-off-by: yuanyuxing <yuanyuxing@bilibili.com>

Co-authored-by: yuanyuxing <yuanyuxing@bilibili.com>
Signed-off-by: Liu Zhenwei <zwliu@thoughtworks.com>
ppbits pushed a commit to ppbits/kruise that referenced this pull request Apr 4, 2024
… default … (openkruise#1007)

* fix bug: allow optional filed max unavilable in ads, and set default value as 1


* return 0 when max unavailable is nil and make the validation work normally


Co-authored-by: yuanyuxing <yuanyuxing@bilibili.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.

[BUG] Why Optional Field <MaxUnavailable> can not be set nil?
4 participants