diff --git a/hexa/pipelines/management/commands/pipelines_runner.py b/hexa/pipelines/management/commands/pipelines_runner.py index 960b736af..05d6fec52 100644 --- a/hexa/pipelines/management/commands/pipelines_runner.py +++ b/hexa/pipelines/management/commands/pipelines_runner.py @@ -33,12 +33,6 @@ def run_pipeline_kube(run: PipelineRun, env_var: dict): logger.debug("K8S RUN %s: %s for %s", os.getpid(), run.pipeline.name, exec_time_str) container_name = generate_pipeline_container_name(run) - pipeline_timeout = ( - run.pipeline_version.timeout - if run.pipeline_version.timeout - else settings.PIPELINE_RUN_DEFAULT_TIMEOUT - ) - config.load_incluster_config() v1 = CoreV1Api() pod = k8s.V1Pod( @@ -59,7 +53,7 @@ def run_pipeline_kube(run: PipelineRun, env_var: dict): ), spec=k8s.V1PodSpec( restart_policy="Never", - active_deadline_seconds=pipeline_timeout, + active_deadline_seconds=run.timeout, tolerations=[ k8s.V1Toleration( key="hub.jupyter.org_dedicated", diff --git a/hexa/pipelines/migrations/0031_pipelinerun_timeout.py b/hexa/pipelines/migrations/0031_pipelinerun_timeout.py new file mode 100644 index 000000000..e4b46595b --- /dev/null +++ b/hexa/pipelines/migrations/0031_pipelinerun_timeout.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-09-20 15:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("pipelines", "0030_alter_pipelineversion_timeout"), + ] + + operations = [ + migrations.AddField( + model_name="pipelinerun", + name="timeout", + field=models.IntegerField(null=True), + ), + ] diff --git a/hexa/pipelines/models.py b/hexa/pipelines/models.py index 583eee2bf..43b91c874 100644 --- a/hexa/pipelines/models.py +++ b/hexa/pipelines/models.py @@ -3,6 +3,7 @@ import uuid from datetime import datetime +from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.contrib.contenttypes.fields import GenericRelation from django.contrib.postgres.indexes import GinIndex, GistIndex @@ -196,6 +197,9 @@ def run( config=config if config else self.config, access_token=str(uuid.uuid4()), send_mail_notifications=send_mail_notifications, + timeout=pipeline_version.timeout + if pipeline_version.timeout + else settings.PIPELINE_RUN_DEFAULT_TIMEOUT, ) return run @@ -325,6 +329,7 @@ class Meta: run_logs = models.TextField(null=True, blank=True) current_progress = models.PositiveSmallIntegerField(default=0) send_mail_notifications = models.BooleanField(default=False) + timeout = models.IntegerField(null=True) objects = PipelineRunQuerySet.as_manager()