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

VC3 Integration #312

Open
wants to merge 19 commits into
base: maint-0.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
8 changes: 8 additions & 0 deletions reana_workflow_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@

BROKER_PORT = os.getenv('RABBIT_MQ_PORT', 5672)

SHARED_VOLUME_PATH = os.getenv('SHARED_VOLUME_PATH', '/var/reana')

REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR = os.getenv('REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR', '')

if os.getenv('REANA_JOB_CONTROLLER_HOST_SHARE_TMPDIR', '').lower() == 'true':
REANA_JOB_CONTROLLER_HOST_SHARE_TMPDIR = True
else:
REANA_JOB_CONTROLLER_HOST_SHARE_TMPDIR = False

SQLALCHEMY_TRACK_MODIFICATIONS = False
"""Track modifications flag."""
Expand Down
4 changes: 4 additions & 0 deletions reana_workflow_controller/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def create_workflow_workspace(path, user_id=None,
os.umask(REANA_WORKFLOW_UMASK)
reana_fs = fs.open_fs(app.config['SHARED_VOLUME_PATH'])
reana_fs.makedirs(path, recreate=True)
if os.environ.get("VC3USERID", None):
vc3_uid = int(os.environ.get("VC3USERID"))
owner_gid = os.stat(reana_fs.getsyspath(path)).st_gid
os.chown(reana_fs.getsyspath(path), vc3_uid, owner_gid)
if git_url and git_ref:
secret_store = REANAUserSecretsStore(user_id)
gitlab_access_token = secret_store\
Expand Down
52 changes: 49 additions & 3 deletions reana_workflow_controller/workflow_run_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
SHARED_FS_MAPPING,
TTL_SECONDS_AFTER_FINISHED,
WORKFLOW_ENGINE_COMMON_ENV_VARS,
REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR,
REANA_JOB_CONTROLLER_HOST_SHARE_TMPDIR,
DEBUG_ENV_VARS)


Expand Down Expand Up @@ -350,8 +352,8 @@ def _create_job_spec(self, name, command=None, image=None,
workflow_enginge_container.env.extend(workflow_engine_env_vars)
workflow_enginge_container.security_context = \
client.V1SecurityContext(
run_as_group=WORKFLOW_RUNTIME_USER_GID,
run_as_user=WORKFLOW_RUNTIME_USER_UID
run_as_group=int(WORKFLOW_RUNTIME_USER_GID),
run_as_user=int(WORKFLOW_RUNTIME_USER_UID)
)
workflow_enginge_container.volume_mounts = [workspace_mount]
secrets_store = REANAUserSecretsStore(owner_id)
Expand Down Expand Up @@ -392,6 +394,21 @@ def _create_job_spec(self, name, command=None, image=None,
'value': K8S_CERN_EOS_AVAILABLE
}
])

job_controller_env_vars.extend([
{
'name': 'SHARED_VOLUME_PATH',
'value': SHARED_VOLUME_PATH
}
])
if REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR:
job_controller_env_vars.extend([
{
'name': 'REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR',
'value': REANA_JOB_CONTROLLER_VC3_HTCONDOR_ADDR
}
])

job_controller_container.env.extend(job_controller_env_vars)
job_controller_container.env.extend(job_controller_env_secrets)
job_controller_container.env.extend([
Expand All @@ -403,13 +420,19 @@ def _create_job_spec(self, name, command=None, image=None,
'name': 'REANA_STORAGE_BACKEND',
'value': REANA_STORAGE_BACKEND
}
])
])

secrets_volume_mount = \
secrets_store.get_secrets_volume_mount_as_k8s_spec()

job_controller_container.volume_mounts = [workspace_mount, db_mount]
job_controller_container.volume_mounts.append(secrets_volume_mount)

tmp_mount, tmp_volume = self._share_tmpdir_with_job_controller()

if tmp_mount and tmp_volume:
job_controller_container.volume_mounts.append(tmp_mount)

job_controller_container.ports = [{
"containerPort":
current_app.config['JOB_CONTROLLER_CONTAINER_PORT']
Expand All @@ -424,12 +447,35 @@ def _create_job_spec(self, name, command=None, image=None,
secrets_store.get_file_secrets_volume_as_k8s_specs(),
]

if tmp_volume and tmp_mount:
spec.template.spec.volumes.append(tmp_volume)

job.spec = spec
job.spec.template.spec.restart_policy = 'Never'
job.spec.ttl_seconds_after_finished = TTL_SECONDS_AFTER_FINISHED
job.spec.backoff_limit = 0
return job

# TODO: Move this to reana-commons
def _share_tmpdir_with_job_controller(self):
rjc_hostPath = {}
rjc_mountPath = {}
vol_name = "rjc-temp"
if REANA_JOB_CONTROLLER_HOST_SHARE_TMPDIR:
rjc_hostPath = {
"name": vol_name,
"hostPath":{
"path": "/tmp"
}
}

rjc_mountPath = {
"name": vol_name,
"mountPath": "/tmp"
}

return rjc_mountPath, rjc_hostPath

def _create_job_controller_startup_cmd(self, user=None):
"""Create job controller startup cmd."""
base_cmd = 'flask run -h 0.0.0.0;'
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@
]

install_requires = [
# Workaround for urllib3>1.25 being installed
# and conflicting with requests 2.20.0
'urllib3<1.25.0',
'Flask-SQLAlchemy>=2.2',
'Flask>=0.12',
'fs>=2.0',
'gitpython>=2.1',
'jsonpickle>=0.9.6',
'marshmallow>2.13.0,<=2.20.1',
'packaging>=18.0',
'kubernetes==10.0.1',
CodyKank marked this conversation as resolved.
Show resolved Hide resolved
'reana-commons[kubernetes]>=0.6.0,<0.7.0',
'reana-db>=0.6.0,<0.7.0',
'requests==2.20.0',
Expand Down