From 1f25dcf69c134e422419b65d514329e1b7a7d405 Mon Sep 17 00:00:00 2001 From: danc094codetogether Date: Tue, 20 Oct 2026 21:04:21 +0000 Subject: [PATCH] AITRAX-2721: codetogether-ai chart 0.2.2 - keep helm upgrade --reuse-values working `helm upgrade --reuse-values` from a release whose chart predates `gateway` (0.1.0) keeps the old values and skips the new defaults, so `.Values.gateway.enabled` was a nil pointer and the upgrade failed, even for an image-only bump. Templates now read `gateway` through `default dict` and the ClientSettingsPolicy body size falls back to 16m. CI renders with `--set gateway=null` to keep it so. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/helm-template-check.yml | 7 +++++++ charts/ai/Chart.yaml | 2 +- charts/ai/templates/NOTES.txt | 9 +++++---- charts/ai/templates/_helpers.tpl | 12 ++++++++++-- charts/ai/templates/clientsettingspolicy.yaml | 2 +- charts/ai/templates/httproute.yaml | 11 ++++++----- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/helm-template-check.yml b/.github/workflows/helm-template-check.yml index e8cc1ca..b83701a 100644 --- a/.github/workflows/helm-template-check.yml +++ b/.github/workflows/helm-template-check.yml @@ -51,6 +51,13 @@ jobs: --set 'gateway.parentRefs[0].namespace=gateway-system' \ --api-versions gateway.networking.k8s.io/v1/HTTPRoute \ --api-versions gateway.nginx.org/v1alpha1/ClientSettingsPolicy + # helm upgrade --reuse-values from a chart without `gateway` drops the key + helm template test ./charts/ai \ + --set-file ctaiPropertiesFile=./charts/ai/ctai-configuration.properties.template \ + --set service.fqdn=https://example.codetogether.io \ + --set imageCredentials.username=test \ + --set imageCredentials.password=test \ + --set gateway=null - name: Validate Live Chart run: | diff --git a/charts/ai/Chart.yaml b/charts/ai/Chart.yaml index cfeb224..1aff94b 100644 --- a/charts/ai/Chart.yaml +++ b/charts/ai/Chart.yaml @@ -3,7 +3,7 @@ name: codetogether-ai description: CodeTogether AI on-premises Kubernetes deployment type: application -version: 0.2.1 +version: 0.2.2 appVersion: "1.2.8165" icon: https://www.codetogether.com/wp-content/uploads/2020/02/codetogether-circle-128.png diff --git a/charts/ai/templates/NOTES.txt b/charts/ai/templates/NOTES.txt index 03371c9..dd67c9e 100644 --- a/charts/ai/templates/NOTES.txt +++ b/charts/ai/templates/NOTES.txt @@ -1,5 +1,6 @@ Application URL: -{{- if or .Values.ingress.enabled .Values.gateway.enabled }} +{{- $gw := .Values.gateway | default dict }} +{{- if or .Values.ingress.enabled $gw.enabled }} https://{{ include "ctai.publicHost" . }}/ {{- else }} Use: kubectl port-forward svc/{{ include "ctai.fullname" . }} 1080:{{ .Values.service.port }} @@ -34,11 +35,11 @@ Protected storage master key: {{- end }} {{- end }} -{{- if .Values.gateway.enabled }} +{{- if $gw.enabled }} Gateway API: {{- $parents := list }} - {{- range .Values.gateway.parentRefs }} + {{- range $gw.parentRefs }} {{- $p := .name }} {{- with .namespace }}{{ $p = printf "%s (namespace %s)" $p . }}{{ end }} {{- with .sectionName }}{{ $p = printf "%s listener %s" $p . }}{{ end }} @@ -47,7 +48,7 @@ Gateway API: HTTPRoute {{ include "ctai.fullname" . }} attaches to: {{ join ", " $parents }} Check it was accepted: kubectl get httproute {{ include "ctai.fullname" . }} -n {{ .Release.Namespace }} -o jsonpath='{.status.parents[*].conditions}' {{- if eq (include "ctai.renderClientSettingsPolicy" .) "true" }} - Request body limit: ClientSettingsPolicy {{ include "ctai.fullname" . }} ({{ .Values.gateway.nginxGatewayFabric.clientSettingsPolicy.bodyMaxSize }}). + Request body limit: ClientSettingsPolicy {{ include "ctai.fullname" . }} ({{ include "ctai.clientSettingsBodyMaxSize" . }}). {{- else }} WARNING: no request body limit was rendered for the Gateway. OTLP uploads over the gateway's default (1MB on NGINX Gateway Fabric) will fail with 413. Set the diff --git a/charts/ai/templates/_helpers.tpl b/charts/ai/templates/_helpers.tpl index 7422a00..4c2dde4 100644 --- a/charts/ai/templates/_helpers.tpl +++ b/charts/ai/templates/_helpers.tpl @@ -280,8 +280,8 @@ the chart doesn't render a duplicate. Whether to render the NGINX Gateway Fabric ClientSettingsPolicy: "true" or "". */}} {{- define "ctai.renderClientSettingsPolicy" -}} -{{- if .Values.gateway.enabled -}} -{{- $mode := toString ((.Values.gateway.nginxGatewayFabric | default dict).clientSettingsPolicy | default dict).enabled -}} +{{- if (.Values.gateway | default dict).enabled -}} +{{- $mode := toString (((.Values.gateway | default dict).nginxGatewayFabric | default dict).clientSettingsPolicy | default dict).enabled -}} {{- if eq $mode "true" -}} true {{- else if and (eq $mode "auto") (.Capabilities.APIVersions.Has "gateway.nginx.org/v1alpha1/ClientSettingsPolicy") -}} @@ -289,3 +289,11 @@ true {{- end -}} {{- end -}} {{- end }} + +{{/* +ClientSettingsPolicy body limit. Read defensively: a `helm upgrade --reuse-values` +from a chart without `gateway` keeps the old values and skips these defaults. +*/}} +{{- define "ctai.clientSettingsBodyMaxSize" -}} +{{- (((.Values.gateway | default dict).nginxGatewayFabric | default dict).clientSettingsPolicy | default dict).bodyMaxSize | default "16m" -}} +{{- end }} diff --git a/charts/ai/templates/clientsettingspolicy.yaml b/charts/ai/templates/clientsettingspolicy.yaml index 08f9e54..440d80b 100644 --- a/charts/ai/templates/clientsettingspolicy.yaml +++ b/charts/ai/templates/clientsettingspolicy.yaml @@ -14,5 +14,5 @@ spec: kind: HTTPRoute name: {{ $fullName }} body: - maxSize: {{ .Values.gateway.nginxGatewayFabric.clientSettingsPolicy.bodyMaxSize | quote }} + maxSize: {{ include "ctai.clientSettingsBodyMaxSize" . | quote }} {{- end }} diff --git a/charts/ai/templates/httproute.yaml b/charts/ai/templates/httproute.yaml index af005aa..e8232a5 100644 --- a/charts/ai/templates/httproute.yaml +++ b/charts/ai/templates/httproute.yaml @@ -1,5 +1,6 @@ -{{- if .Values.gateway.enabled }} -{{- if not .Values.gateway.parentRefs }} +{{- $gw := .Values.gateway | default dict }} +{{- if $gw.enabled }} +{{- if not $gw.parentRefs }} {{- fail "gateway.enabled=true requires gateway.parentRefs: the Gateway (name, and namespace/sectionName if needed) the HTTPRoute attaches to." }} {{- end }} {{- if not (.Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/HTTPRoute") }} @@ -12,16 +13,16 @@ metadata: name: {{ $fullName }} labels: {{- include "ctai.labels" . | nindent 4 }} - {{- with .Values.gateway.labels }} + {{- with $gw.labels }} {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.gateway.annotations }} + {{- with $gw.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: parentRefs: - {{- toYaml .Values.gateway.parentRefs | nindent 4 }} + {{- toYaml $gw.parentRefs | nindent 4 }} hostnames: - {{ include "ctai.routeHostname" . | quote }} rules: