-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🐛 Fixes default control, worker machine counts overriding user specified values #2597
🐛 Fixes default control, worker machine counts overriding user specified values #2597
Conversation
Hi @gab-satchi. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
/assign @fabriziopandini |
cmd/clusterctl/client/config.go
Outdated
@@ -305,13 +305,19 @@ func (c *clusterctlClient) templateOptionsToVariables(options GetClusterTemplate | |||
if options.ControlPlaneMachineCount < 1 { | |||
return errors.Errorf("invalid ControlPlaneMachineCount. Please use a number greater or equal than 1") | |||
} | |||
c.configClient.Variables().Set("CONTROL_PLANE_MACHINE_COUNT", strconv.Itoa(options.ControlPlaneMachineCount)) | |||
// set CONTROL_PLANE_MACHINE_COUNT if it isn't set already | |||
if _, err := c.configClient.Variables().Get("CONTROL_PLANE_MACHINE_COUNT"); err != nil { |
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.
shouldn't this be checking options.ControlPlaneMachineCount
like above for KubernetesVersion?
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.
do you mean checking that it isn't empty like we do for KubernetesVersion? The options.ControlPlaneMachineCount
defaults to 1 so it will always be set.
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.
@gab-satchi
IMO having defaults for the CONTROL_PLANE_MACHINE_COUNT and for the WORKER_MACHINE_COUNT makes a nice UX because it does not force the user to pass values.
Also, as a general rule, flags should always have precedence on env variables/variables on the config file.
and thus I don't think that we should go for the proposed implementation that reverts this logic only for the two flags.
So my suggestion is to fix the issue is to:
1 turn the options.ControlPlaneMachineCount and options.WorkerMachineCount to pointers
2 set options.ControlPlaneMachineCount and options.WorkerMachineCount only if the flags are actually set
3 to consider env variables/variables on the config file only if the option fields are nil.
/hold |
/milestone v0.3.x |
/hold cancel |
240754f
to
1da6713
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.
@gab-satchi thanks for addressing all the comments!
one last nit and then lgtm for me
Looks great @gab-satchi, thanks! |
@vincepri over to you for a final pass |
0e1ae44
to
ded89fc
Compare
/test pull-cluster-api-verify |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gab-satchi, vincepri 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 |
/milestone v0.3.x |
@fabriziopandini over to your for final lgtm /milestone v0.3.4 |
Reviewing... |
…d values - machine count values assigned in the order: defaults, env vars, flags
ded89fc
to
02ec8e4
Compare
/lgtm |
What this PR does / why we need it:
Replica counts set by the user through ENV vars or config file isn't being used as the flag options take precedence. The flags for control and worker counts default to 1 and 0 respectively and were overriding any values set as ENV vars.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2560