From 8ce46701042489ab1f60e798e39e4081a493ad6e Mon Sep 17 00:00:00 2001 From: Derrick Austin Date: Tue, 11 Aug 2026 12:35:14 -0500 Subject: [PATCH] fix(curator): make the prod resource sizing branch reachable curator.resources compared environment to "production", but values.schema.json restricts environment to dev, qa, or prod, so the comparison could never be true and a prod release with no explicit resources fell through to the 500m/512Mi block. Compare against "prod" and add deployment tests pinning both sizing branches plus the override path, so the schema enum and the template can't drift apart again unnoticed. --- charts/curator/templates/_helpers.tpl | 7 ++- charts/curator/tests/deployment_test.yaml | 59 +++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/charts/curator/templates/_helpers.tpl b/charts/curator/templates/_helpers.tpl index 6aeee85..a04fff5 100644 --- a/charts/curator/templates/_helpers.tpl +++ b/charts/curator/templates/_helpers.tpl @@ -111,13 +111,16 @@ storageClassName: {{ $storageClass | quote }} {{- end -}} {{/* -Create the resource blocks based on environment sizing or allow for overrides +Create the resource blocks based on environment sizing or allow for overrides. +The environment values compared here must stay in sync with the `environment` +enum in values.schema.json (dev, qa, prod) -- a comparison against a value the +schema rejects makes the branch unreachable. */}} {{- define "curator.resources" -}} {{- if .Values.resources -}} {{- toYaml .Values.resources -}} {{- else -}} -{{- if eq .Values.environment "production" -}} +{{- if eq .Values.environment "prod" -}} requests: cpu: 1 memory: 1Gi diff --git a/charts/curator/tests/deployment_test.yaml b/charts/curator/tests/deployment_test.yaml index d3c9496..2d38202 100644 --- a/charts/curator/tests/deployment_test.yaml +++ b/charts/curator/tests/deployment_test.yaml @@ -52,3 +52,62 @@ tests: asserts: - notExists: path: spec.replicas + + # The sizing branches key off `environment`, whose allowed values come from + # values.schema.json (dev, qa, prod). These pin that agreement: a branch + # comparing against a value the schema rejects is unreachable and silently + # falls through to the small block. + - it: uses the production sizing when environment is prod and resources is unset + set: + image.tag: latest + environment: prod + asserts: + - equal: + path: spec.template.spec.containers[0].resources.requests.cpu + value: 1 + - equal: + path: spec.template.spec.containers[0].resources.requests.memory + value: 1Gi + - equal: + path: spec.template.spec.containers[0].resources.limits.cpu + value: 1500m + - equal: + path: spec.template.spec.containers[0].resources.limits.memory + value: 2Gi + + - it: uses the small sizing for non-prod environments + set: + image.tag: latest + environment: dev + asserts: + - equal: + path: spec.template.spec.containers[0].resources.requests.cpu + value: 500m + - equal: + path: spec.template.spec.containers[0].resources.requests.memory + value: 512Mi + - equal: + path: spec.template.spec.containers[0].resources.limits.cpu + value: 500m + - equal: + path: spec.template.spec.containers[0].resources.limits.memory + value: 512Mi + + - it: prefers an explicit resources override over the environment sizing + set: + image.tag: latest + environment: prod + resources: + requests: + cpu: 250m + memory: 256Mi + limits: + cpu: 3.5 + memory: 1Gi + asserts: + - equal: + path: spec.template.spec.containers[0].resources.requests.cpu + value: 250m + - equal: + path: spec.template.spec.containers[0].resources.limits.cpu + value: 3.5