From 864514729287f502dedf9153cbf946c53ba742c0 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Fri, 4 Feb 2022 12:45:02 -0500 Subject: [PATCH] Renamed scontext variable to mount_options --- awx/main/tasks/jobs.py | 13 ++++++------- awx/main/tasks/receptor.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/awx/main/tasks/jobs.py b/awx/main/tasks/jobs.py index 54ce9b2f3d..23bf8faa68 100644 --- a/awx/main/tasks/jobs.py +++ b/awx/main/tasks/jobs.py @@ -164,15 +164,14 @@ class BaseTask(object): # Using z allows the dir to be mounted by multiple containers # Uppercase Z restricts access (in weird ways) to 1 container at a time if this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER: - src, dest, scontext = this_path.split(':') + src, dest, mount_option = this_path.split(':') - # scontext validation via performed via API, but since this can be overriden via settings.py - # let's ensure scontext is one that we support - if scontext not in CONTAINER_VOLUMES_MOUNT_TYPES: - scontext = 'z' - logger.warn(f'The path {this_path} has volume mount type {scontext} which is not supported. Using "z" instead.') + # mount_option validation via performed via API, but since this can be overriden via settings.py + if mount_option not in CONTAINER_VOLUMES_MOUNT_TYPES: + mount_option = 'z' + logger.warn(f'The path {this_path} has volume mount type {mount_option} which is not supported. Using "z" instead.') - params['container_volume_mounts'].append(f'{src}:{dest}:{scontext}') + params['container_volume_mounts'].append(f'{src}:{dest}:{mount_option}') elif this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER - 1: src, dest = this_path.split(':') params['container_volume_mounts'].append(f'{src}:{dest}:z') diff --git a/awx/main/tasks/receptor.py b/awx/main/tasks/receptor.py index 2bdc0223ea..278f4dbbc6 100644 --- a/awx/main/tasks/receptor.py +++ b/awx/main/tasks/receptor.py @@ -500,9 +500,9 @@ class AWXReceptorJob: spec_volumes = [] for idx, this_path in enumerate(settings.AWX_ISOLATION_SHOW_PATHS): - scontext = None + mount_option = None if this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER: - src, dest, scontext = this_path.split(':') + src, dest, mount_option = this_path.split(':') elif this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER - 1: src, dest = this_path.split(':') else: @@ -512,7 +512,7 @@ class AWXReceptorJob: # We do this so we can use the same configuration for regular scenarios and k8s # Since flags like ':O', ':z' or ':Z' are not valid in the k8s realm # Example: /data:/data:ro - read_only = bool('ro' == scontext) + read_only = bool('ro' == mount_option) # Since type is not being passed, k8s by default will not perform any checks if the # hostPath volume exists on the k8s node itself.