-
Notifications
You must be signed in to change notification settings - Fork 9
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
update job status in case of actinia error #152
Conversation
Note that the case if actinia does not respond at all is not yet handled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just suggested tiny refactoring to avoid misleading code (e.g. finished
status with code 400
) and added a hint to think about, but as I have no better idea for this issue it is fine for me to merge.
@@ -80,10 +80,32 @@ def get(self, job_id): | |||
|
|||
# Store the updated job in the database | |||
self.job_db[job_id] = job | |||
else: | |||
elif code == 400: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Unfortunately I cannot make a suggestion in the unchanged lines above, so explaining here)
Why not merge if code == 200
and elif code == 400
to a if code == 200 or code == 400
block? This way, inconsistencies don't matter, e.g. that there most likely is no finished
status with a 400 http code.
else: | ||
# other 4xx errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is misleading as all other HTTP codes are handled here, including eg. internal server errors 5xx
if job.additional_info != job_info: | ||
job.additional_info = job_info | ||
|
||
job.status = "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be dangerous. IIUC, the job status is always updated here on http codes not 200
or 400
. This way, the job could be set to error
if actinia is temporarily not available and later on a new request be set to running
again. Or even to error
if actinia returns other 2xx
succces codes (which I wouldn't know about in this context). I would vote for an unclear
option if it would be allowed in openeo api :D
But maybe error
is the best option here, although above objections.
elif code == 400: | ||
# actinia response contains only status and message | ||
if job.additional_info != job_info: | ||
job.additional_info = job_info | ||
if job_info["status"] == "finished": | ||
job.status = "finished" | ||
if job_info["status"] == "error": | ||
job.status = "error" | ||
if job_info["status"] == "accepted": | ||
job.status = "queued" | ||
if job_info["status"] == "terminated": | ||
job.status = "canceled" | ||
if job_info["status"] == "running": | ||
job.status = "running" | ||
|
||
# Store the updated job in the database | ||
self.job_db[job_id] = job | ||
else: | ||
# other 4xx errors | ||
if job.additional_info != job_info: | ||
job.additional_info = job_info | ||
|
||
job.status = "error" | ||
|
||
# Store the updated job in the database | ||
self.job_db[job_id] = job |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same 3 comments here as above.
If the status of an actinia resource is 400, the job status must be updated accordingly.