Beispiel #1
0
def _create_sla_cfg(curr, tasks_count=DEFAUILT_TASKS_COUNT):
    assert isinstance(curr, job.SlaConfig)

    updated_sla = job.SlaConfig(priority=curr.priority,
                                preemptible=curr.preemptible,
                                maximumRunningInstances=tasks_count)
    return updated_sla
Beispiel #2
0
    def get_job_config_spec(self,
                            label,
                            name,
                            num_instance,
                            default_task_config,
                            instance_config=None,
                            **extra):
        """
        Creates a job.JobConfig object
        :param label: the label value of the job
        :param name: the name of the job
        :param respool_id: the id of the resource pool
        :param num_instance: the number of instance of the job
        :param default_task_config: the default task config of the job
        :param instance_config: instance specific task config
        :param extra: extra information of the job

        :type label: str
        :type name: str
        :type respool_id: str
        :type num_instance: int
        :type default_task_config: task.TaskConfig
        :type instance_config: dict<int, task.TaskConfig>
        :type extra: dict
        """
        return job.JobConfig(
            name=name,
            type=extra.get('job_type', job.SERVICE),
            labels=[
                peloton.Label(
                    key='cluster_name',
                    value=label,
                ),
                peloton.Label(
                    key='module_name',
                    value=name,
                ),
            ],
            owningTeam=extra.get('owningTeam', 'compute'),
            description=extra.get('description', 'compute task'),
            instanceCount=num_instance,
            defaultConfig=default_task_config,
            instanceConfig=instance_config,
            # sla is required by resmgr
            sla=job.SlaConfig(
                priority=1,
                preemptible=True,
            ),
            respoolID=peloton.ResourcePoolID(value=self.respool_id),
            changeLog=extra.get('change_log', None))
Beispiel #3
0
    def create_job(self, instance_num, use_instance_config, sleep_time):
        default_config = self.create_pod_config(sleep_time, 'static')
        instance_config = {}
        if use_instance_config:
            for i in range(0, instance_num):
                instance_config[i] = self.create_pod_config(
                    sleep_time, 'instance %s' % i)

        request = job.CreateRequest(
            config=job.JobConfig(
                name='instance %s && sleep %s && instance config %s' %
                (instance_num, sleep_time, use_instance_config),
                labels=[
                    peloton.Label(
                        key='task_num',
                        value=str(instance_num),
                    ),
                    peloton.Label(
                        key='sleep_time',
                        value=str(sleep_time),
                    ),
                    peloton.Label(
                        key='use_instance_config',
                        value=str(use_instance_config),
                    ),
                ],
                owningTeam='compute',
                description='test job',
                instanceCount=instance_num,
                defaultConfig=default_config,
                instanceConfig=instance_config,
                # sla is required by resmgr
                sla=job.SlaConfig(
                    priority=1,
                    preemptible=False,
                ),
                respoolID=peloton.ResourcePoolID(value=self.respool_id),
            ), )

        resp = self.client.job_svc.Create(
            request,
            metadata=self.client.jobmgr_metadata,
            timeout=default_timeout,
        )
        self.job_id = resp.jobId.value
        return resp.jobId.value