Skip to content

Commit ebe6499

Browse files
RobertLuciandeliahu
authored andcommitted
Exit serving container when process-based cron fails (#1560)
(cherry picked from commit 79b0e96)
1 parent 46719e7 commit ebe6499

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: pkg/workloads/cortex/serve/init/script.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import time
1717
import json
18+
import sys
1819

1920
from cortex.lib.type import (
2021
predictor_type_from_api_spec,
@@ -154,7 +155,7 @@ def main():
154155

155156
# wait until the cron finishes its first pass
156157
if cron:
157-
while not cron.ran_once():
158+
while cron.is_alive() and not cron.ran_once():
158159
time.sleep(0.25)
159160

160161
# disable live reloading when the BatchAPI kind is used
@@ -173,6 +174,13 @@ def main():
173174
while cron and cron.is_alive():
174175
time.sleep(0.25)
175176

177+
# exit if cron has exited with errors
178+
if cron and isinstance(cron.exitcode, int) and cron.exitcode != 0:
179+
# if it was killed by a signal
180+
if cron.exitcode < 0:
181+
sys.exit(-cron.exitcode)
182+
sys.exit(cron.exitcode)
183+
176184

177185
if __name__ == "__main__":
178186
main()

0 commit comments

Comments
 (0)