Commit 4e211235 authored by John Chilton's avatar John Chilton
Browse files

Extract functionality from k8s runner for reuse.

parent 7ebb964a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -818,6 +818,13 @@ class AsynchronousJobState(JobState):
        if attribute not in self.cleanup_file_attributes:
            self.cleanup_file_attributes.append(attribute)

    def init_job_stream_files(self):
        """For runners that don't create explicit job scripts - create job stream files."""
        with open(self.output_file, "w"):
            pass
        with open(self.error_file, "w"):
            pass


class AsynchronousJobRunner(BaseJobRunner, Monitors):
    """Parent class for any job runner that runs jobs asynchronously (e.g. via
+2 −6
Original line number Diff line number Diff line
@@ -173,12 +173,8 @@ class KubernetesJobRunner(AsynchronousJobRunner):
            job_wrapper=job_wrapper,
            job_destination=job_wrapper.job_destination,
        )
        # Kubernetes doesn't really produce meaningful "job stdout", but file needs to be present
        with open(ajs.output_file, "w"):
            pass
        with open(ajs.error_file, "w"):
            pass

        # Kubernetes doesn't really produce a "job script", but job stream files needs to be present
        ajs.init_job_stream_files()
        if not self.prepare_job(
            job_wrapper,
            include_metadata=False,