From 671c7d574460ebf0bbb3c0b1ebf60223c5f35e68 Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Tue, 21 Nov 2023 09:27:36 +1100 Subject: [PATCH 1/2] Unset pre-stop hook for bamboo agent --- src/main/charts/bamboo-agent/README.md | 2 +- .../bamboo-agent/templates/deployment-agent.yaml | 3 ++- src/main/charts/bamboo-agent/values.yaml | 11 +++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/charts/bamboo-agent/README.md b/src/main/charts/bamboo-agent/README.md index e3f884971..0cb9a4945 100644 --- a/src/main/charts/bamboo-agent/README.md +++ b/src/main/charts/bamboo-agent/README.md @@ -46,7 +46,7 @@ Kubernetes: `>=1.21.x-0` | agent.securityToken.secretKey | string | `"security-token"` | | | agent.securityToken.secretName | string | `nil` | The name of the K8s Secret that contains the security token. When specified the token will be automatically utilised on agent boot. An Example of creating a K8s secret for the secret below: 'kubectl create secret generic --from-literal=security-token=' https://kubernetes.io/docs/concepts/configuration/secret/#opaque-secrets | | agent.server | string | `nil` | | -| agent.shutdown.command | string | `"/shutdown-wait.sh"` | By default pods will be stopped via a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/), using a script supplied by the Docker image. If any other shutdown behaviour is needed it can be achieved by overriding this value. Note that the shutdown command needs to wait for the application shutdown completely before exiting; see [the default command](https://bitbucket.org/atlassian-docker/docker-bamboo-agent-base/src/master/shutdown-wait.sh) for details. | +| agent.shutdown.command | string | `nil` | Custom command for a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/). Undefined by default which means no pre-stop hook is being executed when an agent container needs to be stopped and deleted | | agent.shutdown.terminationGracePeriodSeconds | int | `30` | The termination grace period for pods during shutdown. This should be set to the internal grace period, plus a small buffer to allow the JVM to fully terminate. | | agent.startupProbe.command | string | `"/probe-startup.sh"` | Command to use to check the startup status. This is provided by the agent image. | | agent.startupProbe.failureThreshold | int | `120` | The number of consecutive failures of the Bamboo agent container startup probe before the pod fails readiness checks. | diff --git a/src/main/charts/bamboo-agent/templates/deployment-agent.yaml b/src/main/charts/bamboo-agent/templates/deployment-agent.yaml index bd429c075..e11a227fd 100644 --- a/src/main/charts/bamboo-agent/templates/deployment-agent.yaml +++ b/src/main/charts/bamboo-agent/templates/deployment-agent.yaml @@ -94,11 +94,12 @@ spec: ports: {{- include "agent.additionalPorts" . | nindent 12 }} {{- end }} - + {{- if .Values.agent.shutdown.command }} lifecycle: preStop: exec: command: ["sh", "-c", {{ .Values.agent.shutdown.command | quote }}] + {{- end }} {{- include "agent.additionalContainers" . | nindent 8 }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/src/main/charts/bamboo-agent/values.yaml b/src/main/charts/bamboo-agent/values.yaml index 7127bbdfa..d29837053 100644 --- a/src/main/charts/bamboo-agent/values.yaml +++ b/src/main/charts/bamboo-agent/values.yaml @@ -167,15 +167,10 @@ agent: # terminationGracePeriodSeconds: 30 - # -- By default pods will be stopped via a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/), - # using a script supplied by the Docker image. If any other - # shutdown behaviour is needed it can be achieved by overriding - # this value. Note that the shutdown command needs to wait for the - # application shutdown completely before exiting; see [the default - # command](https://bitbucket.org/atlassian-docker/docker-bamboo-agent-base/src/master/shutdown-wait.sh) - # for details. + # -- Custom command for a [preStop hook](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/). + # Undefined by default which means no pre-stop hook is being executed when an agent container needs to be stopped and deleted # - command: "/shutdown-wait.sh" + command: # Pod resource requests # From 4544115e5224cc3576e7301e38ca22cc0e3548b6 Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Tue, 21 Nov 2023 09:31:21 +1100 Subject: [PATCH 2/2] Fix unit tests --- .../resources/expected_helm_output/bamboo-agent/output.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/resources/expected_helm_output/bamboo-agent/output.yaml b/src/test/resources/expected_helm_output/bamboo-agent/output.yaml index c42b81e58..81fa9ceae 100644 --- a/src/test/resources/expected_helm_output/bamboo-agent/output.yaml +++ b/src/test/resources/expected_helm_output/bamboo-agent/output.yaml @@ -95,9 +95,5 @@ spec: cpu: "1" memory: 2G volumeMounts: - lifecycle: - preStop: - exec: - command: ["sh", "-c", "/shutdown-wait.sh"] priorityClassName: high volumes: