Skip to content

Commit 3ea8961

Browse files
committed
ci(e2e): add run-id label to infra resources for cleanup
Signed-off-by: Anton Yachmenev <[email protected]>
1 parent f13b3d4 commit 3ea8961

File tree

9 files changed

+41
-28
lines changed

9 files changed

+41
-28
lines changed

.github/workflows/e2e-matrix.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@ jobs:
7979
version: "latest"
8080

8181
- name: Setup d8
82-
uses: werf/trdl/actions/[email protected]
83-
with:
84-
repo: d8
85-
url: https://deckhouse.ru/downloads/deckhouse-cli-trdl/
86-
root-version: 1
87-
root-sha512: 343bd5f0d8811254e5f0b6fe292372a7b7eda08d276ff255229200f84e58a8151ab2729df3515cb11372dc3899c70df172a4e54c8a596a73d67ae790466a0491
88-
group: 0
89-
channel: stable
82+
uses: ./.github/actions/install-d8
9083

9184
- name: Install yq
9285
run: |
@@ -147,7 +140,7 @@ jobs:
147140
env:
148141
GO_VERSION: "1.24.6"
149142
TIMEOUT: 4h
150-
RUN_ID: nightly-nested-e2e-${{ matrix.storage_name }}-${{ github.run_number }}
143+
RUN_ID: ${{ needs.setup.outputs.run_id }}
151144
steps:
152145
- uses: actions/checkout@v4
153146

@@ -167,15 +160,8 @@ jobs:
167160
with:
168161
version: "latest"
169162

170-
- name: Setup d8 CLI
171-
uses: werf/trdl/actions/[email protected]
172-
with:
173-
repo: d8
174-
url: https://deckhouse.ru/downloads/deckhouse-cli-trdl/
175-
root-version: 1
176-
root-sha512: 343bd5f0d8811254e5f0b6fe2923729df3515cb11372dc3899c70df172a4e54c8a596a73d67ae790466a0491
177-
group: 0
178-
channel: stable
163+
- name: Setup d8
164+
uses: ./.github/actions/install-d8
179165

180166
- name: Install ginkgo
181167
working-directory: test/e2e
@@ -191,7 +177,7 @@ jobs:
191177
uses: actions/download-artifact@v4
192178
with:
193179
name: nested-run-${{ env.RUN_ID }}
194-
path: ci/dvp-e2e/tmp/runs
180+
path: .
195181

196182
- name: Configure kubeconfig env
197183
run: |

ci/dvp-e2e/Taskfile.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,16 +535,21 @@ tasks:
535535
echo "[CLEANUP] Prefix='{{ .PREFIX }}'"
536536
ns_list=$(kubectl get ns -o json | jq -r --arg p '{{ .PREFIX }}' '.items[].metadata.name | select(startswith($p))')
537537
if [ -z "${ns_list}" ]; then
538-
echo "[INFO] No namespaces to delete"; exit 0
538+
echo "[INFO] No namespaces to delete"
539+
else
540+
for ns in $ns_list; do
541+
echo "[CLEANUP] Deleting namespace $ns ..."
542+
kubectl delete ns "$ns" --wait=false || true
543+
done
544+
echo "[CLEANUP] Waiting for namespaces to be deleted..."
545+
for ns in $ns_list; do
546+
kubectl wait --for=delete ns/"$ns" --timeout=600s || echo "[WARN] Namespace $ns was not fully deleted within timeout"
547+
done
539548
fi
540-
for ns in $ns_list; do
541-
echo "[CLEANUP] Deleting namespace $ns ..."
542-
kubectl delete ns "$ns" --wait=false || true
543-
done
544-
echo "[CLEANUP] Waiting for namespaces to be deleted..."
545-
for ns in $ns_list; do
546-
kubectl wait --for=delete ns/"$ns" --timeout=600s || echo "[WARN] Namespace $ns was not fully deleted within timeout"
547-
done
549+
# Cleanup cluster-scoped resources for this run-id (if any)
550+
echo "[CLEANUP] Deleting cluster-scoped resources labeled with run-id='{{ .PREFIX }}'"
551+
kubectl delete virtualmachineclass -l e2e.deckhouse.io/run-id='{{ .PREFIX }}' --ignore-not-found || true
552+
kubectl delete clusterrolebinding -l e2e.deckhouse.io/run-id='{{ .PREFIX }}' --ignore-not-found || true
548553
549554
# ------------------------------------------------------------
550555
# CI helpers: kubeconfig + registry

ci/dvp-e2e/charts/infra/templates/ingress.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: Service
33
metadata:
44
name: dvp-over-dvp-443
55
namespace: {{ .Values.namespace }}
6+
labels:
7+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
68
spec:
79
ports:
810
- port: 443
@@ -20,6 +22,8 @@ metadata:
2022
annotations:
2123
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
2224
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
25+
labels:
26+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
2327
spec:
2428
ingressClassName: nginx
2529
rules:

ci/dvp-e2e/charts/infra/templates/jump-host/deploy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ kind: Deployment
44
metadata:
55
name: jump-host
66
namespace: {{ .Values.namespace }}
7+
labels:
8+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
79
spec:
810
replicas: 1
911
selector:
@@ -13,6 +15,7 @@ spec:
1315
metadata:
1416
labels:
1517
app: jump-host
18+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
1619
spec:
1720
containers:
1821
- name: jump-host

ci/dvp-e2e/charts/infra/templates/jump-host/svc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ kind: Service
44
metadata:
55
name: jump-host
66
namespace: {{ .Values.namespace }}
7+
labels:
8+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
79
spec:
810
type: NodePort
911
selector:

ci/dvp-e2e/charts/infra/templates/ns.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: {{ .Values.namespace }}
55
labels:
66
heritage: deckhouse
7+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"

ci/dvp-e2e/charts/infra/templates/rbac/rbac.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: ServiceAccount
33
metadata:
44
name: dkp-sa
55
namespace: {{ .Values.namespace }}
6+
labels:
7+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
68
---
79
apiVersion: v1
810
kind: Secret
@@ -11,13 +13,17 @@ metadata:
1113
namespace: {{ .Values.namespace }}
1214
annotations:
1315
kubernetes.io/service-account.name: dkp-sa
16+
labels:
17+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
1418
type: kubernetes.io/service-account-token
1519
---
1620
apiVersion: rbac.authorization.k8s.io/v1
1721
kind: RoleBinding
1822
metadata:
1923
name: dkp-sa-rb
2024
namespace: {{ .Values.namespace }}
25+
labels:
26+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
2127
subjects:
2228
- kind: ServiceAccount
2329
name: dkp-sa
@@ -31,6 +37,8 @@ apiVersion: rbac.authorization.k8s.io/v1
3137
kind: ClusterRoleBinding
3238
metadata:
3339
name: dkp-sa-cluster-admin-{{ .Values.namespace }}
40+
labels:
41+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
3442
subjects:
3543
- kind: ServiceAccount
3644
name: dkp-sa

ci/dvp-e2e/charts/infra/templates/vi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ kind: VirtualImage
44
metadata:
55
name: image
66
namespace: {{ .Values.namespace }}
7+
labels:
8+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
79
spec:
810
storage: ContainerRegistry
911
dataSource:

ci/dvp-e2e/charts/infra/templates/vmc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ apiVersion: virtualization.deckhouse.io/v1alpha2
22
kind: VirtualMachineClass
33
metadata:
44
name: "{{ .Values.namespace }}-cpu"
5+
labels:
6+
e2e.deckhouse.io/run-id: "{{ .Values.namespace }}"
57
spec:
68
cpu:
79
type: Discovery

0 commit comments

Comments
 (0)