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

fix: update node annotation used to limit log spam with valid key #6301

Conversation

brydoncheyney
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

#6265 introduced the ability for users to apply an annotation to cluster Nodes that are not managed by the autoscaler, reducing the amount of "spam" messages logged by the controller.

However, the chosen annotation key k8s.io/cluster-autoscaler/enabled is not a valid identifier - https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set - which expects only a single DNS prefix.

Attempting to manually add this annotation to an existing node will fail -

# nodes "ip-XXX-XXX-XXX-XXX.ec2.internal" was not valid:
# * metadata.annotations: Invalid value: "k8s.io/cluster-autoscaler/enabled": a qualified name must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')

Note that the use of the k8s.io/cluster-autoscaler/enabled tag is valid within AWS.

This PR uses a valid identifier k8s.io/cluster-autoscaler-enabled

Which issue(s) this PR fixes: 6300

Fixes #6300

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 20, 2023
Copy link

linux-foundation-easycla bot commented Nov 20, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: brydoncheyney / name: Brydon Cheyney (7de0d94)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 20, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @brydoncheyney!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added area/provider/aws Issues or PRs related to aws provider area/cluster-autoscaler size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 20, 2023
@drmorr0
Copy link
Contributor

drmorr0 commented Nov 20, 2023

OH, grumble.

I was thinking the tags got translated into annotations on the node but clearly not.

@gjtempleton can I can a second opinion on this? I feel less confident in my decision-making abilities now, lol

@vadasambar
Copy link
Member

vadasambar commented Nov 21, 2023

DNS regex validation check in kubernetes allows only a single /: https://github.com/kubernetes/kubernetes/blob/ec5096fa869b801d6eb1bf019819287ca61edc4d/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L45-L61

Seems like an easy to trip on thing.

@brydoncheyney
Copy link
Contributor Author

DNS regex validation check in kubernetes allows only a single /: kubernetes/kubernetes@ec5096f/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L45-L61

Seems like an easy to trip on thing.

The annotation key/value format is well documented - https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set - but I think the confusion here is easy to understand when you consider the AWS tags used by the cluster autoscaler, which do not follow the same conventions and can contain arbitrary characters not support by k8s annotations/labels.

tldr: easy mistake to make

@vadasambar
Copy link
Member

I will take a look if you don't mind @drmorr0 (we can get Guy to do the final review).

/assign @vadasambar

@vadasambar
Copy link
Member

LGTM overall. Thank you for the PR. I will do one more pass tomorrow.

@vadasambar
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 Nov 23, 2023
@vadasambar
Copy link
Member

@gjtempleton need your approval 🙏

@gjtempleton
Copy link
Member

Thanks for picking this up, agreed, on first pass my AWS tags brain couldn't see the problem.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brydoncheyney, gjtempleton, vadasambar

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 Dec 11, 2023
@k8s-ci-robot k8s-ci-robot merged commit 37673fe into kubernetes:master Dec 11, 2023
6 checks passed
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/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotation used to exclude Nodes from the autoscaler check uses invalid key
5 participants