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

Use image.tag for app.kubernetes.io/version label if defined #190

Merged

Conversation

davidcaste
Copy link
Contributor

Why is this pull request needed and what does it do?

The Deployment object has a label named app.kubernetes.io/version which value is Chart.AppVersion. But this is not always true because the chart allows to specify the image tag with the image.tag.

I think it makes more sense to use the same mechanism as with the image tag. Use Chart.AppVersion by default but use image.tag if present.

Which issues (if any) are related?

n/a

Checklist:

  • I have bumped the chart version according to versioning.
  • I have updated the chart changelog with all the changes that come with this pull request according to changelog.
  • Any new values are backwards compatible and/or have sensible default.
  • I have signed off all my commits as required by DCO.

Changes are automatically published when merged to main. They are not published on branches.

Note on DCO

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

@hagaibarel hagaibarel merged commit b7df8ac into coredns:master Jan 20, 2025
2 checks passed
@hagaibarel
Copy link
Collaborator

Thanks for the PR!

@jBouyoud
Copy link

Hi @hagaibarel ,

FYI, when we use an immutable tag like v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97 , the tag value is not a valid label value and users could get the following error :

Error: UPGRADE FAILED: release coredns failed, and has been rolled back due to atomic being set: cannot patch "coredns" with kind Deployment: Deployment.apps "coredns" is invalid: [metadata.labels: Invalid value: "v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97": must be no more than 63 characters, metadata.labels: Invalid value: "v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')]

Could you please consider fixed this behavior, probably with something like : | replace ":" "-" | replace "@" "_" | trunc 63 | trimSuffix "-" in the label template.

Thanks

@davidcaste
Copy link
Contributor Author

Hi @hagaibarel ,

FYI, when we use an immutable tag like v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97 , the tag value is not a valid label value and users could get the following error :

Error: UPGRADE FAILED: release coredns failed, and has been rolled back due to atomic being set: cannot patch "coredns" with kind Deployment: Deployment.apps "coredns" is invalid: [metadata.labels: Invalid value: "v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97": must be no more than 63 characters, metadata.labels: Invalid value: "v1.12.0@sha256:40384aa1f5ea6bfdc77997d243aec73da05f27aed0c5e9d65bfa98933c519d97": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')]

Could you please consider fixed this behavior, probably with something like : | replace ":" "-" | replace "@" "_" | trunc 63 | trimSuffix "-" in the label template.

Thanks

I'll create right now another PR fixing the problem you noticed. Sorry for any inconvenience!

@davidcaste davidcaste deleted the fix/deployment_app_version_label branch January 20, 2025 14:28
@davidcaste
Copy link
Contributor Author

Hi @jBouyoud , I already created the PR #192. Sorry for any inconvenience!!

@jBouyoud
Copy link

Thank you 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants