Commit 2e81c346 authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Add stop function to enable finishing jobs early to job manager and pulsar runner

parent 843d2efb
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -736,7 +736,7 @@ class PulsarJobRunner(AsynchronousJobRunner):
                )
            return False

    def stop_job(self, job_wrapper):
    def stop_job(self, job_wrapper, soft_kill=True):
        job = job_wrapper.get_job()
        if not job.job_runner_external_id:
            return
@@ -775,6 +775,9 @@ class PulsarJobRunner(AsynchronousJobRunner):
            job_id = job.job_runner_external_id
            log.debug(f"Attempt remote Pulsar kill of job with url {pulsar_url} and id {job_id}")
            client = self.get_client(job.destination_params, job_id)
            if soft_kill:
                client.kill(soft_kill=soft_kill)
            else:
                client.kill()

    def recover(self, job, job_wrapper):
+13 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ from galaxy.exceptions import (
    ObjectNotFound,
    RequestParameterInvalidException,
)
from galaxy.jobs import JobConfiguration, MinimalJobWrapper
from galaxy.job_metrics import (
    RawMetric,
    Safety,
@@ -266,6 +267,18 @@ class JobManager:
        else:
            return False

    def finish_early(self, job):
        if not job.finished:
            try:
                job.mark_stopped(self.app.config.track_jobs_in_database)
                session = self.app.model.session
                with transaction(session):
                    session.commit()
                self.app.job_manager.stop(job, message="")
                return True
            except Exception as e:
                log.error("Job Runner does not support stopping job early.")
        return False

class JobSearch:
    """Search for jobs using tool inputs or other jobs"""