Skip to content

Commit d1a602d

Browse files
authored
add flag to skip custom delete logic (#649)
1 parent e420c9b commit d1a602d

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ checkout-last-release:
184184

185185
.PHONY: last-release-cluster
186186
last-release-cluster: kind ctlptl tilt kustomize clusterctl chainsaw kind-cluster checkout-last-release local-release local-deploy
187-
GIT_REF=$(COMMON_CLUSTER_REF) LOCALBIN=$(CACHE_BIN) CLUSTERCTL_CONFIG=$(CLUSTERCTL_CONFIG) $(CHAINSAW) test --namespace $(COMMON_NAMESPACE) --assert-timeout 600s --skip-delete ./e2e/capl-cluster-flavors/kubeadm-capl-cluster
187+
GIT_REF=$(COMMON_CLUSTER_REF) LOCALBIN=$(CACHE_BIN) CLUSTERCTL_CONFIG=$(CLUSTERCTL_CONFIG) SKIP_CUSTOM_DELETE=true $(CHAINSAW) test --namespace $(COMMON_NAMESPACE) --assert-timeout 600s --skip-delete ./e2e/capl-cluster-flavors/kubeadm-capl-cluster
188188

189189
.PHONY: test-upgrade
190190
test-upgrade: last-release-cluster checkout-latest-commit

e2e/capl-cluster-flavors/kubeadm-capl-cluster/chainsaw-test.yaml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,28 +130,29 @@ spec:
130130
namespace: kube-system
131131
- name: Delete child cluster
132132
try:
133-
- delete:
134-
ref:
135-
apiVersion: cluster.x-k8s.io/v1beta1
136-
kind: Cluster
137-
name: ($cluster)
138-
- delete:
139-
ref:
140-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
141-
kind: LinodeVPC
142-
name: ($cluster)
143-
- delete:
144-
ref:
145-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
146-
kind: LinodeFirewall
147-
name: ($cluster)
148-
- delete:
149-
ref:
150-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
151-
kind: LinodeFirewall
152-
name: ($cluster)-nb
153-
- error:
154-
file: check-child-cluster-vpc-and-firewall-deleted.yaml
133+
- script:
134+
env:
135+
- name: CLUSTER
136+
value: ($cluster)
137+
- name: NAMESPACE
138+
value: ($namespace)
139+
- name: CLUSTERCTL_CONFIG
140+
value: (env('CLUSTERCTL_CONFIG'))
141+
- name: SKIP_DELETE
142+
value: (env('SKIP_CUSTOM_DELETE'))
143+
content: |
144+
set -e
145+
if [[ -n "$SKIP_DELETE" ]]; then
146+
echo "Skipping deletion of child cluster"
147+
exit 0
148+
fi
149+
kubectl delete cluster $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
150+
kubectl delete linodevpc $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
151+
kubectl delete linodefirewall $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
152+
kubectl delete linodefirewall $CLUSTER-nb -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
153+
check:
154+
($error == null): true
155+
(contains($stdout, 'deletion failed')): false
155156
- name: Check if the linodes are deleted
156157
try:
157158
- script:
@@ -164,8 +165,14 @@ spec:
164165
value: linode/instances
165166
- name: FILTER
166167
value: (to_string({"tags":($cluster)}))
168+
- name: SKIP_DELETE
169+
value: (env('SKIP_CUSTOM_DELETE'))
167170
content: |
168171
set -e
172+
if [[ -n "$SKIP_DELETE" ]]; then
173+
echo {\"results\":0}
174+
exit 0
175+
fi
169176
curl -s \
170177
-H "Authorization: Bearer $LINODE_TOKEN" \
171178
-H "X-Filter: $FILTER" \

e2e/capl-cluster-flavors/kubeadm-capl-cluster/check-child-cluster-vpc-and-firewall-deleted.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)