Skip to content

Commit

Permalink
Don't call job_runner.stop_job on jobs in new state
Browse files Browse the repository at this point in the history
These aren't submitted yet, no point in doing that.
Fixes
https://sentry.galaxyproject.org/share/issue/ea06518238f1409eb22a8f502f9db557/:
```
AssertionError: External job id is None
  File "galaxy/jobs/runners/drmaa.py", line 375, in stop_job
    assert ext_id not in (None, "None"), "External job id is None"
```
  • Loading branch information
mvdbeek committed Jul 4, 2024
1 parent ed81681 commit 70dad74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/galaxy/jobs/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,8 @@ def stop(self, job, job_wrapper):
runner_name = job_runner_name.split(":", 1)[0]
log.debug(f"Stopping job {job_wrapper.get_id_tag()} in {runner_name} runner")
try:
self.job_runners[runner_name].stop_job(job_wrapper)
if not job.state == model.Job.states.NEW:
self.job_runners[runner_name].stop_job(job_wrapper)
except KeyError:
log.error(f"stop(): ({job_wrapper.get_id_tag()}) Invalid job runner: {runner_name}")
# Job and output dataset states have already been updated, so nothing is done here.
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/jobs/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ def _handle_runner_state(self, runner_state, job_state: "JobState"):
log.exception("Caught exception in runner state handler")

def fail_job(self, job_state: "JobState", exception=False, message="Job failed", full_status=None):
if getattr(job_state, "stop_job", True):
job = job_state.job_wrapper.get_job()
if getattr(job_state, "stop_job", True) and job.state != model.Job.states.NEW:
self.stop_job(job_state.job_wrapper)
job_state.job_wrapper.reclaim_ownership()
self._handle_runner_state("failure", job_state)
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/jobs/runners/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ def recover(self, job, job_wrapper):
self.monitor_queue.put(ajs)

def fail_job(self, job_state, exception=False):
if getattr(job_state, "stop_job", True):
job = job_state.job_wrapper.get_job()
if getattr(job_state, "stop_job", True) and job.state != model.Job.states.NEW:
self.stop_job(job_state.job_wrapper)
job_state.job_wrapper.reclaim_ownership()
self._handle_runner_state("failure", job_state)
Expand Down

0 comments on commit 70dad74

Please sign in to comment.