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
Show file tree
Hide file tree
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
24 changes: 23 additions & 1 deletion src/openeo_grass_gis_driver/jobs_job_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

# 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
Comment on lines +100 to +101
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.


# Store the updated job in the database
self.job_db[job_id] = job

if (job.additional_info['urls'] and
"resources" in job.additional_info['urls']):
Expand Down
24 changes: 23 additions & 1 deletion src/openeo_grass_gis_driver/jobs_job_id_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,32 @@ def get(self, job_id):

# Store the updated job in the database
self.job_db[job_id] = job
else:
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
Comment on lines +84 to +109
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.


if (job.additional_info['urls'] and
"resources" in job.additional_info['urls']):
Expand Down