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

[kubetest2-gke deployer] Automatically resolves the release channel if it's not specified #142

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

chizhg
Copy link
Contributor

@chizhg chizhg commented Jun 18, 2021

Sometimes when the users create the GKE clusters, they just want to specify a valid cluster version but do not want to hard code the channel, but if the version is only valid in a specific channel (e.g. rapid), the cluster creation will fail.

This PR adds the support to automatically resolve the release channel if it's not specified, so that as long as the specified version is in any of the valid release channels, kubetest2 gke --up will work.

/cc @amwat

@k8s-ci-robot k8s-ci-robot requested a review from amwat June 18, 2021 01:18
@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 Jun 18, 2021
@chizhg chizhg changed the title kubetest2-gke automatically resolves the release channel if it's not specified [kubetest2-gke deployer] Automatically resolves the release channel if it's not specified Jun 18, 2021
Copy link
Contributor

@amwat amwat left a comment

Choose a reason for hiding this comment

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

Let's make this best-effort instead of a run failing error.
Otherwise lgtm.

Isn't None channel usually a superset of all channels except maybe Rapid?

go.mod Outdated Show resolved Hide resolved
}

func validateReleaseChannel(releaseChannel string) error {
if releaseChannel != "" && !validReleaseChannels.Has(releaseChannel) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe can reuse toReleaseChannel to avoid needing sets.

Copy link
Contributor Author

@chizhg chizhg Jun 18, 2021

Choose a reason for hiding this comment

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

toReleaseChannel is used to convert the channel name in the server config to the channel name in the gcloud flag, so it cannot be used here. I have changed to simple array iteration to avoid using sets.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant since the strings are the same, we can use toLower/toUpper and the default case to also use it as a validation method.
But considering it's just 4 values the array solution is fine as well.

kubetest2-gke/deployer/up.go Outdated Show resolved Hide resolved
@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 Jun 18, 2021
Copy link
Contributor

@amwat amwat left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

/hold

couple of nits feel free to cancel the hold.

{
desc: "the same major.minor version is a match",
version: "1.19",
target: "1.19.10-gke.1000",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

also add a case with version and target swapped to exercise

if len(parts) < len(matchParts) {
		return false
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I'll address this comment in my next PR.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amwat, chizhg

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 lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 19, 2021
@chizhg
Copy link
Contributor Author

chizhg commented Jun 21, 2021

/unhold

@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 Jun 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit a86a3a5 into kubernetes-sigs:master Jun 21, 2021
@chizhg chizhg deleted the auto-release-channel branch November 3, 2021 21:59
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. 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.

3 participants