From 3a55008066f8bf4ef0c1596d85edf0ed08c00315 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Thu, 4 Apr 2024 09:45:24 +0200 Subject: [PATCH] Remove a pipelinerun if cleanup is about to start --- hooks/down.sh | 7 ++++++- tpls/hetzner-k3s.yaml | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hooks/down.sh b/hooks/down.sh index 86255db..d69401f 100755 --- a/hooks/down.sh +++ b/hooks/down.sh @@ -28,7 +28,12 @@ else export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH) export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH) echo "removing the ${SP_ENVIRONMENT} owned by ${SP_CUSTOMER_ID}" - + + # -- Remove the pipelinerun, if not removed yet + kubectl delete pipelinerun -n "${SP_TEKTON_RUNTIME_NS}" \ + -l softplayer.net/user-uuid="${SP_CUSTOMER_ID}" \ + -l softplayer.net/env_name="${SP_ENVIRONMENT}" || true + envsubst < /tpls/${SP_PROVIDER}-cleanup.yaml | kubectl create -f - # -- Removing the finalizer diff --git a/tpls/hetzner-k3s.yaml b/tpls/hetzner-k3s.yaml index 4c77363..8e733f6 100644 --- a/tpls/hetzner-k3s.yaml +++ b/tpls/hetzner-k3s.yaml @@ -3,6 +3,9 @@ kind: PipelineRun metadata: generateName: hetzner-k3s namespace: "${SP_TEKTON_RUNTIME_NS}" + labels: + softplayer.net/user-uuid: "${SP_CUSTOMER_ID}" + softplayer.net/env_name: "${SP_ENVIRONMENT}" spec: params: - name: namespace