Skip to content

Commit

Permalink
add flag to skip custom delete logic (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulait authored Feb 5, 2025
1 parent e420c9b commit d1a602d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ checkout-last-release:

.PHONY: last-release-cluster
last-release-cluster: kind ctlptl tilt kustomize clusterctl chainsaw kind-cluster checkout-last-release local-release local-deploy
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
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

.PHONY: test-upgrade
test-upgrade: last-release-cluster checkout-latest-commit
Expand Down
51 changes: 29 additions & 22 deletions e2e/capl-cluster-flavors/kubeadm-capl-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,29 @@ spec:
namespace: kube-system
- name: Delete child cluster
try:
- delete:
ref:
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: ($cluster)
- delete:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: LinodeVPC
name: ($cluster)
- delete:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: LinodeFirewall
name: ($cluster)
- delete:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: LinodeFirewall
name: ($cluster)-nb
- error:
file: check-child-cluster-vpc-and-firewall-deleted.yaml
- script:
env:
- name: CLUSTER
value: ($cluster)
- name: NAMESPACE
value: ($namespace)
- name: CLUSTERCTL_CONFIG
value: (env('CLUSTERCTL_CONFIG'))
- name: SKIP_DELETE
value: (env('SKIP_CUSTOM_DELETE'))
content: |
set -e
if [[ -n "$SKIP_DELETE" ]]; then
echo "Skipping deletion of child cluster"
exit 0
fi
kubectl delete cluster $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
kubectl delete linodevpc $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
kubectl delete linodefirewall $CLUSTER -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
kubectl delete linodefirewall $CLUSTER-nb -n $NAMESPACE --timeout=60s || { echo "deletion failed!"; exit 1; }
check:
($error == null): true
(contains($stdout, 'deletion failed')): false
- name: Check if the linodes are deleted
try:
- script:
Expand All @@ -164,8 +165,14 @@ spec:
value: linode/instances
- name: FILTER
value: (to_string({"tags":($cluster)}))
- name: SKIP_DELETE
value: (env('SKIP_CUSTOM_DELETE'))
content: |
set -e
if [[ -n "$SKIP_DELETE" ]]; then
echo {\"results\":0}
exit 0
fi
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
Expand Down

This file was deleted.

0 comments on commit d1a602d

Please sign in to comment.