From cf344777a80e5867a25096b72749b5dbf8275a9f Mon Sep 17 00:00:00 2001 From: Jaswanthi Kolla Date: Mon, 17 Jun 2024 11:50:03 -0400 Subject: [PATCH] [JK] DinD Graceful termination - Wait for Runner --- charts/gha-runner-scale-set/templates/_helpers.tpl | 11 +++++++++++ .../templates/autoscalingrunnerset.yaml | 3 +++ 2 files changed, 14 insertions(+) diff --git a/charts/gha-runner-scale-set/templates/_helpers.tpl b/charts/gha-runner-scale-set/templates/_helpers.tpl index bd71ed64c9..7ec87e97a8 100644 --- a/charts/gha-runner-scale-set/templates/_helpers.tpl +++ b/charts/gha-runner-scale-set/templates/_helpers.tpl @@ -113,6 +113,17 @@ volumeMounts: mountPath: /var/run - name: dind-externals mountPath: /home/runner/externals +lifecycle: + preStop: + exec: + command: + - /bin/sh + - -c + - > + while pgrep "Runner.Worker" > /dev/null; do + echo "Runner's Worker is still running, delaying termination..."; + sleep 2; + done {{- end }} {{- define "gha-runner-scale-set.dind-volume" -}} diff --git a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml index 39ebfef800..55a3ab53b7 100644 --- a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml +++ b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml @@ -116,6 +116,9 @@ spec: restartPolicy: Never {{- end }} {{- $containerMode := .Values.containerMode }} + {{- if eq $containerMode.type "dind" }} + shareProcessNamespace: true + {{- end }} {{- if eq $containerMode.type "kubernetes" }} serviceAccountName: {{ default (include "gha-runner-scale-set.kubeModeServiceAccountName" .) .Values.template.spec.serviceAccountName }} {{- else }}