def _status_info(job_schedule_info): # Let's grab the last job complete_at = job_schedule_info["requests"][0]["complete_at"] request_id = job_schedule_info["requests"][0]["request_id"] # NOTE: This call can take a bit of time return buildjson.query_job_data(complete_at, request_id)
def query_job_status(job): """Helper to determine the scheduling status of a job from self-serve.""" if not ("status" in job): return PENDING else: status = job["status"] if status is None: if job.get("endtime") is not None: return RUNNING else: return UNKNOWN elif status == SUCCESS: # The success status for self-serve can actually be a coalesced job req = job["requests"][0] status_data = query_job_data( req["complete_at"], req["request_id"]) if status_data["properties"]["revision"][0:12] != req["revision"][0:12]: return COALESCED else: return SUCCESS elif status in (WARNING, FAILURE, EXCEPTION, RETRY, CANCELLED): return status else: LOG.debug(job) raise Exception("Unexpected status")
def _is_coalesced(self, job): """Helper method to determine if a job with status 'SUCCESS' is coalesced. Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1175611 """ assert job["status"] == SUCCESS req = job["requests"][0] status_data = query_job_data(req["complete_at"], req["request_id"]) if not status_data: LOG.info("We have not found the job. We assume the job to be running.") return RUNNING if status_data["properties"]["revision"][0:12] != req["revision"][0:12]: return COALESCED else: return SUCCESS