Skip to content

Instantly share code, notes, and snippets.

@JackBuggins
Last active November 14, 2023 17:50
Show Gist options
  • Save JackBuggins/b01cb5cc3e23d1971eee7726939b6be7 to your computer and use it in GitHub Desktop.
Save JackBuggins/b01cb5cc3e23d1971eee7726939b6be7 to your computer and use it in GitHub Desktop.
A simple script that can help you find any jobs that are stuck in the state BackoffLimitExceeded after failure. Note that this will depend on using jq-1.6 and GNU-Sed in this example.
#!/bin/bash
# Fetch the list of jobs to evaluate...
JOBS_TO_EVALUATE=$(
kubectl get job -o json \
| jq '.items[] | .metadata.name' \
| sed 's/"//g' \
);
# Find jobs that are stuck in the state BackoffLimitExceeded
for job in $JOBS_TO_EVALUATE; do
if [[ $(kubectl get job $job -o jsonpath='{.status.conditions[?(@.reason=="BackoffLimitExceeded")].status}') == *True* ]]; then
echo "WARNING - job $job is in state BackoffLimitExceeded"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment