summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasa Jovicic <jovicic.sasa@hotmail.com>2025-01-02 22:16:14 +0100
committerGitHub <noreply@github.com>2025-01-02 22:16:14 +0100
commit7835e39bacd0e10d8e0b06ab160a3c89ad5628be (patch)
treea632c94233978a4e5010bc84aabe07f9bdaa48c6
parentMove RBAC functional tests into folder (#15723) (diff)
downloadawx-7835e39bacd0e10d8e0b06ab160a3c89ad5628be.tar.xz
awx-7835e39bacd0e10d8e0b06ab160a3c89ad5628be.zip
Bugfix: adjust incorrectly passed keywords with exclude-strings argument (#15721)
* Fix incorrectly passed keywords with exclude-strings arg to ansible-runner worker cleanup command Signed-off-by: Sasa Jovicic <jovicic.sasa@hotmail.com> * Keep the quotes for each arg and adjust test_receptor --------- Signed-off-by: Sasa Jovicic <jovicic.sasa@hotmail.com>
-rw-r--r--awx/main/tasks/receptor.py2
-rw-r--r--awx/main/tests/unit/utils/test_receptor.py5
2 files changed, 4 insertions, 3 deletions
diff --git a/awx/main/tasks/receptor.py b/awx/main/tasks/receptor.py
index 576ad661d5..58c2e895cc 100644
--- a/awx/main/tasks/receptor.py
+++ b/awx/main/tasks/receptor.py
@@ -360,7 +360,7 @@ def _convert_args_to_cli(vargs):
args = ['cleanup']
for option in ('exclude_strings', 'remove_images'):
if vargs.get(option):
- args.append('--{}="{}"'.format(option.replace('_', '-'), ' '.join(vargs.get(option))))
+ args.append('--{} {}'.format(option.replace('_', '-'), ' '.join(f'"{item}"' for item in vargs.get(option))))
for option in ('file_pattern', 'image_prune', 'process_isolation_executable', 'grace_period'):
if vargs.get(option) is True:
args.append('--{}'.format(option.replace('_', '-')))
diff --git a/awx/main/tests/unit/utils/test_receptor.py b/awx/main/tests/unit/utils/test_receptor.py
index b077e8a5db..123044fcad 100644
--- a/awx/main/tests/unit/utils/test_receptor.py
+++ b/awx/main/tests/unit/utils/test_receptor.py
@@ -3,7 +3,7 @@ from awx.main.tasks.receptor import _convert_args_to_cli
def test_file_cleanup_scenario():
args = _convert_args_to_cli({'exclude_strings': ['awx_423_', 'awx_582_'], 'file_pattern': '/tmp/awx_*_*'})
- assert ' '.join(args) == 'cleanup --exclude-strings="awx_423_ awx_582_" --file-pattern=/tmp/awx_*_*'
+ assert ' '.join(args) == 'cleanup --exclude-strings "awx_423_" "awx_582_" --file-pattern=/tmp/awx_*_*'
def test_image_cleanup_scenario():
@@ -17,5 +17,6 @@ def test_image_cleanup_scenario():
}
)
assert (
- ' '.join(args) == 'cleanup --remove-images="quay.invalid/foo/bar:latest quay.invalid/foo/bar:devel" --image-prune --process-isolation-executable=podman'
+ ' '.join(args)
+ == 'cleanup --remove-images "quay.invalid/foo/bar:latest" "quay.invalid/foo/bar:devel" --image-prune --process-isolation-executable=podman'
)