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

🐛 Ensure MachinePool Version is a valid Kubernetes version #6311

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Mar 17, 2022

What this PR does / why we need it: In the past we've added kube semver validations to KCP, MachineDeployment, Machines, and MachineSets. For some reason we missed MachinePool. This PR adds webhook defaulting to add the "v" prefix when it's missing and validation to make sure MachinePool version is valid, as well as unit tests.

Here's the equivalent changeset for MachineSets: https://github.com/kubernetes-sigs/cluster-api/pull/5406/files

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 #

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2022
@CecileRobertMichon CecileRobertMichon changed the title 🐛 Make sure MachinePool Version is a valid Kubernetes version 🐛 Ensure MachinePool Version is a valid Kubernetes version Mar 17, 2022
@sbueringer
Copy link
Member

/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 21, 2022

// tolerate version strings without a "v" prefix: prepend it if it's not there.
if m.Spec.Template.Spec.Version != nil && !strings.HasPrefix(*m.Spec.Template.Spec.Version, "v") {
normalizedVersion := "v" + *m.Spec.Template.Spec.Version
Copy link
Member

Choose a reason for hiding this comment

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

Just to double-check: is this triggering rollouts on existing infrastructure or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only if the user created a MP without the v prefix (which as described in #4651 isn't functional). Once the template version has the v prefix it won't modify it / cause a rollout.

@CecileRobertMichon
Copy link
Contributor Author

/assign @fabriziopandini

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@vincepri
Copy link
Member

Should we backport?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 28, 2022
@k8s-ci-robot k8s-ci-robot merged commit 93821f9 into kubernetes-sigs:main Mar 28, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.2 milestone Mar 28, 2022
@fabriziopandini
Copy link
Member

fabriziopandini commented Mar 31, 2022

Should we backport?

I leave the call on @CecileRobertMichon (no objections from my side)

@CecileRobertMichon
Copy link
Contributor Author

/cherry-pick release-1.1

@k8s-infra-cherrypick-robot

@CecileRobertMichon: new pull request created: #6364

In response to this:

/cherry-pick release-1.1

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.

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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants