Skip to content

Commit

Permalink
Fix: Fail the job submit if the flink run returns a non-zero exit code (
Browse files Browse the repository at this point in the history
#203)

Co-authored-by: Yunus Olgun <[email protected]>
  • Loading branch information
yolgun and yolgun authored Jan 13, 2022
1 parent f4024dc commit fb6277c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/flinkcluster_submit_job_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function submit_job() {
# Submit job and extract the job ID
echo "/opt/flink/bin/flink run $*" | tee -a submit_log
/opt/flink/bin/flink run "$@" 2>&1 | tee -a submit_log
local -r job_exit_code=$?
local -r job_id_indicator="Job has been submitted with JobID"
job_id=$(grep "${job_id_indicator}" submit_log | awk -F "${job_id_indicator}" '{printf $2}' | awk '{printf $1}')
Expand All @@ -142,10 +143,17 @@ function submit_job() {
return 1
fi
# On success, write job ID and log.
# write job ID if there is one
write_term_log "jobID: ${job_id}"
write_term_log_msg "Successfully submitted!" "submit_log"
# check the job's exit code
if [ $job_exit_code -ne 0 ]; then
write_term_log_msg "Job failed with a non-zero exit code: ${job_exit_code}" "submit_log"
return 1
fi
# On success, write log
write_term_log_msg "Successfully submitted!" "submit_log"
return 0
}
Expand Down

0 comments on commit fb6277c

Please sign in to comment.