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

🐛 Fixes default control, worker machine counts overriding user specified values #2597

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

gab-satchi
Copy link
Member

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 9, 2020
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 9, 2020
@nader-ziada
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 9, 2020
@vincepri
Copy link
Member

vincepri commented Mar 9, 2020

/assign @fabriziopandini

@@ -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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

@fabriziopandini fabriziopandini left a 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.

@gab-satchi
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2020
@vincepri
Copy link
Member

/milestone v0.3.x

@k8s-ci-robot k8s-ci-robot added this to the v0.3.x milestone Mar 10, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 10, 2020
@gab-satchi
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2020
Copy link
Member

@fabriziopandini fabriziopandini left a 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

cmd/clusterctl/client/config.go Show resolved Hide resolved
@fabriziopandini
Copy link
Member

Looks great @gab-satchi, thanks!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2020
@fabriziopandini
Copy link
Member

@vincepri over to you for a final pass

cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/config.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2020
@gab-satchi
Copy link
Member Author

/test pull-cluster-api-verify

@vincepri
Copy link
Member

/approve
/assign @fabriziopandini
/milestone v0.3.1

@k8s-ci-robot k8s-ci-robot modified the milestones: v0.3.x, v0.3.1 Mar 16, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 16, 2020
@vincepri
Copy link
Member

/milestone v0.3.x

@k8s-ci-robot k8s-ci-robot modified the milestones: v0.3.1, v0.3.x Mar 16, 2020
@vincepri
Copy link
Member

@fabriziopandini over to your for final lgtm

/milestone v0.3.4

@wfernandes
Copy link
Contributor

Reviewing...
/assign

…d values

- machine count values assigned in the order: defaults, env vars, flags
@gab-satchi gab-satchi force-pushed the 2560-replica-count branch from ded89fc to 02ec8e4 Compare April 3, 2020 21:45
@wfernandes
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 3, 2020
@k8s-ci-robot k8s-ci-robot merged commit bf4fcea into kubernetes-sigs:master Apr 3, 2020
@gab-satchi gab-satchi deleted the 2560-replica-count branch April 6, 2020 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clusterctl: Replica count env vars are not used
7 participants