Fix too long kubernetes labels when using digest in image tag #326
Fix too long kubernetes labels when using digest in image tag #326barskern wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 8 minutes and 42 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ChangesVersion label configuration
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0dc27fa to
7098b93
Compare
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@charts/meilisearch/templates/_helpers.tpl`:
- Around line 37-40: The helper currently computes $rawVersion only from
.Values.image.tag or .Chart.AppVersion so .Values.image.versionLabel is ignored;
change the $rawVersion assignment to prefer .Values.image.versionLabel first,
falling back to .Values.image.tag then .Chart.AppVersion (e.g. set $rawVersion
:= .Values.image.versionLabel | default (.Values.image.tag | default
.Chart.AppVersion)), leaving the subsequent $version
regexReplaceAll/trunc/trimSuffix and the app.kubernetes.io/version label
generation unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 55ed916a-b82b-4201-871f-b9f53c880d85
📒 Files selected for processing (2)
charts/meilisearch/templates/_helpers.tplcharts/meilisearch/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- charts/meilisearch/values.yaml
| {{- if or .Chart.AppVersion .Values.image.tag }} | ||
| app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }} | ||
| {{- $rawVersion := .Values.image.tag | default .Chart.AppVersion }} | ||
| {{- $version := regexReplaceAll "@sha256:[a-f0-9]+" $rawVersion "" | trunc 63 | trimSuffix "-" }} | ||
| app.kubernetes.io/version: {{ $version | quote }} |
There was a problem hiding this comment.
image.versionLabel override is not applied in label computation
The new override path is missing: on Line 38 the helper still derives version only from image.tag/Chart.AppVersion, so image.versionLabel cannot actually control app.kubernetes.io/version as intended.
Suggested fix
-{{- if or .Chart.AppVersion .Values.image.tag }}
-{{- $rawVersion := .Values.image.tag | default .Chart.AppVersion }}
+{{- if or .Values.image.versionLabel .Values.image.tag .Chart.AppVersion }}
+{{- $rawVersion := .Values.image.versionLabel | default (.Values.image.tag | default .Chart.AppVersion) }}
{{- $version := regexReplaceAll "`@sha256`:[a-f0-9]+" $rawVersion "" | trunc 63 | trimSuffix "-" }}
app.kubernetes.io/version: {{ $version | quote }}
{{- end }}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {{- if or .Chart.AppVersion .Values.image.tag }} | |
| app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }} | |
| {{- $rawVersion := .Values.image.tag | default .Chart.AppVersion }} | |
| {{- $version := regexReplaceAll "@sha256:[a-f0-9]+" $rawVersion "" | trunc 63 | trimSuffix "-" }} | |
| app.kubernetes.io/version: {{ $version | quote }} | |
| {{- if or .Values.image.versionLabel .Values.image.tag .Chart.AppVersion }} | |
| {{- $rawVersion := .Values.image.versionLabel | default (.Values.image.tag | default .Chart.AppVersion) }} | |
| {{- $version := regexReplaceAll "`@sha256`:[a-f0-9]+" $rawVersion "" | trunc 63 | trimSuffix "-" }} | |
| app.kubernetes.io/version: {{ $version | quote }} | |
| {{- end }} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@charts/meilisearch/templates/_helpers.tpl` around lines 37 - 40, The helper
currently computes $rawVersion only from .Values.image.tag or .Chart.AppVersion
so .Values.image.versionLabel is ignored; change the $rawVersion assignment to
prefer .Values.image.versionLabel first, falling back to .Values.image.tag then
.Chart.AppVersion (e.g. set $rawVersion := .Values.image.versionLabel | default
(.Values.image.tag | default .Chart.AppVersion)), leaving the subsequent
$version regexReplaceAll/trunc/trimSuffix and the app.kubernetes.io/version
label generation unchanged.
Labels have to be less than 63 characters, so when using a digest in the tag, which is recommended [0], the label becomes too long and the chart fails. This change strips away any digest or pinning after the tag. [0]: https://docs.docker.com/dhi/core-concepts/digests/
7098b93 to
21d3c52
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Pull Request
Related issue
NaN
What does this PR do?
Labels have to be less than 63 characters, so when using a digest in the tag, which is recommended 0, the label
becomes too long and the chart fails. This change strips away any digest or pinning after the tag.
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Overview
This PR prevents Kubernetes label failures caused by overly long image tags (e.g., when using image digests) by adding a configurable label value and sanitizing the version used in labels.
Changes
New Configuration Option
image.versionLabelto charts/meilisearch/values.yaml (defaults to empty string). Documented as intended for use when the image tag is pinned to a digest.Label Generation Logic Update
meilisearch.labels:app.kubernetes.io/versionis now emitted only when either.Chart.AppVersionor.Values.image.tagis set..Values.image.tagwith a fallback to.Chart.AppVersion, then:@sha256:...digest suffix,-,Design Rationale
Sanitizing and truncating the version keeps label values within Kubernetes' 63-character limit. The added
image.versionLabelprovides an opt-in configurable field for users, though the template currently derives the emitted version fromimage.tag→Chart.AppVersionand applies normalization to ensure label validity.