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 <matt@mystile.com>
This commit is contained in:
Alexander Sowitzki 2021-01-21 18:22:58 +01:00 committed by GitHub
parent 45240c1871
commit fe792fdcd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Avoid using ``/tmp`` to resolve occasional failures starting tests with the ``--docker`` option.

View file

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