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

flat-manager-client: Non-zero exit code on job failure #102

Merged
merged 1 commit into from
Jun 3, 2023
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
17 changes: 16 additions & 1 deletion flat-manager-client
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ class ApiError(Exception):
return "Api call to %s failed with status %d, details: %s" % (self.url, self.status, self.body)


class FailedJobError(Exception):
def __init__(self, job):
self.job = job

def repr(self):
return {
"type": "job",
"job": self.job
}

def __str__(self):
return "Job failed: %s" % (self.job)


TENACITY_RETRY_EXCEPTIONS = (retry_if_exception_type(aiohttp.client_exceptions.ServerDisconnectedError) | retry_if_exception_type(ApiError) | retry_if_exception_type(aiohttp.client_exceptions.ServerConnectionError))
TENACITY_STOP_AFTER = stop_after_delay(300)
TENACITY_WAIT_BETWEEN = wait_random_exponential(multiplier=1, max=60)
Expand Down Expand Up @@ -390,6 +404,7 @@ async def wait_for_job(session, job_url, token):
print("\ Job completed successfully")
else:
print("\ Job failed")
raise FailedJobError(job)
return job
else:
iterations_since_change=4 # Start at 4 so we ramp up the delay faster
Expand Down Expand Up @@ -827,7 +842,7 @@ if __name__ == '__main__':
# Something called sys.exit(), lets just exit
res = 1
raise # Pass on regular exit callse
except ApiError as e:
except (ApiError, FailedJobError) as e:
eprint(str(e))
output = {
"command": args.subparser_name,
Expand Down