mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix(helm): truncate the helm.sh/chart label to 63 bytes
Kubernetes caps a label value at 63 bytes and .Chart.Version is unbounded. CI
publishes branch builds as 0.0.0-branch-<branch>-<sha>, so helm.sh/chart
rendered as a 64 byte value and the API server rejected every labeled resource
with "must be no more than 63 bytes", including the migrations Job. The
litellm-helm chart already guards this through a litellm.chart helper; this
adds the same helper here.
Swept the rest of the chart for label and name values built from unbounded
input. .Chart.Version appeared only in this label. The remaining candidates all
derive from .Release.Name, which helm itself caps at 53 characters, so they
cannot overflow; three of them are selector labels feeding immutable Deployment
matchLabels, where adding trunc would risk churn for no gain. They are left
alone deliberately.
Verified with a new helm-unittest suite, tests/chart_label_tests.yaml, which
overrides chart.version per test:
helm unittest -f 'tests/*.yaml' helm/litellm # 13 passed
helm unittest -f 'tests/*.yaml' helm/litellm-helm # 54 passed
The truncation cases fail against the previous helper. Reproduced the original
overflow by rendering with the real branch version and measuring the label:
helm template rel helm/litellm -f helm/litellm/tests/values/required.yaml \
| grep helm.sh/chart # 64 bytes before, 63 after
This commit is contained in:
parent
f0b217f2c2
commit
4f7f706a63
2 changed files with 70 additions and 1 deletions
|
|
@ -27,11 +27,20 @@ Common naming + label helpers shared by gateway, backend, and ui templates.
|
|||
{{- printf "%s-ui" (include "litellm.fullname" .) | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Chart label. Kubernetes caps a label value at 63 bytes, and .Chart.Version is
|
||||
unbounded: CI branch builds version charts as 0.0.0-branch-<branch>-<sha>, which
|
||||
overflows and makes the API server reject every labeled resource.
|
||||
*/}}
|
||||
{{- define "litellm.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "litellm.commonLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "litellm.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
|
||||
helm.sh/chart: {{ include "litellm.chart" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
|
|
|
|||
60
helm/litellm/tests/chart_label_tests.yaml
Normal file
60
helm/litellm/tests/chart_label_tests.yaml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
suite: test helm.sh/chart label stays within the 63 byte kubernetes limit
|
||||
templates:
|
||||
- gateway/deployment.yaml
|
||||
- gateway/configmap.yaml
|
||||
- backend/deployment.yaml
|
||||
- ui/deployment.yaml
|
||||
- migrations-job.yaml
|
||||
values:
|
||||
- ./values/required.yaml
|
||||
tests:
|
||||
- it: renders the plain chart label for a normal semver version
|
||||
template: gateway/deployment.yaml
|
||||
chart:
|
||||
version: 0.1.0
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
value: litellm-0.1.0
|
||||
|
||||
# CI publishes branch builds as 0.0.0-branch-<branch>-<sha>. Untruncated, the
|
||||
# label is 64 bytes and the API server rejects every labeled resource with
|
||||
# "must be no more than 63 bytes", which wedges the whole release.
|
||||
- it: truncates a long branch-build version to 63 bytes on the gateway
|
||||
template: gateway/deployment.yaml
|
||||
chart:
|
||||
version: 0.0.0-branch-litellm-enterprise-request-metering-f0b217f
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
value: litellm-0.0.0-branch-litellm-enterprise-request-metering-f0b217
|
||||
|
||||
- it: truncates the long version on the migrations job that blocked the sync
|
||||
template: migrations-job.yaml
|
||||
chart:
|
||||
version: 0.0.0-branch-litellm-enterprise-request-metering-f0b217f
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
value: litellm-0.0.0-branch-litellm-enterprise-request-metering-f0b217
|
||||
|
||||
- it: truncates the long version on backend and ui
|
||||
templates:
|
||||
- backend/deployment.yaml
|
||||
- ui/deployment.yaml
|
||||
chart:
|
||||
version: 0.0.0-branch-litellm-enterprise-request-metering-f0b217f
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
value: litellm-0.0.0-branch-litellm-enterprise-request-metering-f0b217
|
||||
|
||||
# trunc can land on the separator; a label value may not end in a dash.
|
||||
- it: never leaves a trailing dash after truncation
|
||||
template: gateway/deployment.yaml
|
||||
chart:
|
||||
version: 0.0.0-branch-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbb
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: metadata.labels["helm.sh/chart"]
|
||||
pattern: "[^-]$"
|
||||
Loading…
Add table
Reference in a new issue