Make sure to delete the cdi namespace during make cluster-clean
@@ -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
@@ -94,15 +97,16 @@ for label in ${labels[@]}; do
done
done
-if [ -n "$(_kubectl get ns | grep "${namespace} ")" ]; then
- echo "Clean ${namespace} namespace"
- _kubectl delete ns ${namespace}
+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 ${namespace} namespace to disappear ..."
- while [ -n "$(_kubectl get ns | grep "${namespace} ")" ]; do
+ 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
@@ -110,6 +114,7 @@ if [ -n "$(_kubectl get ns | grep "${namespace} ")" ]; then
fi
done
fi
+done
sleep 2
