Skip to content

Commit

Permalink
Merge pull request #13 from DNXLabs/kube-job-handle-error
Browse files Browse the repository at this point in the history
Created a variable to handle the error
  • Loading branch information
edonizeti authored Aug 8, 2023
2 parents efd0d9e + 99c3d69 commit 6a9cc32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/kube-job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ function run_job {
kubectl apply -f kube-job.yml
echo "Kube job ===== Waiting for ${APP_NAME}-job"
kubectl wait --for=condition=Complete job/${APP_NAME}-job -n ${KUBE_NAMESPACE}
STATUS=$?
echo "Kube job ===== Logs"
kubectl logs -f $(kubectl get pod --selector=job-name=${APP_NAME}-job -n ${KUBE_NAMESPACE} --sort-by=.metadata.creationTimestamp -o jsonpath="{.items[-1].metadata.name}") -n ${KUBE_NAMESPACE}
echo "Kube job ===== processed"

if [[ $STATUS -gt 0 ]]; then
echo "The job has failed"
exit 1
else
echo "Kube job ===== processed"
fi
}

run_job

0 comments on commit 6a9cc32

Please sign in to comment.