From 651bb83f43b4de263b0cbdb26c7c1b4d95b61b09 Mon Sep 17 00:00:00 2001 From: Shuang Men Date: Thu, 7 Jan 2021 15:46:44 +0800 Subject: [PATCH] add pre-check on scheduler statefulset before patch it --- .../pre-upgrade/remove-deployment-updater-readiness.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chart/hooks/pre-upgrade/remove-deployment-updater-readiness.sh b/chart/hooks/pre-upgrade/remove-deployment-updater-readiness.sh index 822d8bdfcb..9999b2571a 100644 --- a/chart/hooks/pre-upgrade/remove-deployment-updater-readiness.sh +++ b/chart/hooks/pre-upgrade/remove-deployment-updater-readiness.sh @@ -30,8 +30,13 @@ if [ "${scheduler_list}" == "" ]; then exit 0 fi +query='{.spec.template.spec.containers[*].name}' + for scheduler in ${scheduler_list}; do - kubectl patch statefulset --namespace "$NAMESPACE" "${scheduler}" --patch "$patch" + probe="$(kubectl get statefulsets --namespace="${NAMESPACE}" "${scheduler}" --output=jsonpath="${query}")" + if [[ "${probe}" =~ "cc-deployment-updater-cc-deployment-updater" ]]; then + kubectl patch statefulset --namespace "$NAMESPACE" "${scheduler}" --patch "$patch" + fi done # Delete all existing scheduler pods; we can't just patch them as changing