Skip to content

Commit

Permalink
Wait for systemd-tmpfiles-setup service to complete after container r…
Browse files Browse the repository at this point in the history
…estart

There is a race condition between starting an lxc container and executing
the first ansible task. Ansible makes heavy use of /tmp and the first
task executed after 'lxc-start' will collide with systemd-tmpfiles-setup
which by default removes all content from /tmp, including the working
files of any ansible task which happens to be running. This causes a fatal
error for ansible which cannot be recovered with retries.

This patch adds a raw command to check the state of the tmpfiles-setup
service and wait until it has completed, avoiding the race confdition.

Change-Id: I4ada8473bfd17b763bde16ac95099ddf7deb541c
  • Loading branch information
Jonathan Rosser committed Jun 17, 2020
1 parent f543a71 commit 8e9bdba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions playbooks/common-tasks/os-lxc-container-setup.yml
Expand Up @@ -133,6 +133,14 @@
tags:
- common-lxc

- name: Wait for container tmpfiles-setup finish
raw: systemctl status systemd-tmpfiles-setup.service | grep Process | grep 'code=exited' >/dev/null
register: systemd_tmpfiles
until: systemd_tmpfiles.rc == 0
retries: 20
delay: 2
changed_when: false

- name: Wait for container connectivity
wait_for_connection:
connect_timeout: "{{ lxc_container_wait_params.connect_timeout | default(omit) }}"
Expand Down

0 comments on commit 8e9bdba

Please sign in to comment.