def update_stateless_job(self, job_id, new_job_config): """ param job_id: id of the job param new_job_config: new config of the job type job_id: str type new_job_config: job.JobConfig rtype: job.UpdateResponse """ request = update_svc.CreateUpdateRequest( jobId=peloton.JobID(value=job_id), jobConfig=new_job_config, updateConfig=update_pb2.UpdateConfig(), ) try: print_okblue("Updating Job %s" % job_id) resp = self.client.update_svc.CreateUpdate( request, metadata=self.client.jobmgr_metadata, timeout=default_timeout, ) return resp except Exception as e: print_fail("Exception calling Update Stateless Job: %s" % str(e)) raise
def create(self, config_version=None): """ creates an update based on the job and config. if config_version is provided, create will use the provided value, and raise an exception if version is wrong. if config_version is provided, create will query job runtime to get config version and retry until version is correct. :return: the update ID """ respool_id = self.pool.ensure_exists() self.updated_job_config.respoolID.value = respool_id while True: job_config_version = self.job.get_runtime().configurationVersion self.updated_job_config.changeLog.version = (config_version or job_config_version) request = update_svc.CreateUpdateRequest( jobId=peloton.JobID(value=self.job.job_id), jobConfig=self.updated_job_config, updateConfig=update.UpdateConfig( batchSize=self.batch_size, rollbackOnFailure=self.roll_back_on_failure, maxInstanceAttempts=self.max_instance_attempts, maxFailureInstances=self.max_failure_instances, startPaused=self.start_paused, ), ) try: resp = self.client.update_svc.CreateUpdate( request, metadata=self.client.jobmgr_metadata, timeout=self.config.rpc_timeout_sec, ) except grpc.RpcError as e: # if config version is incorrect and caller does not specify a # config version, get config version from job runtime # and try again. if (e.code() == grpc.StatusCode.ABORTED and e.details() == INVALID_VERSION_ERR_MESSAGE and config_version is None): continue raise break assert resp.updateID.value self.workflow = Workflow(resp.updateID.value, client=self.client, config=self.config) log.info("created update %s", self.workflow.workflow_id)