Skip to content
Snippets Groups Projects
Commit 1fbf9cd8 authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added support for custom singularity bindings for user-owned computing resources.

parent 73c88b8f
No related branches found
No related tags found
No related merge requests found
...@@ -185,10 +185,20 @@ class RemoteComputingManager(ComputingManager): ...@@ -185,10 +185,20 @@ class RemoteComputingManager(ComputingManager):
else: else:
authstring = '' authstring = ''
# Set bindings, only from sys config if the resource is not owned by the user
if task.computing.user != task.user:
bindings = task.computing.get_conf_param('bindings', from_sys_only=True )
else:
bindings = task.computing.get_conf_param('bindings')
if not bindings:
bindings = ''
else:
bindings = '-B {}'.format(bindings)
run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, user, host)
run_command += '/bin/bash -c \'"wget {}/api/v1/base/agent/?task_uuid={} -O \$HOME/agent_{}.py &> /dev/null && export BASE_PORT=\$(python \$HOME/agent_{}.py 2> \$HOME/{}.log) && '.format(webapp_conn_string, task.uuid, task.uuid, task.uuid, task.uuid) run_command += '/bin/bash -c \'"wget {}/api/v1/base/agent/?task_uuid={} -O \$HOME/agent_{}.py &> /dev/null && export BASE_PORT=\$(python \$HOME/agent_{}.py 2> \$HOME/{}.log) && '.format(webapp_conn_string, task.uuid, task.uuid, task.uuid, task.uuid)
run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT=\$BASE_PORT && {} '.format(authstring) run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT=\$BASE_PORT && {} '.format(authstring)
run_command += 'exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv ' run_command += 'exec nohup singularity run {} --pid --writable-tmpfs --containall --cleanenv '.format(bindings)
# Set registry # Set registry
if task.container.registry == 'docker_local': if task.container.registry == 'docker_local':
...@@ -325,7 +335,11 @@ class SlurmComputingManager(ComputingManager): ...@@ -325,7 +335,11 @@ class SlurmComputingManager(ComputingManager):
else: else:
authstring = '' authstring = ''
bindings = task.computing.get_conf_param('bindings', from_sys_only=True ) # Set bindings, only from sys config if the resource is not owned by the user
if task.computing.user != task.user:
bindings = task.computing.get_conf_param('bindings', from_sys_only=True )
else:
bindings = task.computing.get_conf_param('bindings')
if not bindings: if not bindings:
bindings = '' bindings = ''
else: else:
...@@ -443,7 +457,7 @@ class RemotehopComputingManager(ComputingManager): ...@@ -443,7 +457,7 @@ class RemotehopComputingManager(ComputingManager):
second_user = task.computing.get_conf_param('second_user') second_user = task.computing.get_conf_param('second_user')
setup_command = task.computing.get_conf_param('setup_command') setup_command = task.computing.get_conf_param('setup_command')
# De hard-code # TODO: De hard-code
use_agent = False use_agent = False
# Get user keys # Get user keys
...@@ -467,7 +481,17 @@ class RemotehopComputingManager(ComputingManager): ...@@ -467,7 +481,17 @@ class RemotehopComputingManager(ComputingManager):
authstring = ' export SINGULARITYENV_AUTH_PASS={} && '.format(task.auth_pass) authstring = ' export SINGULARITYENV_AUTH_PASS={} && '.format(task.auth_pass)
else: else:
authstring = '' authstring = ''
# Set bindings, only from sys config if the resource is not owned by the user
if task.computing.user != task.user:
bindings = task.computing.get_conf_param('bindings', from_sys_only=True )
else:
bindings = task.computing.get_conf_param('bindings')
if not bindings:
bindings = ''
else:
bindings = '-B {}'.format(bindings)
run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, first_user, first_host) run_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} '.format(user_keys.private_key_file, first_user, first_host)
run_command += '"ssh -4 -o StrictHostKeyChecking=no {}@{} /bin/bash -c \''.format(second_user, second_host) run_command += '"ssh -4 -o StrictHostKeyChecking=no {}@{} /bin/bash -c \''.format(second_user, second_host)
...@@ -476,13 +500,13 @@ class RemotehopComputingManager(ComputingManager): ...@@ -476,13 +500,13 @@ class RemotehopComputingManager(ComputingManager):
if setup_command: if setup_command:
run_command += setup_command + ' && ' run_command += setup_command + ' && '
run_command += '\'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT=\$BASE_PORT && {} '.format(authstring) run_command += '\'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT=\$BASE_PORT && {} '.format(authstring)
run_command += 'exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv ' run_command += 'exec nohup singularity run {} --pid --writable-tmpfs --containall --cleanenv '.format(bindings)
else: else:
run_command += ' : && ' # Trick to prevent some issues in exporting variables run_command += ' : && ' # Trick to prevent some issues in exporting variables
if setup_command: if setup_command:
run_command += setup_command + ' && ' run_command += setup_command + ' && '
run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT={} && {} '.format(task.port, authstring) run_command += 'export SINGULARITY_NOHTTPS=true && export SINGULARITYENV_BASE_PORT={} && {} '.format(task.port, authstring)
run_command += 'exec nohup singularity run --pid --writable-tmpfs --containall --cleanenv ' run_command += 'exec nohup singularity run {} --pid --writable-tmpfs --containall --cleanenv '.format(bindings)
# Set registry # Set registry
if task.container.registry == 'docker_local': if task.container.registry == 'docker_local':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment