Esempio n. 1
0
    def test_determine_error(self):
        """Tests that a post-task successfully determines the correct error"""

        scale_errors = [
            ScaleDatabaseError(),
            ScaleIOError(),
            ScaleOperationalError(),
            InvalidResultsManifest(''),
            MissingRequiredOutput('')
        ]

        for scale_error in scale_errors:
            config = ExecutionConfiguration()
            config.create_tasks(['pre'])
            config.set_task_ids(self.job_exe.get_cluster_id())
            task = PostTask('agent_1', self.job_exe, self.job_exe.job_type,
                            config)
            update = job_test_utils.create_task_status_update(
                task.id, task.agent_id, TaskStatusUpdate.RUNNING, now())
            task.update(update)
            update = job_test_utils.create_task_status_update(
                task.id,
                task.agent_id,
                TaskStatusUpdate.FAILED,
                now(),
                exit_code=scale_error.exit_code)
            error = task.determine_error(update)
            self.assertEqual(scale_error.error_name, error.name)
Esempio n. 2
0
    def __init__(self, job_exe):
        """Constructor

        :param job_exe: The job execution, which must be in RUNNING status and have its related node_id, job, job_type
            and job_type_rev models populated
        :type job_exe: :class:`job.models.JobExecution`
        """

        self._id = job_exe.id
        self._job_id = job_exe.job_id
        self._job_type_id = job_exe.job.job_type_id
        self._node_id = job_exe.node_id
        if hasattr(job_exe, 'docker_volumes'):
            self._docker_volumes = job_exe.docker_volumes
        else:
            self._docker_volumes = []

        self._lock = threading.Lock()  # Protects the following fields
        self._all_tasks = []
        self._current_task = None
        self._error = None
        self._finished = None
        self._remaining_tasks = []
        self._status = 'RUNNING'

        # Create tasks
        if not job_exe.is_system:
            self._all_tasks.append(PreTask(job_exe))
        self._all_tasks.append(JobTask(job_exe))
        if not job_exe.is_system:
            self._all_tasks.append(PostTask(job_exe))
        for task in self._all_tasks:
            self._remaining_tasks.append(task)
Esempio n. 3
0
    def __init__(self, agent_id, job_exe, job_type, configuration, priority):
        """Constructor

        :param agent_id: The ID of the agent on which the execution is running
        :type agent_id: string
        :param job_exe: The job execution model, related fields will only have IDs populated
        :type job_exe: :class:`job.models.JobExecution`
        :param job_type: The job type model
        :type job_type: :class:`job.models.JobType`
        :param configuration: The job execution configuration, including secret values
        :type configuration: :class:`job.execution.configuration.json.exe_config.ExecutionConfiguration`
        :param priority: The priority of the job execution
        :type priority: int
        """

        # Public, read-only info
        self.id = job_exe.id
        self.agent_id = agent_id
        self.cluster_id = job_exe.get_cluster_id()
        self.job_id = job_exe.job_id
        self.exe_num = job_exe.exe_num
        self.job_type_id = job_exe.job_type_id
        self.node_id = job_exe.node_id
        self.priority = priority
        self.queued = job_exe.queued
        self.started = job_exe.started
        self.docker_volumes = configuration.get_named_docker_volumes()

        # Keep job_exe model for generating job_exe_end model
        self._job_exe = job_exe

        # Internal task and status info
        self._lock = threading.Lock()  # Protects the following fields
        self._all_tasks = []
        self._current_task = None
        self._error = None
        self._finished = None
        self._has_been_starved = False
        self._last_task_finished = None
        self._remaining_tasks = []
        self._status = 'RUNNING'

        # Create tasks
        for task_type in configuration.get_task_types():
            task = None
            if task_type == 'pull':
                task = PullTask(agent_id, job_exe, job_type, configuration)
            elif task_type == 'pre':
                task = PreTask(agent_id, job_exe, job_type, configuration)
            elif task_type == 'main':
                task = MainTask(agent_id, job_exe, job_type, configuration)
            elif task_type == 'post':
                task = PostTask(agent_id, job_exe, job_type, configuration)
            self._all_tasks.append(task)
        for task in self._all_tasks:
            self._remaining_tasks.append(task)