From bc7256cab3d663df8db5a62ac7d6aa0a7932c41b Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Fri, 23 Apr 2021 12:58:32 +0100 Subject: [PATCH] Cli: revert order of error and state change. --- lib/galaxy/jobs/runners/cli.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/jobs/runners/cli.py b/lib/galaxy/jobs/runners/cli.py index 8ddfe710ddb..a4b9f6fa069 100644 --- a/lib/galaxy/jobs/runners/cli.py +++ b/lib/galaxy/jobs/runners/cli.py @@ -171,15 +171,16 @@ class ShellJobRunner(AsynchronousJobRunner): job_state = ajs.job_wrapper.get_state() if state != old_state: log.debug(f"({id_tag}/{external_job_id}) state change: from {old_state} to {state}") - if not state == model.Job.states.OK: - # No need to change_state when the state is OK, this will be handled by `self.finish_job` - ajs.job_wrapper.change_state(state) if state == model.Job.states.ERROR and job_state != model.Job.states.STOPPED: - # Try to find out the reason for exiting + # Try to find out the reason for exiting - this needs to happen before change_state + # otherwise jobs depending on resubmission outputs see that job as failed and pause. self.__handle_out_of_memory(ajs, external_job_id) self.work_queue.put((self.mark_as_failed, ajs)) # Don't add the job to the watched items once it fails, deals with https://github.com/galaxyproject/galaxy/issues/7820 continue + if not state == model.Job.states.OK: + # No need to change_state when the state is OK, this will be handled by `self.finish_job` + ajs.job_wrapper.change_state(state) if state == model.Job.states.RUNNING and not ajs.running: ajs.running = True ajs.old_state = state