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
This commit is contained in:
parent
117d8e966f
commit
9f478ee18e
@ -365,6 +365,47 @@ outputs:
|
|||||||
nfs_options: {get_param: NovaNfsOptions}
|
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
|
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
|
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:
|
upgrade_tasks:
|
||||||
- name: Stop nova-compute service
|
- name: Stop nova-compute service
|
||||||
when: step|int == 1
|
when: step|int == 1
|
||||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user