diff --git a/tests/scripts/uninstall_milvus.sh b/tests/scripts/uninstall_milvus.sh index c17d4098c1..9316ce72df 100755 --- a/tests/scripts/uninstall_milvus.sh +++ b/tests/scripts/uninstall_milvus.sh @@ -66,3 +66,26 @@ MILVUS_LABELS2="release=${MILVUS_HELM_RELEASE_NAME}" # Clean up pvc kubectl delete pvc -n "${MILVUS_HELM_NAMESPACE}" $(kubectl get pvc -n "${MILVUS_HELM_NAMESPACE}" -l "${MILVUS_LABELS1}" -o jsonpath='{range.items[*]}{.metadata.name} ') || true kubectl delete pvc -n "${MILVUS_HELM_NAMESPACE}" $(kubectl get pvc -n "${MILVUS_HELM_NAMESPACE}" -l "${MILVUS_LABELS2}" -o jsonpath='{range.items[*]}{.metadata.name} ') || true + +# Add check & delete pvc again in case pvc need time to be deleted +clean_label_pvc(){ + local label=${1?label expected as first argument.} + + for i in {1..10} + do + PVC=$(kubectl get pvc -n "${MILVUS_HELM_NAMESPACE}" -l "${label}" -o jsonpath='{range.items[*]}{.metadata.name} ') + STATUS=$(echo ${PVC} | wc -w ) + echo "status is ${STATUS}" + if [ $STATUS == 0 ]; then + break + else + sleep 5 + echo "PVCs are ${PVC}" + kubectl delete pvc -n "${MILVUS_HELM_NAMESPACE}" ${PVC} + fi + done +} + +echo "Check & Delete Persistent Volumes" +clean_label_pvc ${MILVUS_LABELS1} +clean_label_pvc ${MILVUS_LABELS2} \ No newline at end of file