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

config: add mount dest for shared FS #78

Merged
merged 1 commit into from
Jul 24, 2018
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
10 changes: 8 additions & 2 deletions reana_job_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@
MAX_JOB_RESTARTS = 3
"""Number of retries for a job before considering it as failed."""

SHARED_VOLUME_PATH_ROOT = os.getenv("SHARED_VOLUME_PATH_ROOT", '/reana')
"""Root path in the underlying shared file system."""
SHARED_FS_MAPPING = {
'MOUNT_SOURCE_PATH': os.getenv("SHARED_VOLUME_PATH_ROOT", '/reana'),
# Root path in the underlying shared file system to be mounted inside
# jobs.
'MOUNT_DEST_PATH': os.getenv("SHARED_VOLUME_PATH", '/reana'),
# Mount path for the shared file system volume inside jobs.
}
"""Mapping from the shared file system backend to the job file system."""
2 changes: 1 addition & 1 deletion reana_job_controller/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def add_shared_volume(job):
else:
volume = volume_templates.get_k8s_hostpath_volume(
job['metadata']['namespace'])
mount_path = config.SHARED_VOLUME_PATH_ROOT
mount_path = config.SHARED_FS_MAPPING['MOUNT_DEST_PATH']

job['spec']['template']['spec']['containers'][0]['volumeMounts'].append(
{'name': volume['name'], 'mountPath': mount_path}
Expand Down
14 changes: 8 additions & 6 deletions reana_job_controller/volume_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import json
from string import Template

from reana_job_controller.config import SHARED_VOLUME_PATH_ROOT
from reana_job_controller.config import SHARED_FS_MAPPING

CEPHFS_SECRET_NAME = 'ceph-secret'

Expand Down Expand Up @@ -96,9 +96,10 @@ def get_k8s_cephfs_volume(experiment):
:returns: k8s CephFS volume spec as a dictionary.
"""
return json.loads(
K8S_CEPHFS_TEMPLATE.substitute(experiment=experiment,
path=SHARED_VOLUME_PATH_ROOT,
secret_name=CEPHFS_SECRET_NAME)
K8S_CEPHFS_TEMPLATE.substitute(
experiment=experiment,
path=SHARED_FS_MAPPING['MOUNT_SOURCE_PATH'],
secret_name=CEPHFS_SECRET_NAME)
)


Expand All @@ -122,6 +123,7 @@ def get_k8s_hostpath_volume(experiment):
:returns: k8s HostPath spec as a dictionary.
"""
return json.loads(
K8S_HOSTPATH_TEMPLATE.substitute(experiment=experiment,
path=SHARED_VOLUME_PATH_ROOT)
K8S_HOSTPATH_TEMPLATE.substitute(
experiment=experiment,
path=SHARED_FS_MAPPING['MOUNT_SOURCE_PATH'])
)