Skip to content

Commit

Permalink
workflow_run_manager: add code mount in dev mode
Browse files Browse the repository at this point in the history
* Adds REANA code mounted to runtime pods (RWE_ and RJC) when
  FLASK_ENV is `development`. We assume that when REANA is installed
  in dev mode, minikube will have all REANA source code under `/code`
  this safe to assume since it is part of our Makefile procedures
  (we do not allow to run REANA in dev mode without the mount active).
  • Loading branch information
Diego Rodriguez committed Jan 14, 2020
1 parent a7fd1f8 commit 0255de9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 4 additions & 2 deletions reana_workflow_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@
"""Common to all workflow engines environment variables."""

DEBUG_ENV_VARS = ({'name': 'WDB_SOCKET_SERVER',
'value': 'wdb'},
'value': 'reana-wdb'},
{'name': 'WDB_NO_BROWSER_AUTO_OPEN',
'value': 'True'})
'value': 'True'},
{'name': 'FLASK_ENV',
'value': 'development'})
"""Common to all workflow engines environment variables for debug mode."""

TTL_SECONDS_AFTER_FINISHED = 60
Expand Down
26 changes: 22 additions & 4 deletions reana_workflow_controller/workflow_run_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,6 @@ def _create_job_spec(self, name, command=None, image=None,
args=self._create_job_controller_startup_cmd(user),
ports=[])

if os.getenv('FLASK_ENV') == 'development':
job_controller_env_vars.extend(
current_app.config['DEBUG_ENV_VARS'])

job_controller_env_vars.extend([
{
'name': 'REANA_USER_ID',
Expand Down Expand Up @@ -425,6 +421,28 @@ def _create_job_spec(self, name, command=None, image=None,
secrets_store.get_file_secrets_volume_as_k8s_specs(),
]

if os.getenv('FLASK_ENV') == 'development':
code_volume_name = 'reana-code'
code_mount_path = '/code'
k8s_code_volume = client.V1Volume(
name=code_volume_name
)
k8s_code_volume.host_path = client.V1HostPathVolumeSource(
code_mount_path
)
spec.template.spec.volumes.append(k8s_code_volume)

for container in spec.template.spec.containers:
container.env.extend(current_app.config['DEBUG_ENV_VARS'])
sub_path = f'reana-{container.name}'
if container.name == 'workflow-engine':
sub_path += f'-{self.workflow.type_}'
container.volume_mounts.append({
'name': code_volume_name,
'mountPath': code_mount_path,
'subPath': sub_path
})

job.spec = spec
job.spec.template.spec.restart_policy = 'Never'
job.spec.ttl_seconds_after_finished = TTL_SECONDS_AFTER_FINISHED
Expand Down

0 comments on commit 0255de9

Please sign in to comment.