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

Fix ticket-based job state transition for analysis jobs #1105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ambrussimon
Copy link
Contributor

Fixes #1084

  • Mostly copied relevant parts from EnginePlacer (DRY suggestions welcome)
  • Added tests

Review Checklist

  • Tests were added to cover all code changes
  • Documentation was added / updated
  • Code and tests follow standards in CONTRIBUTING.md

@ryansanford
Copy link
Contributor

@nagem @ambrussimon Please confirm if this adds any risk for endpoints in use, so we can decide whether to hold this merge for after the imminent release. Thanks.

@ambrussimon ambrussimon force-pushed the analysis-job-completion-ticket branch from 1f566ab to dd7bc31 Compare March 20, 2018 14:22
@codecov-io
Copy link

codecov-io commented Mar 20, 2018

Codecov Report

Merging #1105 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1105      +/-   ##
==========================================
+ Coverage   90.92%   90.98%   +0.05%     
==========================================
  Files          49       49              
  Lines        7055     7068      +13     
==========================================
+ Hits         6415     6431      +16     
+ Misses        640      637       -3

@ambrussimon
Copy link
Contributor Author

@ryansanford Change scope is limited to POST /upload/engine?level=analysis and should be only additive in terms of functionality. Personally I think the risk is minimal.

})
Queue.mutate(job, {'state': 'complete' if success else 'failed',
'profile': {'elapsed': job_ticket['elapsed']}})
job = Job.get(job.id_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will raise an APINotFoundException, not return None.

It looks like we call it above too so I'm curious why you're checking for None below. Race condition that it gets deleted between the Queue.mutate call and save?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queue.mutate does not update the loaded job's attributes (except partially in this special case: https://github.com/scitran/core/blob/master/api/jobs/queue.py#L82)
Therefore calling job.save() once more (when setting saved_files below) would try to revert the state transition.
Was thinking of updating mutate instead, but wanted to limit the scope of the change and the possible errors introduced.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on that, I ran into that edge case myself earlier.

@ambrussimon ambrussimon force-pushed the analysis-job-completion-ticket branch from dd7bc31 to 03784df Compare March 20, 2018 15:38
Copy link
Contributor

@kofalt kofalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one quick question.

file_attrs['created'] = file_attrs['modified']
self.save_file(field)
self.saved.append(file_attrs)

def finalize(self):
# Search the sessions table for analysis, replace file field
if self.saved:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity check: you're sure we don't need the self.saved conditional? I'm not super familiar here.

@gsfr gsfr removed the request for review from ryansanford May 11, 2018 14:53
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.

5 participants