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

KCP/CABPK should reject known invalid Kubernetes versions #3697

Closed
ncdc opened this issue Sep 25, 2020 · 26 comments
Closed

KCP/CABPK should reject known invalid Kubernetes versions #3697

ncdc opened this issue Sep 25, 2020 · 26 comments
Assignees
Labels
area/bootstrap Issues or PRs related to bootstrap providers area/control-plane Issues or PRs related to control-plane lifecycle management help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@ncdc
Copy link
Contributor

ncdc commented Sep 25, 2020

What steps did you take and what happened:

  1. Try to create a cluster with KCP.spec.kubernetesVersion set to something like v1.19.1_mycompany.2
  2. kubeadm bootstrapping fails with this in the output
couldn't parse Kubernetes version "v1.19.1_mycompany.2": could not parse pre-release/metadata (_mycompany.2) in version "v1.19.1_mycompany.2"

What did you expect to happen:

  1. kubeadm bootstrapping succeeds

Anything else you would like to add:
For this example, a valid/appropriate version would be v1.19.1+mycompany.2.

kubeadm only accepts valid semver values. We should consider adding webhook validations for both KCP and KubeadmConfig.

Environment:

  • Cluster-api version: v0.3.x

/kind bug
/area control-plane
/area bootstrap

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/control-plane Issues or PRs related to control-plane lifecycle management area/bootstrap Issues or PRs related to bootstrap providers labels Sep 25, 2020
@ncdc
Copy link
Contributor Author

ncdc commented Sep 25, 2020

cc @fabriziopandini

@vincepri
Copy link
Member

Seems we're using this regex

var kubeSemver = regexp.MustCompile(`^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$`)
to validate the KCP.Spec.Version field, and it seems it does allow for underscores 🤔

@vincepri
Copy link
Member

cc @CecileRobertMichon as well, given that the regex came in #3147

@vincepri
Copy link
Member

@ncdc Not sure if you wanna tackle this in v0.3.x or later, if we do remove the underscore from the regex, it could technically break some controllers out there from patching, that said their clusters would already pretty much be broken at that point

@ncdc
Copy link
Contributor Author

ncdc commented Sep 25, 2020

/milestone v0.4.0

@k8s-ci-robot k8s-ci-robot added this to the v0.4.0 milestone Sep 25, 2020
@CecileRobertMichon
Copy link
Contributor

@vincepri regex actually came from 32e6e61#diff-99f38c7c07bfcc03a528180716bafab5R58, I just reused the same one in webhook validation (couldn't use the one in util because it created a dependency cycle)

@vincepri
Copy link
Member

Thanks, I wish we added a comment on where that regex came from :/

@vincepri
Copy link
Member

We can probably use this issue to align all our validations on Kubernetes versions, and use the exact same code / parsing everywhere

@vincepri
Copy link
Member

@fabriziopandini What do you think the best way to proceed here? Are you able to work on this?

@fabriziopandini
Copy link
Member

Let me take a look tomorrow and try to get a picture of all the points where we are doing version validation before making an action plan

@fabriziopandini
Copy link
Member

fabriziopandini commented Sep 29, 2020

@vincepri I have found following field in the API holding a Kubernetes version and the corresponding web hook validation:

  1. Machine.Spec.Version: validated using wrong regex :-(
  2. MachineDeployments.Spec.Template.Spec.Version: not validated :-(
  3. KubeadmConfig.Spec.ClusterConfiguration.KubernetesVersion: not validated :-(
  4. KubeadmConfigTemplate.Spec.Template.Spec.ClusterConfiguration.KubernetesVersion: not validated :-(
  5. KubeadmControlPlane.Spec.Version: validated using wrong regex :-(
  6. MachinePools.Spec.Template.Spec.Version: not validated :-(

So my plan is to craft a PR that ensures

  • all the defaulting web hook adding v in front of version, if missing.
  • all the validating web hook are checking version using version.ParseSemantic

@fabriziopandini
Copy link
Member

/assign
/lifecycle active

@k8s-ci-robot k8s-ci-robot added the lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. label Sep 29, 2020
@vincepri
Copy link
Member

vincepri commented Sep 29, 2020

all the defaulting web hook add adding v in front of version, if missing.

This might be a breaking change and cause a rollout in some cases

@fabriziopandini
Copy link
Member

/remove-lifecycle active
TBD an approach that does not trigger rollouts

@k8s-ci-robot k8s-ci-robot removed the lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. label Oct 6, 2020
@fabriziopandini
Copy link
Member

/unassing @fabriziopandini

@fabriziopandini fabriziopandini removed their assignment Nov 9, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 7, 2021
@fabriziopandini
Copy link
Member

/lifecycle frozen
I think we should make version management consistent across resources and leverage v1alpha3 --> v1alpha4 conversion to fix existing resources without triggering rollout
@vincepri opinions?

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 8, 2021
@fabriziopandini
Copy link
Member

/priority important-soon
This should be re-evaluated after #4163 merged

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Mar 10, 2021
@fabriziopandini
Copy link
Member

/help

@k8s-ci-robot
Copy link
Contributor

@fabriziopandini:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

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 help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Mar 10, 2021
@vincepri
Copy link
Member

I think we should make version management consistent across resources and leverage v1alpha3 --> v1alpha4 conversion to fix existing resources without triggering rollout

How would that work for folks using gitops? That would cause their changes to be overwritten, and possibly still causing a rollout if we overwrite their changes.

I'd rather have the validation/defaulting/mutation be in a webhook, and return a warning (I think there is support for these now?) and in the next version we'd start breaking folks. I'd want to avoid any magic changes during upgrades using the CLI.

@vincepri
Copy link
Member

/milestone Next

@k8s-ci-robot k8s-ci-robot modified the milestones: v0.4, Next Oct 19, 2021
@vincepri
Copy link
Member

/assign @killianmuldoon
/milestone v1.1

@k8s-ci-robot k8s-ci-robot modified the milestones: Next, v1.1 Oct 29, 2021
@fabriziopandini fabriziopandini modified the milestones: v1.1, v1.2 Feb 3, 2022
@fabriziopandini fabriziopandini added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jul 29, 2022
@fabriziopandini fabriziopandini removed this from the v1.2 milestone Jul 29, 2022
@fabriziopandini fabriziopandini removed the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jul 29, 2022
@fabriziopandini
Copy link
Member

/close
in favour of #7011 and #7010

@k8s-ci-robot
Copy link
Contributor

@fabriziopandini: Closing this issue.

In response to this:

/close
in favour of #7011 and #7010

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
area/bootstrap Issues or PRs related to bootstrap providers area/control-plane Issues or PRs related to control-plane lifecycle management help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

7 participants