Skip to content

Commit

Permalink
Bugfix: adjust incorrectly passed keywords with exclude-strings argum…
Browse files Browse the repository at this point in the history
…ent (#15721)

* Fix incorrectly passed keywords with exclude-strings arg to ansible-runner worker cleanup command

Signed-off-by: Sasa Jovicic <[email protected]>

* Keep the quotes for each arg and adjust test_receptor

---------

Signed-off-by: Sasa Jovicic <[email protected]>
  • Loading branch information
Sasa993 authored Jan 2, 2025
1 parent 14808cb commit 7835e39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('_', '-')))
Expand Down
5 changes: 3 additions & 2 deletions awx/main/tests/unit/utils/test_receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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():
Expand All @@ -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'
)

0 comments on commit 7835e39

Please sign in to comment.