WORKFLOW-199: polling every X seconds for job completion#138
WORKFLOW-199: polling every X seconds for job completion#138
Conversation
|
@bahamas10 can't we modify it in a way that when Additionally, we should review if we can keep HTTP requests open more than 2 minutes, otherwise it will not be too useful for jobs like "SDC import images", where the average time is pretty much over that time always. And, speaking of such jobs. Do you think that it may have sense to add some variable to workflow definition which may allow/disallow using wait for a given type of jobs?. Everything else looks fine to me. Remember to add some test case and fix the 80 columns issues, please ;-) |
ca779f3 to
5c169d2
Compare
|
@kusor thanks for the review.. i've added the logic to handle throwing a ConflictError (409) if I'll test the 2 minute thing, as well as check out restricting blocking jobs in the workflow definition |
This adds the ability to pass new parameters to
POST /jobswhen creating a new job via the apiwait: set this totrueto have thePOSTrequest block while the job completescallback_urls: an optional array of endpoints to call, by the runner, when a job completes.A caller of the api service can create a job like this now
{ "workflow": "82280dc4-f5d9-4def-b5c1-a1361db9dd27", "wait": true, "callback_urls": [ "http://localhost:8080/jobdone" ] }where
waittells the API to return the headers immediately (containing the same headers thatPOST /jobswould normally give), but to wait until the job has completed to return the body. The body of the request will be the same body that would be supplied byGET /jobs/:uuid... ie. it will be a JSON body that gives the exit status of the job (completed, failed, etc.)callback_urlsshould contain a URL to hit the api service (the runner calls the urls incallback_urls) at the endpoint/jobdone, which is a new endpoint for the API service that takes aPOSTrequest with the output of a job, and uses that to end any requests that are currently waiting.todo
restify(if it makes sense)caveats
wait: truewithout registering the API service as acallback_urlwill result in the request hanging indefinitely