Skip to content

Commit

Permalink
Merge 3c35097 into 1a380c4
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego authored Jan 14, 2020
2 parents 1a380c4 + 3c35097 commit 2c95303
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
4 changes: 3 additions & 1 deletion reana_workflow_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
DEBUG_ENV_VARS = ({'name': 'WDB_SOCKET_SERVER',
'value': '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
39 changes: 30 additions & 9 deletions reana_workflow_controller/workflow_run_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _create_job_spec(self, name, command=None, image=None,
template=client.V1PodTemplateSpec())
spec.template.metadata = workflow_metadata

workflow_enginge_container = client.V1Container(
workflow_engine_container = client.V1Container(
name=current_app.config['WORKFLOW_ENGINE_NAME'],
image=image,
image_pull_policy='IfNotPresent',
Expand All @@ -348,13 +348,13 @@ def _create_job_spec(self, name, command=None, image=None,
'value': 'localhost'}
]
workflow_engine_env_vars.extend(job_controller_address)
workflow_enginge_container.env.extend(workflow_engine_env_vars)
workflow_enginge_container.security_context = \
workflow_engine_container.env.extend(workflow_engine_env_vars)
workflow_engine_container.security_context = \
client.V1SecurityContext(
run_as_group=WORKFLOW_RUNTIME_USER_GID,
run_as_user=WORKFLOW_RUNTIME_USER_UID
)
workflow_enginge_container.volume_mounts = [workspace_mount]
workflow_engine_container.volume_mounts = [workspace_mount]
secrets_store = REANAUserSecretsStore(owner_id)
job_controller_env_secrets = secrets_store.\
get_env_secrets_as_k8s_spec()
Expand All @@ -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 @@ -415,7 +411,7 @@ def _create_job_spec(self, name, command=None, image=None,
"containerPort":
current_app.config['JOB_CONTROLLER_CONTAINER_PORT']
}]
containers = [workflow_enginge_container, job_controller_container]
containers = [workflow_engine_container, job_controller_container]
spec.template.spec = client.V1PodSpec(
containers=containers)
spec.template.spec.service_account_name = \
Expand All @@ -425,6 +421,31 @@ 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':
job_controller_env_vars.extend(
current_app.config['DEBUG_ENV_VARS'])

# Add code mount to runtime pods to enable debugging.
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)
job_controller_container.volume_mounts.append({
'name': code_volume_name,
'mountPath': code_mount_path,
'subPath': 'reana-job-controller'
})
workflow_enginge_container.volume_mounts.append({
'name': code_volume_name,
'mountPath': code_mount_path,
'subPath': f'reana-workflow-engine-{self.workflow.type_}'
})

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 2c95303

Please sign in to comment.