Skip to content

Commit bb7b2ff

Browse files
committed
fix(dask): check Traefik before creating dashboard ingress (#629)
Before creating the Dask dashboard ingress, the code now checks if either TRAEFIK_ENABLED or TRAEFIK_EXTERNAL is set. This ensures that ingress resources are only created and deleted when Traefik is available. Closes reanahub/reana#852
1 parent 3a8e37e commit bb7b2ff

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

reana_workflow_controller/config.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# This file is part of REANA.
4-
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 CERN.
4+
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 CERN.
55
#
66
# REANA is free software; you can redistribute it and/or modify it
77
# under the terms of the MIT License; see LICENSE file for more details.
@@ -11,7 +11,6 @@
1111
import os
1212
import json
1313

14-
from distutils.util import strtobool
1514
from reana_commons.config import (
1615
MQ_CONNECTION_STRING,
1716
REANA_COMPONENT_PREFIX,
@@ -293,11 +292,17 @@ def _parse_interactive_sessions_environments(env_var):
293292
IMAGE_PULL_SECRETS = os.getenv("IMAGE_PULL_SECRETS", "").split(",")
294293
"""Docker image pull secrets which allow the usage of private images."""
295294

296-
DASK_ENABLED = strtobool(os.getenv("DASK_ENABLED", "true"))
297-
"""Whether Dask is enabled in the cluster or not"""
295+
TRAEFIK_ENABLED = os.getenv("TRAEFIK_ENABLED", "true").lower() == "true"
296+
"""Whether Traefik is enabled in the cluster or not."""
297+
298+
TRAEFIK_EXTERNAL = os.getenv("TRAEFIK_EXTERNAL", "false").lower() == "true"
299+
"""Whether Traefik is deployed externally or not."""
300+
301+
DASK_ENABLED = os.getenv("DASK_ENABLED", "true").lower() == "true"
302+
"""Whether Dask is enabled in the cluster or not."""
298303

299304
DASK_AUTOSCALER_ENABLED = os.getenv("DASK_AUTOSCALER_ENABLED", "true").lower() == "true"
300-
"""Whether Dask autoscaler is enabled in the cluster or not"""
305+
"""Whether Dask autoscaler is enabled in the cluster or not."""
301306

302307
REANA_DASK_CLUSTER_MAX_MEMORY_LIMIT = os.getenv(
303308
"REANA_DASK_CLUSTER_MAX_MEMORY_LIMIT", "16Gi"
@@ -307,7 +312,7 @@ def _parse_interactive_sessions_environments(env_var):
307312
REANA_DASK_CLUSTER_DEFAULT_NUMBER_OF_WORKERS = int(
308313
os.getenv("REANA_DASK_CLUSTER_DEFAULT_NUMBER_OF_WORKERS", 2)
309314
)
310-
"""Number of workers in Dask cluster by default """
315+
"""Number of workers in Dask cluster by default."""
311316

312317
REANA_DASK_CLUSTER_DEFAULT_SINGLE_WORKER_MEMORY = os.getenv(
313318
"REANA_DASK_CLUSTER_DEFAULT_SINGLE_WORKER_MEMORY", "2Gi"

reana_workflow_controller/dask.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
REANA_INGRESS_HOST,
4444
REANA_INGRESS_CLASS_NAME,
4545
REANA_INGRESS_ANNOTATIONS,
46+
TRAEFIK_ENABLED,
47+
TRAEFIK_EXTERNAL,
4648
)
4749

4850

@@ -129,7 +131,8 @@ def create_dask_resources(self):
129131
self._prepare_autoscaler()
130132
self._create_dask_autoscaler()
131133

132-
create_dask_dashboard_ingress(self.workflow_id, self.user_id)
134+
if TRAEFIK_ENABLED or TRAEFIK_EXTERNAL:
135+
create_dask_dashboard_ingress(self.workflow_id, self.user_id)
133136

134137
except Exception as e:
135138
logging.error(
@@ -594,15 +597,16 @@ def delete_dask_cluster(workflow_id, user_id) -> None:
594597
f"Error deleting Dask autoscaler for workflow {workflow_id}: {e}"
595598
)
596599

597-
try:
598-
delete_dask_dashboard_ingress(workflow_id)
599-
logging.info(
600-
f"Dask dashboard ingress for workflow {workflow_id} deleted successfully."
601-
)
602-
except Exception as e:
603-
errors.append(
604-
f"Error deleting Dask dashboard ingress for workflow {workflow_id}: {e}"
605-
)
600+
if TRAEFIK_ENABLED or TRAEFIK_EXTERNAL:
601+
try:
602+
delete_dask_dashboard_ingress(workflow_id)
603+
logging.info(
604+
f"Dask dashboard ingress for workflow {workflow_id} deleted successfully."
605+
)
606+
except Exception as e:
607+
errors.append(
608+
f"Error deleting Dask dashboard ingress for workflow {workflow_id}: {e}"
609+
)
606610

607611
try:
608612
dask_service = (

0 commit comments

Comments
 (0)