Fix how tripleo_multipathd updates multipath.conf

This patch fixes a problem that causes a stack update to fail as a
result of changing the multipathd configuration. The original code
modifies /etc/multipath.conf on the host, and uses "podman cp" to
refresh the contents of the containers that require a copy.

The original intent was to avoid restarting containers that
asynchronously read from /etc/multipath.conf, but that approach no
longer works. Instead, the new code restarts each container that
needs its multipath.conf file refreshed.

At some point, podman (or something related) started using locks on
files used in a container volume mount. Now, attempts to update the
contents of /etc/multipath.conf inside a container will fail. Here's
an example when running the same command that tripleo_multipathd
executes:

[root@standalone ~]# podman cp /etc/multipath.conf multipathd:/etc/
Error: 2 errors occurred:
        * error copying to container: copier: put: error creating "/etc/multipath.conf": copier: put: error removing item to be overwritten "/etc/multipath.conf": unlinkat /etc/multipath.conf: device or resource busy
        * error copying from host: copier: get: "/etc/multipath.conf": error copying /etc/multipath.conf: io: read/write on closed pipe

Depends-On: Ia6a8d27fd2ae6310544bc3767cf7f1fb246939c3
Change-Id: I6bd5249e3cf930108f93aee1dbcad76dda94eaee
(cherry picked from commit 91768c6e69)
This commit is contained in:
Alan Bishop 2022-02-09 08:06:12 -08:00
parent a6813adb56
commit a3f9d84534
2 changed files with 22 additions and 11 deletions

View File

@ -39,15 +39,8 @@
register: multipath_conf_containers
changed_when: false
# Services that use os-brick (e.g. cinder-volume, nova-compute) only access
# /etc/multipath.conf sporadically, so it's sufficient to refresh the
# container's copy of the file. The services do not need to be restarted.
- name: Refresh their /etc/multipath.conf
command: "{{ tripleo_container_cli }} cp /etc/multipath.conf {{ item }}:/etc/"
- name: Restart containers in order to refresh their /etc/multipath.conf
include_tasks: restart.yml
loop: "{{ multipath_conf_containers.stdout_lines | default([]) }}"
# The multipathd service does need to be restarted.
- name: Restart multipathd
command: "{{ tripleo_container_cli }} restart multipathd"
when:
- "'multipathd' in multipath_conf_containers.stdout | default('')"
loop_control:
loop_var: multipath_container

View File

@ -0,0 +1,18 @@
# Most containers are managed by systemd, but some are managed by pacemaker.
- name: "Check if the {{ multipath_container }} container is managed by systemd"
systemd:
name: "tripleo_{{ multipath_container }}"
enabled: yes
failed_when: false
changed_when: false
register: systemd_service
- name: "Restart {{ multipath_container }} using systemd"
systemd:
name: "tripleo_{{ multipath_container }}"
state: restarted
when: "'status' in systemd_service"
- name: "Restart {{ multipath_container }} using {{ tripleo_container_cli }}"
command: "{{ tripleo_container_cli }} restart {{ multipath_container }}"
when: "'status' not in systemd_service"