Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 8552009

Browse files
Merge pull request #168 from wallrj/157-delete-namespace-now
Automatic merge from submit-queue. Delete namespaces immediately, without waiting for pods to stop * Use `kubectl delete --now` to ensure fast deletion of namespaces between tests. Fixes: #157 **Release note**: ```release-note NOW ```
2 parents 2c02864 + 33ecca1 commit 8552009

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

hack/libe2e.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,30 @@ function retry() {
4747

4848
function kube_delete_namespace_and_wait() {
4949
local namespace=$1
50+
# Delete all the resources in the namespace
51+
# This is a work around for Kubernetes 1.7 which doesn't support garbage
52+
# collection of resources owned by third party resources.
53+
# See https://github.com/kubernetes/kubernetes/issues/44507
54+
if ! retry kubectl --namespace "${namespace}" \
55+
delete \
56+
services,serviceaccounts,roles,rolebindings,statefulsets,pods \
57+
--now \
58+
--all
59+
then
60+
# If multiple attempts to delete resources fails, display the remaining
61+
# resources.
62+
kubectl cluster-info dump --namespaces "${namespace}" || true
63+
return 1
64+
fi
5065
# Delete any previous namespace and wait for Kubernetes to finish deleting.
51-
kubectl delete namespace "${namespace}" || true
52-
retry TIMEOUT=300 not kubectl get namespace ${namespace}
66+
kubectl delete --now namespace "${namespace}" || true
67+
if ! retry TIMEOUT=300 not kubectl get namespace ${namespace}; then
68+
# If the namespace doesn't delete in time, display the remaining
69+
# resources.
70+
kubectl cluster-info dump --namespaces "${namespace}" || true
71+
return 1
72+
fi
73+
return 0
5374
}
5475

5576
function kube_event_exists() {

0 commit comments

Comments
 (0)