def run(self): """Main job execution logic. This methods returns when the job execution is completed. Throws: WorkerUnsupportedRunbookType : If the language isn't supported by by the worker. OSUnsupportedRunbookType : If the language isn't supported by by the host. Exception : Any unhandled exception. """ try: self.load_job() self.initialize_runtime() self.execute_runbook() self.unload_job() except (WorkerUnsupportedRunbookType, OSUnsupportedRunbookType) as e: tracer.log_sandbox_job_unsupported_runbook_type( self.job_id, e.message) self.jrds_client.set_job_status(self.sandbox_id, self.job_id, jobstatus.FAILED, True, exception=e.message) self.unload_job() except (InvalidRunbookSignature, GPGKeyringNotConfigured) as e: self.jrds_client.set_job_status(self.sandbox_id, self.job_id, jobstatus.FAILED, True, exception=e.message) self.unload_job() except Exception: tracer.log_sandbox_job_unhandled_exception(self.job_id, traceback.format_exc()) self.job_thread_exception_queue.put(traceback.format_exc())
self.job_id, jobstatus.FAILED, True, self.get_job_extended_properties(), exception=e.message) self.unload_job() except (InvalidRunbookSignature, GPGKeyringNotConfigured), e: self.jrds_client.set_job_status(self.sandbox_id, self.job_id, jobstatus.FAILED, True, self.get_job_extended_properties(), exception=e.message) self.unload_job() except Exception: tracer.log_sandbox_job_unhandled_exception(self.job_id, traceback.format_exc()) self.job_thread_exception_queue.put(traceback.format_exc()) def execute_runbook(self): """Executes the job runtime and performs runtime operation (stream upload / status change).""" # set status to running tracer.log_sandbox_job_started(self.job_id, self.runbook.definition_kind_str, self.runbook_data.name, self.runbook_data.runbook_version_id) start_request_time = time.strptime( self.job_data.start_request_time.split("+")[0].split(".")[0], "%Y-%m-%dT%H:%M:%S") time_taken_to_start_td = datetime.utcnow() - datetime.fromtimestamp( time.mktime(start_request_time)) time_taken_to_start_in_seconds = (