Skip to content

Commit

Permalink
config: add mount dest for shared FS
Browse files Browse the repository at this point in the history
* Refactors shared file system related variables to a defined mapping
  making a clear difference between source path and destination path.
  • Loading branch information
Diego Rodriguez committed Jul 24, 2018
1 parent dad812c commit 4721a1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
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_SOURCE_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'])
)

0 comments on commit 4721a1c

Please sign in to comment.