From fe792fdcd26ea41d38cef57ec18cef5ea45b7a7a Mon Sep 17 00:00:00 2001 From: Alexander Sowitzki Date: Thu, 21 Jan 2021 18:22:58 +0100 Subject: [PATCH] Vanquish rare container bootstrap failure (#73288) The init script for the test container writes additional lines to the .bashrc of the user. This was done via a `cat` multiline instruction, which is implemented internally by writing a temporary file to TMPDIR (/tmp in this case) first. Docker fails to provide /tmp just after creation, which results in a race condition that rarely makes the init fail. Changed the `cat` statement to multiple `echo`s. Co-authored-by: Matt Clay --- .../vanquish-rare-container-bootstrap-failure.yml | 2 ++ test/lib/ansible_test/_data/setup/docker.sh | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/vanquish-rare-container-bootstrap-failure.yml diff --git a/changelogs/fragments/vanquish-rare-container-bootstrap-failure.yml b/changelogs/fragments/vanquish-rare-container-bootstrap-failure.yml new file mode 100644 index 00000000000..2a207fdefde --- /dev/null +++ b/changelogs/fragments/vanquish-rare-container-bootstrap-failure.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test - Avoid using ``/tmp`` to resolve occasional failures starting tests with the ``--docker`` option. diff --git a/test/lib/ansible_test/_data/setup/docker.sh b/test/lib/ansible_test/_data/setup/docker.sh index c65e8ac5fc2..ea60e1a6f35 100644 --- a/test/lib/ansible_test/_data/setup/docker.sh +++ b/test/lib/ansible_test/_data/setup/docker.sh @@ -6,9 +6,8 @@ set -eu rm -f /usr/sbin/policy-rc.d # Improve prompts on remote host for interactive use. -# shellcheck disable=SC1117 -cat << EOF > ~/.bashrc -alias ls='ls --color=auto' -export PS1='\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -cd ~/ansible/ -EOF +# `cat << EOF > ~/.bashrc` flakes sometimes since /tmp may not be ready yet in +# the container. So don't do that +echo "alias ls='ls --color=auto'" > ~/.bashrc +echo "export PS1='\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '" >> ~/.bashrc +echo "cd ~/ansible/" >> ~/.bashrc