nova/nova
Lee Yarwood eae6aa8094 libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot
We call _hard_reboot during reboot, power_on, and
resume_state_on_host_boot. It functions essentially by tearing as much
of an instance as possible before recreating it, which additionally
makes it useful to operators for attempting automated recovery of
instances in an inconsistent state.

The Libvirt driver would previously only call _destroy and
_undefine_domain when hard rebooting an instance. This would leave vifs
plugged, volumes connected, and encryptors attached on the host. It
also means that when we try to restart the instance, we assume all
these things are correctly configured. If they are not, the instance
may fail to start at all, or may be incorrectly configured when
starting.

For example, consider an instance with an encrypted volume after a
compute host reboot. When we attempt to start the instance, power_on
will call _hard_reboot. The volume will be coincidentally re-attached
as a side-effect of calling _get_guest_xml(!), but when we call
_create_domain_and_network we pass reboot=True, which tells it not to
reattach the encryptor, as it is assumed to be already attached. We
are therefore left presenting the encrypted volume data directly to
the instance without decryption.

The approach in this patch is to ensure we recreate the instance as
fully as possible during hard reboot. This means not passing
vifs_already_plugged and reboot to _create_domain_and_network, which
in turn requires that we fully destroy the instance first. This
addresses the specific problem given in the example, but also a whole
class of potential volume and vif related issues of inconsistent
state.

Because we now always tear down volumes, encryptors, and vifs, we are
relying on the tear down of these things to be idempotent.  This
highlighted that detach of the luks and cryptsetup encryptors were not
idempotent. We depend on the fixes for those os-brick drivers.

NOTE(melwitt): In Ocata, we don't go through os-brick to handle detach
of encrypted volumes and instead have our code under
nova/volume/encryptors/. We're already ignoring exit code 4 for "not
found" in cryptsetup.py and this makes luks.py consistent with that.
We need to be able to ignore "already detached" encrypted volumes with
this patch because of the re-initialization during hard reboot.

 Conflicts:
	nova/tests/unit/virt/libvirt/test_driver.py
	nova/virt/libvirt/driver.py

NOTE(melwitt): The conflicts are due to _create_domain_and_network
taking an additional disk_info argument in Ocata and the method for
getting instance disk info was named _get_instance_disk_info instead
of _get_instance_disk_info_from_config in Ocata.

Closes-bug: #1724573
Change-Id: Id188d48609f3d22d14e16c7f6114291d547a8986
(cherry picked from commit 3f8daf0804)
2018-01-09 01:09:59 +00:00
..
CA
api Merge "Fix 'force' parameter in os-quota-sets PUT schema" into stable/ocata 2017-12-14 22:26:54 +00:00
cells Use six.text_type() when logging Instance object 2017-05-22 10:57:28 +00:00
cert Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
cloudpipe Rename security_group parameter in compute.API:create 2016-11-10 11:25:43 -05:00
cmd Merge "Fix --max-count handling for nova-manage cell_v2 map_instances" into stable/ocata 2017-10-04 23:51:11 +00:00
common cors: update default configuration in config 2016-11-05 20:17:42 -04:00
compute Merge "Call terminate_connection when shelve_offloading" into stable/ocata 2017-12-16 17:49:38 +00:00
conductor Validate new image via scheduler during rebuild 2017-11-14 10:41:06 -05:00
conf Document the real behavior of notify_on_state_change 2017-11-27 12:24:18 +00:00
console Merge "tests: Replace use of CONF with monkey patching" 2017-01-24 12:03:07 +00:00
consoleauth Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
db Make request_spec.spec MediumText 2017-12-18 19:43:54 +00:00
hacking [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
image Merge "[2/3]Replace six.iteritems() with .items()" 2017-01-21 06:55:52 +00:00
ipv6 Fix test_ipv6 and simplify to_global() 2016-06-28 20:42:32 +02:00
keymgr Deprecate barbican options 2016-07-29 15:36:28 -05:00
locale Imported Translations from Zanata 2016-10-27 08:19:38 +00:00
network Correct log message when removing a security group 2017-11-14 09:52:46 +01:00
notifications Merge "[2/3]Replace six.iteritems() with .items()" 2017-01-21 06:55:52 +00:00
objects Use instance.project_id when creating request specs for old instances 2017-12-20 13:02:41 -05:00
pci [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
policies Separate CRUD policy for server_groups 2016-11-21 11:43:13 -05:00
scheduler Refined fix for validating image on rebuild 2017-11-28 09:48:20 -05:00
servicegroup Don't use 'updated_at' to check service's status 2016-12-08 09:51:03 +00:00
tests libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot 2018-01-09 01:09:59 +00:00
virt libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot 2018-01-09 01:09:59 +00:00
vnc
volume libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot 2018-01-09 01:09:59 +00:00
wsgi Clarify the language in the apache wsgi sample 2017-02-02 15:43:25 -08:00
__init__.py
availability_zones.py Avoid lazy-load error when getting instance AZ 2017-05-31 16:00:42 +00:00
baserpc.py
block_device.py Allow None for block_device_mapping_v2.boot_index 2017-02-09 15:20:06 +00:00
cache_utils.py
config.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
context.py Cache database and message queue connection objects 2017-05-19 21:54:25 +00:00
crypto.py
debugger.py
exception.py libvirt: Always disconnect_volume after rebase failures 2017-04-26 21:25:47 +01:00
exception_wrapper.py do not include context to exception notification 2017-03-17 13:00:21 -04:00
filters.py
hash_ring.py Ironic: allow multiple compute services 2016-08-04 23:51:13 +00:00
hooks.py
i18n.py
loadables.py
manager.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
policy.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
profiler.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
quota.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
rpc.py Merge "Add live.migration.force.complete to the legacy notification whitelist" into stable/ocata 2017-10-24 06:19:51 +00:00
safe_utils.py
service.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
service_auth.py Add service_token for nova-cinder interaction 2017-01-11 15:49:16 +00:00
signature_utils.py
test.py Expose StandardLogging fixture for use 2017-07-26 14:09:26 +00:00
utils.py Use six.text_type() when logging Instance object 2017-05-22 10:57:28 +00:00
version.py
weights.py
wsgi.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00