From 18fdc309615f335fe16ad27ab27bb91972aac75a Mon Sep 17 00:00:00 2001 From: Kostiantyn Kalynovskyi Date: Thu, 14 Jul 2022 23:19:11 +0000 Subject: [PATCH] Create cron jobs idempotently Change-Id: Ib7d74ed3b202237027e6da9908c257e81c8cfc25 --- tools/deployment/common/force-cronjob-run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/deployment/common/force-cronjob-run.sh b/tools/deployment/common/force-cronjob-run.sh index b7f2eb69f6..ad0339a6b9 100755 --- a/tools/deployment/common/force-cronjob-run.sh +++ b/tools/deployment/common/force-cronjob-run.sh @@ -10,7 +10,8 @@ for i in ${CRONJOBS}; do # avoid scheduled runs to prevent case when our manual job is deleted by history limit. kubectl patch cj/"${CJ}" -n"${NS}" -p '{"spec" : {"suspend" : true }}' - kubectl create job -n"${NS}" --from=cj/"${CJ}" "${CJ}-${TEST_POSTFIX}" + kubectl get job -n"${NS}" "${CJ}-${TEST_POSTFIX}" || \ + kubectl create job -n"${NS}" --from=cj/"${CJ}" "${CJ}-${TEST_POSTFIX}" done echo "Waiting for all test jobs to complete."