Renamed scontext variable to mount_options

This commit is contained in:
Marcelo Moreira de Mello
2022-02-04 12:45:02 -05:00
parent 169da866f3
commit 8645147292
2 changed files with 9 additions and 10 deletions

View File

@@ -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')

View File

@@ -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.