Last active
November 14, 2023 17:50
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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