From 2b19197e2fa09a04490c78aa0f55ba62dbfcab23 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Tue, 10 Aug 2021 18:11:27 +0530 Subject: [PATCH] ci: modify kubectl_retry() to handle NotFound on delete cmd Signed-off-by: Rakshith R --- scripts/utils.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/utils.sh b/scripts/utils.sh index afcae9eb3..a7605b7c3 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -25,6 +25,18 @@ kubectl_retry() { fi fi + # in case of a failure when running "delete", ignore errors with "NotFound" + if [ "${action}" == 'delete' ] + then + # count lines in stderr that do not have "NotFound" + ret=$(grep -cvw 'NotFound' "${stderr}") + if [ "${ret}" -eq 0 ] + then + # Success! stderr is empty after removing all "NotFound" lines. + break + fi + fi + retries=$((retries+1)) if [ ${retries} -eq ${KUBECTL_RETRY} ] then