From 45a913bde7fbfccd2fff30ef007e8bd74a216ac8 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Tue, 17 Dec 2024 11:11:47 +1100 Subject: [PATCH 1/2] Don't include empty worker pools env var if not a worker --- .../templates/tentacle-deployment.yaml | 2 ++ .../tentacle-deployment_test.yaml.snap | 2 -- ...entacle-deployment-container-env-vars_test.yaml | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/charts/kubernetes-agent/templates/tentacle-deployment.yaml b/charts/kubernetes-agent/templates/tentacle-deployment.yaml index 4a2c05f0..590928db 100644 --- a/charts/kubernetes-agent/templates/tentacle-deployment.yaml +++ b/charts/kubernetes-agent/templates/tentacle-deployment.yaml @@ -72,8 +72,10 @@ spec: value: {{ .Values.agent.deploymentTarget.initial.tenantedDeploymentParticipation | quote }} - name: "WorkerEnabled" value: {{ .Values.agent.worker.enabled | quote }} + {{- if and .Values.agent.worker.initial.workerPools .Values.agent.worker.enabled }} - name: "WorkerPools" value: {{ join "," .Values.agent.worker.initial.workerPools | quote }} + {{- end }} {{- if .Values.agent.deploymentTarget.enabled }} {{include "kubernetes-agent.scriptPodEnvVars" .Values.scriptPods.deploymentTarget.image | nindent 12}} {{- else if .Values.agent.worker.enabled }} diff --git a/charts/kubernetes-agent/tests/__snapshot__/tentacle-deployment_test.yaml.snap b/charts/kubernetes-agent/tests/__snapshot__/tentacle-deployment_test.yaml.snap index a2782ed8..306e84ee 100644 --- a/charts/kubernetes-agent/tests/__snapshot__/tentacle-deployment_test.yaml.snap +++ b/charts/kubernetes-agent/tests/__snapshot__/tentacle-deployment_test.yaml.snap @@ -70,8 +70,6 @@ should match snapshot: value: Untenanted - name: WorkerEnabled value: "false" - - name: WorkerPools - value: "" - name: OCTOPUS__K8STENTACLE__NAMESPACE value: NAMESPACE - name: OCTOPUS__K8STENTACLE__PODSERVICEACCOUNTNAME diff --git a/charts/kubernetes-agent/tests/tentacle-deployment-container-env-vars_test.yaml b/charts/kubernetes-agent/tests/tentacle-deployment-container-env-vars_test.yaml index f7480f66..c6ff49d7 100644 --- a/charts/kubernetes-agent/tests/tentacle-deployment-container-env-vars_test.yaml +++ b/charts/kubernetes-agent/tests/tentacle-deployment-container-env-vars_test.yaml @@ -108,10 +108,11 @@ tests: path: spec.template.spec.containers[0].env[?(@.name == 'TargetRole')].value value: "web,admin" -- it: "Sets worker pools" +- it: "Sets worker pools if worker enabled" set: agent: worker: + enabled: true initial: workerPools: [WorkerPools-3, MyAwesomeWorkerPool] asserts: @@ -119,6 +120,17 @@ tests: path: spec.template.spec.containers[0].env[?(@.name == 'WorkerPools')].value value: "WorkerPools-3,MyAwesomeWorkerPool" +- it: "Does not set worker pools if worker disabled" + set: + agent: + worker: + enabled: false + initial: + workerPools: [WorkerPools-3, MyAwesomeWorkerPool] + asserts: + - notExists: + path: spec.template.spec.containers[0].env[?(@.name == 'WorkerPools')].value + - it: "Sets machine policy if specified" set: agent: From fde11e6f4b6f11973e714a33b208364447470bf4 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Tue, 17 Dec 2024 11:12:40 +1100 Subject: [PATCH 2/2] Add changeset --- .changeset/strong-pears-end.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/strong-pears-end.md diff --git a/.changeset/strong-pears-end.md b/.changeset/strong-pears-end.md new file mode 100644 index 00000000..34f963cc --- /dev/null +++ b/.changeset/strong-pears-end.md @@ -0,0 +1,5 @@ +--- +"kubernetes-agent": patch +--- + +Don't include an empty WorkerPools env var if not a worker