From 20f17687dac23d04cae825254c52cb90befc94d1 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 3 Oct 2023 08:27:55 -0700 Subject: [PATCH] ansible-test - Invoke container sleep through env (#81853) --- changelogs/fragments/ansible-test-container-sleep.yml | 3 +++ test/lib/ansible_test/_internal/host_profiles.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ansible-test-container-sleep.yml diff --git a/changelogs/fragments/ansible-test-container-sleep.yml b/changelogs/fragments/ansible-test-container-sleep.yml new file mode 100644 index 00000000000..e862530a1d4 --- /dev/null +++ b/changelogs/fragments/ansible-test-container-sleep.yml @@ -0,0 +1,3 @@ +minor_changes: +- ansible-test - When invoking ``sleep`` in containers during container setup, the ``env`` command is used to avoid invoking + the shell builtin, if present. diff --git a/test/lib/ansible_test/_internal/host_profiles.py b/test/lib/ansible_test/_internal/host_profiles.py index 33bd6640f51..09812456ca0 100644 --- a/test/lib/ansible_test/_internal/host_profiles.py +++ b/test/lib/ansible_test/_internal/host_profiles.py @@ -806,6 +806,7 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do - Avoid hanging indefinitely or for an unreasonably long time. NOTE: The container must have a POSIX-compliant default shell "sh" with a non-builtin "sleep" command. + The "sleep" command is invoked through "env" to avoid using a shell builtin "sleep" (if present). """ command = '' @@ -813,7 +814,7 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do command += f'{init_config.command} && ' if sleep or init_config.command_privileged: - command += 'sleep 60 ; ' + command += 'env sleep 60 ; ' if not command: return None