File tree Expand file tree Collapse file tree
internal/controllers/remediation/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,6 +205,25 @@ while true; do
205205 fi
206206 isComplete=$( kubectl get job " $JOB_NAME " -n " $NAMESPACE " -o jsonpath=' {.status.conditions[?(@.type=="Complete")].status}' )
207207 isFailure=$( kubectl get job " $JOB_NAME " -n " $NAMESPACE " -o jsonpath=' {.status.conditions[?(@.type=="Failed")].status}' )
208+
209+ # Check for ImagePullBackOff or ErrImagePull in pod status
210+ podStatus=$( kubectl get pods -n " $NAMESPACE " -l " job-name=$JOB_NAME " -o jsonpath=' {.items[*].status.containerStatuses[*].state.waiting.reason}' 2> /dev/null || true)
211+ initContainerStatus=$( kubectl get pods -n " $NAMESPACE " -l " job-name=$JOB_NAME " -o jsonpath=' {.items[*].status.initContainerStatuses[*].state.waiting.reason}' 2> /dev/null || true)
212+
213+ if [[ " $podStatus " == * " ImagePullBackOff" * ]] || [[ " $podStatus " == * " ErrImagePull" * ]]; then
214+ echo " Error: Image pull failure detected in container."
215+ kubectl describe pods -n " $NAMESPACE " -l " job-name=$JOB_NAME " || true
216+ kubectl logs -n $NAMESPACE job/$JOB_NAME 2> /dev/null || true
217+ exit 1
218+ fi
219+
220+ if [[ " $initContainerStatus " == * " ImagePullBackOff" * ]] || [[ " $initContainerStatus " == * " ErrImagePull" * ]]; then
221+ echo " Error: Image pull failure detected in init container."
222+ kubectl describe pods -n " $NAMESPACE " -l " job-name=$JOB_NAME " || true
223+ kubectl logs -n $NAMESPACE job/$JOB_NAME 2> /dev/null || true
224+ exit 1
225+ fi
226+
208227 if [ " $isComplete " = " True" ]; then
209228 echo " Test runner job completed successfully."
210229 kubectl logs -n $NAMESPACE job/$JOB_NAME
You can’t perform that action at this time.
0 commit comments