From a3c0edba564beff374e5074ed6a00170b350bf2b Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 10 Feb 2022 14:23:44 +0200 Subject: [PATCH] Fix race-condition when libvirt starts unwillingly libvirtd.socket does monitor libvirtd.service and trigger service restart when it spot that service is down. However in order to enable tcp and tls sockets, we need libvirt to be stopped. Currently race condition can happen, when we stop libvirt, but it's started by socket before we enable tls one. To overcome this we stop socket along with service. Change-Id: Iacc093311036fb8d6559a0e32252579303a639ba --- handlers/main.yml | 8 ++++++-- tasks/drivers/kvm/nova_compute_kvm_install.yml | 3 ++- vars/debian.yml | 4 +++- vars/redhat-9.yml | 4 +++- vars/redhat.yml | 4 +++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index ee06a198..99a34261 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -15,12 +15,14 @@ - name: Stop libvirt-bin service: - name: "{{ libvirt_service_name }}" + name: "{{ item }}" enabled: yes state: "stopped" listen: - Restart libvirt-bin - "cert installed" + with_items: + - "{{ libvirt_service_name }}" when: - "'nova_compute' in group_names" - nova_virt_type != 'ironic' @@ -43,9 +45,11 @@ - name: Start libvirt-bin service: - name: "{{ libvirt_service_name }}" + name: "{{ item }}" enabled: yes state: "started" + with_items: + - "{{ libvirt_service_name }}" listen: - Restart libvirt-bin - "cert installed" diff --git a/tasks/drivers/kvm/nova_compute_kvm_install.yml b/tasks/drivers/kvm/nova_compute_kvm_install.yml index 34e4216d..57607262 100644 --- a/tasks/drivers/kvm/nova_compute_kvm_install.yml +++ b/tasks/drivers/kvm/nova_compute_kvm_install.yml @@ -15,8 +15,9 @@ - name: Make sure libvirt is started service: - name: "{{ libvirt_service_name }}" + name: "{{ item }}" state: "started" + with_items: "{{ libvirt_service_name }}" - name: Check the state of the default qemu save directory stat: diff --git a/vars/debian.yml b/vars/debian.yml index 7b438e69..ee5c5c1f 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -17,7 +17,9 @@ cache_timeout: 600 libvirt_group: libvirt -libvirt_service_name: libvirtd +libvirt_service_name: + - libvirtd.socket + - libvirtd.service # Common apt packages nova_distro_packages: diff --git a/vars/redhat-9.yml b/vars/redhat-9.yml index 19c73bec..8861bf1c 100644 --- a/vars/redhat-9.yml +++ b/vars/redhat-9.yml @@ -16,7 +16,9 @@ nova_qemu_user: qemu nova_qemu_group: qemu libvirt_group: libvirt -libvirt_service_name: libvirtd +libvirt_service_name: + - libvirtd.socket + - libvirtd.service # Common yum packages nova_distro_packages: diff --git a/vars/redhat.yml b/vars/redhat.yml index da50e2f3..cd51aa8b 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -16,7 +16,9 @@ nova_qemu_user: qemu nova_qemu_group: qemu libvirt_group: libvirt -libvirt_service_name: libvirtd +libvirt_service_name: + - libvirtd.socket + - libvirtd.service # Common yum packages nova_distro_packages: