Skip to content

Commit

Permalink
Delete namespaces immediately, without waiting for pods to stop
Browse files Browse the repository at this point in the history
* Use `kubectl delete --now` to ensure fast deletion of namespaces between tests.

Fixes: jetstack#157
  • Loading branch information
wallrj committed Dec 1, 2017
1 parent 61acfee commit 62b6edc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions hack/libe2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,23 @@ function retry() {

function kube_delete_namespace_and_wait() {
local namespace=$1
# Delete all the resources in the namespace
# This is a work around for Kubernetes 1.7 which doesn't support garbage
# collection of resources owned by third party resources.
# See https://github.com/kubernetes/kubernetes/issues/44507
kubectl --namespace "${namespace}" \
delete \
services,serviceaccounts,roles,rolebindings,statefulsets,pods \
--all || true
# Delete any previous namespace and wait for Kubernetes to finish deleting.
kubectl delete namespace "${namespace}" || true
retry TIMEOUT=300 not kubectl get namespace ${namespace}
kubectl delete --now namespace "${namespace}" || true
if ! retry TIMEOUT=300 not kubectl get namespace ${namespace}; then
# If the namespace doesn't delete in time, display the remaining
# resources.
kubectl cluster-info dump --namespaces "${namespace}" || true
return 1
fi
return 0
}

function kube_event_exists() {
Expand Down

0 comments on commit 62b6edc

Please sign in to comment.