@@ -175,21 +175,18 @@ steps:
175175 SLEEP_SECONDS_BETWEEN_ATTEMPTS=5
176176 # total = 10 minutes wait time
177177
178- EXPECTED_TAG="${LATEST_TAG}-ubi8"
179178 # Periodically poll if the snyk-monitor has upgraded
180179 for (( attempt=1; attempt<ATTEMPTS; attempt++))
181180 do
182- # Grab the tag of the snyk-monitor container image.
183- SNYK_MONITOR_POD=$(kubectl get pods -n snyk-monitor --no-headers | grep "snyk-monitor")
184- if [[ ! -z "${SNYK_MONITOR_POD}" ]]; then
185- VERSION=$(echo "${SNYK_MONITOR_POD}" | \
186- awk 'END { print $1 }' | \
181+ # Grab the tag of the snyk-monitor container image. If snyk-monitor is not deployed for some reason, we exit immediately.
182+ VERSION=$(kubectl get pods -n snyk-monitor --no-headers | \
183+ grep "snyk-monitor" | \
184+ awk 'END { if (NR==0) exit 1; else print $1 }' | \
187185 xargs '-I{}' kubectl get pod '{}' -n snyk-monitor -o 'jsonpath={..containers[*].image}' | \
188- grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
189- fi
186+ awk '{print $1}' | grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
190187
191188 # Break out of the polling if the tag matches the one we want to upgrade to.
192- if [[ "${VERSION}" == "${EXPECTED_TAG }" ]]; then
189+ if [[ "${VERSION}" == "${LATEST_TAG }" ]]; then
193190 break
194191 fi
195192
@@ -202,8 +199,8 @@ steps:
202199 awk 'END { if (NR==0) exit 101; else print $1 }')
203200
204201 # If we polled for 5 minutes and the snyk-monitor still hasn't upgraded, fail the current job.
205- if [[ "${VERSION}" != "${EXPECTED_TAG }" ]]; then
206- &>2 echo "versions (${VERSION}) does not match expected (${EXPECTED_TAG })!"
202+ if [[ "${VERSION}" != "${LATEST_TAG }" ]]; then
203+ &>2 echo "versions (${VERSION}) does not match expected (${LATEST_TAG })!"
207204
208205 kubectl describe pod ${SNYK_MONITOR_POD} -n snyk-monitor
209206 kubectl describe catalogsource snyk-operator -n openshift-marketplace
0 commit comments