Add check and delete pvc in case pvc is not cleaned up (#12594)

Signed-off-by: Jenny Li <jing.li@zilliz.com>
This commit is contained in:
Jenny Li 2021-12-02 19:03:32 +08:00 committed by GitHub
parent b03695aa14
commit fb17e78abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}