Fix sensitive environment variable values are not masked in "executing docker" printout (issue #67)

This commit is contained in:
allegroai 2021-09-13 14:00:11 +03:00
parent 31d90be0a1
commit db57441c5d
2 changed files with 13 additions and 6 deletions

View File

@ -673,7 +673,7 @@ class Worker(ServiceCommandSection):
lines=
['Running Task {} inside {}docker: {} arguments: {}\n'.format(
task_id, "default " if default_docker else '',
docker_image, docker_arguments or [])]
docker_image, self._sanitize_docker_command(docker_arguments or []))]
+ (['custom_setup_bash_script:\n{}'.format(docker_setup_script)] if docker_setup_script else []),
level="INFO",
session=task_session,
@ -1434,7 +1434,7 @@ class Worker(ServiceCommandSection):
queue_names = [q.name for q in queues]
if not all('=' in q for q in queue_names):
raise ValueError("using --dynamic-gpus, --queue [{}], "
raise ValueError("using --dynamic-gpus, --queues [{}], "
"queue must be in format <queue_name>=<num_gpus>".format(queue_names))
gpu_indexes = kwargs.get('gpus')
@ -1938,7 +1938,6 @@ class Worker(ServiceCommandSection):
clone=False,
**_
):
self._standalone_mode = standalone_mode
if not task_id:
@ -2292,8 +2291,13 @@ class Worker(ServiceCommandSection):
execution.working_dir
)
)
print("Executing task id [%s]:" % current_task.id)
for pair in attr.asdict(execution).items():
sanitized_execution = attr.evolve(
execution,
docker_cmd=" ".join(self._sanitize_docker_command(shlex.split(execution.docker_cmd or ""))),
)
for pair in attr.asdict(sanitized_execution).items():
print("{} = {}".format(*pair))
print()
return execution
@ -2956,7 +2960,8 @@ class Worker(ServiceCommandSection):
self._docker_arguments = docker_arguments
print("Running in Docker {} mode (v19.03 and above) - using default docker image: {} {}\n".format(
'*standalone*' if self._standalone_mode else '', self._docker_image, self._docker_arguments or ''))
'*standalone*' if self._standalone_mode else '', self._docker_image,
self._sanitize_docker_command(self._docker_arguments) or ''))
temp_config = deepcopy(self._session.config)
mounted_cache_dir = temp_config.get(
@ -3533,6 +3538,8 @@ class Worker(ServiceCommandSection):
def _sanitize_docker_command(self, docker_command):
# type: (List[str]) -> List[str]
if not docker_command:
return docker_command
if not self._session.config.get('agent.hide_docker_command_env_vars.enabled', False):
return docker_command

View File

@ -104,7 +104,7 @@ DAEMON_ARGS = dict({
},
'--dynamic-gpus': {
'help': 'Allow to dynamically allocate gpus based on queue properties, '
'configure with \'--queue <queue_name>=<num_gpus>\'.'
'configure with \'--queues <queue_name>=<num_gpus>\'.'
' Example: \'--dynamic-gpus --gpus 0-3 --queue dual_gpus=2 single_gpu=1\''
' Example Opportunistic: \'--dynamic-gpus --gpus 0-3 --queue dual_gpus=2 max_quad_gpus=1-4 \'',
'action': 'store_true',