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 2932: let the capi version to be discovered #2934

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Mar 13, 2020

Add the ability to override CAPI group via env variable and discovers the API version.

This change adds detection for an environment variable to specify the group for the clusterapi resources. If the environment variable CAPI_GROUP is specified, then it will be used instead of the default. This also decouples the API group from the version and let the latter to be discovered dynamically.

Fixes #2932

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 13, 2020
@k8s-ci-robot k8s-ci-robot requested review from elmiko and hardikdr March 13, 2020 12:37
@enxebre
Copy link
Member Author

enxebre commented Mar 13, 2020

/hold
To do some manual validations
cc @frobware @elmiko

@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 13, 2020
@enxebre
Copy link
Member Author

enxebre commented Mar 13, 2020

/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 13, 2020
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Codewise looks good, just wondering whether we want to be calling all the variables etc Machine API or Cluster API, do we have a preference?

@elmiko
Copy link
Contributor

elmiko commented Mar 13, 2020

Codewise looks good, just wondering whether we want to be calling all the variables etc Machine API or Cluster API, do we have a preference?

agreed, i think if we can use "cluster api" here it will reduce any confusion for someone reading this. at the very least we should name the external bits (eg env variable) to reflect cluster api.


machineSetResource, _ := schema.ParseResourceArg(fmt.Sprintf("machinesets.%v", defaultMachineAPI))
machineSetResource, _ := schema.ParseResourceArg(fmt.Sprintf("machinesets.%v", specifiedMachineAPI))
if machineSetResource == nil {
panic("MachineSetResource")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should really return an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

mm why? atm MachineDeployment, MachineSets and Machine` are intentionally assumed to exist so it seems reasonable to me to panic here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it makes unit tests easier to write and assert for expected behaviour.

Copy link
Member Author

@enxebre enxebre Mar 16, 2020

Choose a reason for hiding this comment

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

ok make sense, let's address this separately from this PR. I'll move the capi resource expectations into its own unit tested func which errors and let the caller panic.

@enxebre enxebre force-pushed the fix-2932 branch 2 times, most recently from 2f20344 to 223ef38 Compare March 16, 2020 09:43
@enxebre
Copy link
Member Author

enxebre commented Mar 16, 2020

Codewise looks good, just wondering whether we want to be calling all the variables etc Machine API or Cluster API, do we have a preference?

agreed, i think if we can use "cluster api" here it will reduce any confusion for someone reading this. at the very least we should name the external bits (eg env variable) to reflect cluster api.

I renamed to CAPI consistently and moved code to fetch the preferred version into unit tested getAPIGroupPreferredVersion

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

in general it looks good to me, deduplicating the tests seems like a good idea.

@enxebre
Copy link
Member Author

enxebre commented Mar 16, 2020

in general it looks good to me, deduplicating the tests seems like a good idea.

Addressed comments and meld into one commit. PTAL @elmiko @frobware @JoelSpeed

Copy link
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

/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 16, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 16, 2020
…API version.

This change adds detection for an environment variable to specify the group for the clusterapi resources. If the environment
variable `CAPI_GROUP` is specified, then it will
be used instead of the default.
This also decouples the API group from the version and let the latter to be discovered dynamically.
Copy link
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

The issue (#2934) talks about discovering the version but, unless I'm mistaken, this only allows the group to be overridden. True?

@enxebre
Copy link
Member Author

enxebre commented Mar 16, 2020

The issue (#2934) talks about discovering the version but, unless I'm mistaken, this only allows the group to be overridden. True?

This PR enables an env variable to override the default CAPI group and discovers the API version (#2932) see https://github.com/kubernetes/autoscaler/pull/2934/files#diff-89363471d762322b93c9bcfec57b5af8R302. Let me update the PR desc with the commit message.

@frobware
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: frobware

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
@enxebre
Copy link
Member Author

enxebre commented Mar 16, 2020

/area provider/cluster-api

@k8s-ci-robot k8s-ci-robot added the area/provider/cluster-api Issues or PRs related to Cluster API provider label Mar 16, 2020
@elmiko
Copy link
Contributor

elmiko commented Mar 16, 2020

/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 16, 2020
@k8s-ci-robot k8s-ci-robot merged commit ee627f2 into kubernetes:master Mar 16, 2020
k8s-ci-robot added a commit that referenced this pull request May 4, 2020
[CA-1.18] #2934 cherry-pick: Fixes 2932: let the capi version to be discovered
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. area/provider/cluster-api Issues or PRs related to Cluster API provider 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. 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.

Let the CAPI group be overridden and discover the preferred version
5 participants