From fd023d17946b86c838eec19a614e29c06266d67f Mon Sep 17 00:00:00 2001 From: Marco Donadoni Date: Thu, 22 Feb 2024 15:17:43 +0100 Subject: [PATCH] feat(manager): pass custom env variables to job controller (#571) --- reana_workflow_controller/config.py | 6 ++++++ reana_workflow_controller/workflow_run_manager.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/reana_workflow_controller/config.py b/reana_workflow_controller/config.py index d62cce3a..08175395 100644 --- a/reana_workflow_controller/config.py +++ b/reana_workflow_controller/config.py @@ -162,6 +162,12 @@ def _env_vars_dict_to_k8s_list(env_vars): ) """Default image for REANA Job Controller sidecar.""" + +JOB_CONTROLLER_ENV_VARS = _env_vars_dict_to_k8s_list( + json.loads(os.getenv("REANA_JOB_CONTROLLER_ENV_VARS", "{}")) +) +"""Environment variables to be passed to the job controller container.""" + JOB_CONTROLLER_CONTAINER_PORT = 5000 """Default container port for REANA Job Controller sidecar.""" diff --git a/reana_workflow_controller/workflow_run_manager.py b/reana_workflow_controller/workflow_run_manager.py index 03cc535f..c840242f 100644 --- a/reana_workflow_controller/workflow_run_manager.py +++ b/reana_workflow_controller/workflow_run_manager.py @@ -61,6 +61,7 @@ from reana_workflow_controller.config import ( # isort:skip IMAGE_PULL_SECRETS, JOB_CONTROLLER_CONTAINER_PORT, + JOB_CONTROLLER_ENV_VARS, JOB_CONTROLLER_SHUTDOWN_ENDPOINT, REANA_KUBERNETES_JOBS_MAX_USER_MEMORY_LIMIT, REANA_KUBERNETES_JOBS_MEMORY_LIMIT, @@ -484,7 +485,6 @@ def _create_job_spec( overwrite_operational_options=overwrite_operational_options, ) workflow_engine_env_vars = env_vars or self._workflow_engine_env_vars() - job_controller_env_vars = [] owner_id = str(self.workflow.owner_id) command = format_cmd(command) workspace_mount, workspace_volume = get_workspace_volume( @@ -586,6 +586,7 @@ def _create_job_spec( ), ) + job_controller_env_vars = copy.deepcopy(JOB_CONTROLLER_ENV_VARS) job_controller_env_vars.extend( [ {"name": "REANA_USER_ID", "value": owner_id},