Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Pipelines): add timeout to PipelineRun model #549

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions hexa/pipelines/management/commands/pipelines_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions hexa/pipelines/migrations/0031_pipelinerun_timeout.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
5 changes: 5 additions & 0 deletions hexa/pipelines/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
Loading