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

update job status in case of actinia error #152

Merged
merged 2 commits into from
Sep 26, 2022
Merged

update job status in case of actinia error #152

merged 2 commits into from
Sep 26, 2022

Conversation

metzm
Copy link
Collaborator

@metzm metzm commented Sep 14, 2022

If the status of an actinia resource is 400, the job status must be updated accordingly.

@metzm metzm requested a review from mmacata September 14, 2022 14:09
@metzm
Copy link
Collaborator Author

metzm commented Sep 14, 2022

Note that the case if actinia does not respond at all is not yet handled.

Copy link
Collaborator

@mmacata mmacata left a 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:
Copy link
Collaborator

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.

Comment on lines +100 to +101
else:
# other 4xx errors
Copy link
Collaborator

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"
Copy link
Collaborator

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.

Comment on lines +84 to +109
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
Copy link
Collaborator

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.

@metzm metzm merged commit 469cb3a into main Sep 26, 2022
@metzm metzm deleted the actinia_job_status branch September 26, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants