From 9f478ee18e15696822a014b9ffe31638b7bc89fb Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 13 Nov 2018 09:18:40 +0100 Subject: [PATCH] Add customized libvirt-guests unit file to properly shutdown instances If resume_guests_state_on_host_boot is set in nova.conf instances need to be shutdown using libvirt-guests after nova_compute container is shut down. Therefore we need a customized libvirt-guests unit file which: 1) removes the dependency to libvirt (non container) that it don't get started as a dependency and make the nova_libvirt container to fail. 2) adds a dependency to docker related services that a shutdown of nova_compute container is possible on system reboot. 3) stops nova_compute container 4) shutdown VMs This is a missing part of Bug 1778216. Change-Id: Ic4b7b427827114fcec0f4973a200461e811ee53a Related-bug: 1778216 --- puppet/services/nova-compute.yaml | 41 +++++++++++++++++++ ..._libvirt-guests_unit-7ac2c4b5511ca549.yaml | 16 ++++++++ 2 files changed, 57 insertions(+) create mode 100644 releasenotes/notes/nova_custom_libvirt-guests_unit-7ac2c4b5511ca549.yaml diff --git a/puppet/services/nova-compute.yaml b/puppet/services/nova-compute.yaml index b2cecec7bc..6085886501 100644 --- a/puppet/services/nova-compute.yaml +++ b/puppet/services/nova-compute.yaml @@ -365,6 +365,47 @@ outputs: nfs_options: {get_param: NovaNfsOptions} mount: name=/var/lib/nova/instances src="{{nfs_share}}" fstype=nfs4 opts="_netdev,bg,{{nfs_options}},vers=4,nfsvers=4" state=mounted when: nfs_backend_enable|bool + - name: is Nova Resume Guests State On Host Boot enabled + set_fact: + resume_guests_state_on_host_boot_enabled: {get_param: NovaResumeGuestsStateOnHostBoot} + - name: install libvirt-guests systemd unit file + when: resume_guests_state_on_host_boot_enabled|bool + block: + - name: libvirt-guests unit to stop nova_api container before shutdown VMs + copy: + dest: /etc/systemd/system/libvirt-guests.service + content: | + [Unit] + Description=Suspend/Resume Running libvirt Guests + Requires=virt-guest-shutdown.target + After=network.target + After=time-sync.target + After=virt-guest-shutdown.target + After=docker.service + After=paunch-container-shutdown.service + After=rhel-push-plugin.service + Documentation=man:libvirtd(8) + Documentation=https://libvirt.org + + [Service] + EnvironmentFile=-/etc/sysconfig/libvirt-guests + # Hack just call traditional service until we factor + # out the code + ExecStart=/usr/libexec/libvirt-guests.sh start + ExecStop=/bin/{{container_cli}} stop nova_compute + ExecStop=/usr/libexec/libvirt-guests.sh stop + Type=oneshot + RemainAfterExit=yes + StandardOutput=journal+console + TimeoutStopSec=0 + + [Install] + WantedBy=multi-user.target + - name: libvirt-guests enable VM shutdown on compute reboot/shutdown + systemd: + name: libvirt-guests + enabled: yes + daemon_reload: yes upgrade_tasks: - name: Stop nova-compute service when: step|int == 1 diff --git a/releasenotes/notes/nova_custom_libvirt-guests_unit-7ac2c4b5511ca549.yaml b/releasenotes/notes/nova_custom_libvirt-guests_unit-7ac2c4b5511ca549.yaml new file mode 100644 index 0000000000..22d324aadb --- /dev/null +++ b/releasenotes/notes/nova_custom_libvirt-guests_unit-7ac2c4b5511ca549.yaml @@ -0,0 +1,16 @@ +--- +fixes: + - | + Add customized libvirt-guests unit file to properly shutdown instances + + If resume_guests_state_on_host_boot is set in nova.conf instances + need to be shutdown using libvirt-guests after nova_compute container + is shut down. Therefore we need a customized libvirt-guests unit file + 1) removes the dependency to libvirt (non container) that it don't + get started as a dependency and make the nova_libvirt container to fail. + 2) adds a dependency to docker related services that a shutdown of + nova_compute container is possible on system reboot. + 3) stops nova_compute container + 4) shutdown VMs + + This is a missing part of Bug 1778216.