I have an image of java code that does database validation and the job uses that image. I want the job to intentionally fail when the database validation fails. Is there any way to do the same?
Asked
Active
Viewed 2,879 times
3
-
1Returning exit code != 0 didn't work for you? – rkosegi Jan 28 '20 at 05:10
-
Do you mean System.exit(1) in java code? @rkosegi – Darshil Shah Jan 28 '20 at 05:20
-
Worked, thank you @rkosegi – Darshil Shah Jan 28 '20 at 07:09
1 Answers
4
A Kubernetes job is just a contrainer running. As with any container, the final exit code determines if the run was successful or not. So, to make your job fail you need to exit with a code other than 0.
How would you do this in Java?
System.exit(1)
How would you do this in Bash scripting?
exit 1
How would you do this in Node.js?
process.exit(1)
How would you do this in Python/PHP?
exit(1)
How would you do this in Go?
os.Exit(1)

george.yord
- 3,002
- 2
- 15
- 7
-
I tried both `process.exit(0)` and `node index.js ; exit $?`, but the job keeps running until `activeDeadlineSeconds` was hit and terminated as a failure... – paulz Mar 03 '23 at 00:10