Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit serving container when process-based cron fails #1560

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/workloads/cortex/serve/init/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import time
import json
import sys

from cortex.lib.type import (
predictor_type_from_api_spec,
Expand Down Expand Up @@ -154,7 +155,7 @@ def main():

# wait until the cron finishes its first pass
if cron:
while not cron.ran_once():
while cron.is_alive() and not cron.ran_once():
time.sleep(0.25)

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

# exit if cron has exited with errors
if cron and isinstance(cron.exitcode, int) and cron.exitcode != 0:
# if it was killed by a signal
if cron.exitcode < 0:
sys.exit(-cron.exitcode)
sys.exit(cron.exitcode)


if __name__ == "__main__":
main()