Skip to content

Commit

Permalink
Make sure to delete the cdi namespace during make cluster-clean
Browse files Browse the repository at this point in the history
Signed-off-by: David Vossel <[email protected]>
  • Loading branch information
davidvossel committed Jan 21, 2019
1 parent cb091a1 commit 1e71f46
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions cluster/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ _kubectl get vmis --all-namespaces -o=custom-columns=NAME:.metadata.name,NAMESPA
_kubectl patch vmi $name -n $namespace --type=json -p '[{ "op": "remove", "path": "/metadata/finalizers" }]'
done

# Delete Namespaces created by us.
managed_namespaces=(${namespace} ${cdi_namespace})

# Delete all traces of kubevirt
namespaces=(default ${namespace} ${cdi_namespace})
labels=("operator.kubevirt.io" "kubevirt.io" "cdi.kubevirt.io")
labels=("operator.kubevirt.io" "operator.cdi.kubevirt.io" "kubevirt.io" "cdi.kubevirt.io")

# Namespaced resources
for i in ${namespaces[@]}; do
Expand Down Expand Up @@ -94,22 +97,24 @@ for label in ${labels[@]}; do
done
done

if [ -n "$(_kubectl get ns | grep "${namespace} ")" ]; then
echo "Clean ${namespace} namespace"
_kubectl delete ns ${namespace}

start_time=0
sample=10
timeout=120
echo "Waiting for ${namespace} namespace to disappear ..."
while [ -n "$(_kubectl get ns | grep "${namespace} ")" ]; do
sleep $sample
start_time=$((current_time + sample))
if [[ $current_time -gt $timeout ]]; then
exit 1
fi
done
fi
for i in ${managed_namespaces[@]}; do
if [ -n "$(_kubectl get ns | grep "${i} ")" ]; then
echo "Clean ${i} namespace"
_kubectl delete ns ${i}

start_time=0
sample=10
timeout=120
echo "Waiting for ${i} namespace to disappear ..."
while [ -n "$(_kubectl get ns | grep "${i} ")" ]; do
sleep $sample
start_time=$((current_time + sample))
if [[ $current_time -gt $timeout ]]; then
exit 1
fi
done
fi
done

sleep 2

Expand Down

0 comments on commit 1e71f46

Please sign in to comment.