nova/nova/tests/unit
Balazs Gibizer 30317e6b3f Replace blind retry with libvirt event waiting in detach
Nova so far applied a retry loop that tried to periodically detach the
device from libvirt while the device was visible in the domain xml. This
could lead to an issue where an already progressing detach on the
libvirt side is interrupted by nova re-sending the detach request for
the same device. See bug #1882521 for more information.

Also if there was both a persistent and a live domain the nova tried the
detach from both at the same call. This lead to confusion about the
result when such call failed. Was the detach failed partially?

We can do better, at least for the live detach case. Based on the
libvirt developers detaching from the persistent domain always
succeeds and it is a synchronous process. Detaching from the live
domain can be both synchronous or asynchronous depending on the guest
OS and the load on the hypervisor. But for live detach libvirt always
sends an event [1] nova can wait for.

So this patch does two things.

1) Separates the detach from the persistent domain from the detach from
   the live domain to make the error cases clearer.

2) Changes the retry mechanism.

   Detaching from the persistent domain is not retried. If libvirt
   reports device not found, while both persistent and live detach
   is needed, the error is ignored, and the process continues with
   the live detach. In any other case the error considered as fatal.

   Detaching from the live domain is changed to always wait for the
   libvirt event. In case of timeout, the live detach is retried.
   But a failure event from libvirt considered fatal, based on the
   information from the libvirt developers, so in this case the
   detach is not retried.

Related-Bug: #1882521

[1]https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventDeviceRemovedCallback

Change-Id: I7f2b6330decb92e2838aa7cee47fb228f00f47da
(cherry picked from commit e56cc4f439)
2021-05-05 09:47:35 +02:00
..
accelerator Cyborg evacuate support 2020-09-01 08:41:45 +00:00
api Merge "Initialize global data separately and run_once in WSGI app init" 2021-03-23 16:55:49 +00:00
cmd nova-status: Add hw_machine_type check for libvirt instances 2021-03-03 14:03:49 +00:00
compute compute: Reject requests to commit intermediary snapshot of an inactive instance 2021-04-09 10:06:09 +01:00
conductor Rename ensure_network_metadata to amend requested_networks 2021-02-03 18:21:34 +01:00
conf Support different vGPU types per pGPU 2020-04-09 17:54:26 +02:00
console Refactor and rename test_tcp_rst_no_compute_rpcapi 2021-02-03 23:15:06 +00:00
db Dynamically archive FK related records in archive_deleted_rows 2021-03-11 20:05:44 +00:00
fake_loadables
image glance: Remove [glance]/allowed_direct_url_schemes 2021-01-28 12:46:57 +00:00
keymgr
network pci: Add vDPA vnic to PCI request mapping and filtering 2021-03-16 20:39:26 +00:00
notifications libvirt: Add support for virtio-based input devices 2021-03-05 11:00:02 +00:00
objects pci: Add vDPA vnic to PCI request mapping and filtering 2021-03-16 20:39:26 +00:00
pci pci: Add vDPA vnic to PCI request mapping and filtering 2021-03-16 20:39:26 +00:00
policies api: Block unsupported actions with vDPA 2021-03-16 20:39:27 +00:00
privsep Remove VFSLocalFS 2021-03-03 17:55:43 +01:00
scheduler Merge "scheduler: Translate secure boot requests to trait" 2021-03-14 08:14:41 +00:00
servicegroup Handle ServiceNotFound in DbDriver._report_state 2019-12-04 09:50:17 -05:00
ssl_cert
storage Add ability to download Glance images into the libvirt image cache via RBD 2020-08-31 15:14:11 +02:00
virt Replace blind retry with libvirt event waiting in detach 2021-05-05 09:47:35 +02:00
volume Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
__init__.py
cast_as_call.py
conf_fixture.py Support different vGPU types per pGPU 2020-04-09 17:54:26 +02:00
fake_block_device.py
fake_build_request.py
fake_console_auth_token.py
fake_crypto.py
fake_diagnostics.py
fake_flavor.py
fake_hosts.py
fake_instance.py objects: Update keypairs when saving an instance 2020-07-22 12:29:19 +00:00
fake_ldap.py Remove six.moves 2020-11-07 03:25:02 +00:00
fake_network.py nova-net: Kill it 2020-01-14 21:25:56 +00:00
fake_network_cache_model.py Use UUID as vif and network_id in vif tests 2020-09-07 10:31:52 +02:00
fake_notifier.py
fake_pci_device_pools.py
fake_policy.py virt: Remove 'reset_network' API 2020-11-23 15:55:50 +00:00
fake_processutils.py Remove six.binary_type/integer_types/string_types 2020-12-13 11:25:14 +00:00
fake_request_spec.py objects: Introduce 'pcpuset' field for InstanceNUMACell 2020-07-14 00:38:34 +08:00
fake_requests.py
fake_server_actions.py Store instance action event exc_val fault details 2020-03-21 06:08:34 +00:00
fake_volume.py
image_fixtures.py
matchers.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
policy_fixture.py [Trivial] Replace ref of policy.json to policy.yaml 2020-09-09 16:46:43 +00:00
test_api_validation.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
test_availability_zones.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
test_baserpc.py
test_block_device.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
test_cache.py
test_cinder.py
test_conf.py test cleanup: Make base TestCase subclass oslotest 2019-11-22 22:38:22 +00:00
test_configdrive2.py
test_context.py Revert "Log CellTimeout traceback in scatter_gather_cells" 2019-10-22 17:12:28 -04:00
test_crypto.py Remove six.moves 2020-11-07 03:25:02 +00:00
test_exception.py rpc: Rework 'get_notifier', 'wrap_exception' 2021-03-01 11:06:48 +00:00
test_exception_wrapper.py rpc: Rework 'get_notifier', 'wrap_exception' 2021-03-01 11:06:48 +00:00
test_fake_notifier.py rpc: Rework 'get_notifier', 'wrap_exception' 2021-03-01 11:06:48 +00:00
test_fixtures.py db: Compact Mitaka database migrations 2021-01-07 11:47:43 +00:00
test_flavors.py
test_hacking.py Merge "Add a hacking rule for assert_has_calls" 2020-10-14 14:31:15 +00:00
test_identity.py
test_instance_types_extra_specs.py
test_json_ref.py Remove six.moves 2020-11-07 03:25:02 +00:00
test_loadables.py
test_matchers.py
test_metadata.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
test_notifications.py virt: Remove 'get_all_bw_counters' API 2020-11-24 15:29:21 +00:00
test_notifier.py
test_policy.py Reuse code from oslo lib for JSON policy migration 2021-01-14 22:41:33 +00:00
test_profiler.py Remove six.moves 2020-11-07 03:25:02 +00:00
test_quota.py Remove six.moves 2020-11-07 03:25:02 +00:00
test_rpc.py rpc: Rework 'get_notifier', 'wrap_exception' 2021-03-01 11:06:48 +00:00
test_safeutils.py
test_service.py Restore retrying the RPC connection to conductor 2020-11-13 18:02:00 +01:00
test_service_auth.py
test_test.py Remove six.text_type (2/2) 2020-12-13 11:26:35 +00:00
test_test_utils.py Remove six.moves 2020-11-07 03:25:02 +00:00
test_utils.py Merge "Initialize global data separately and run_once in WSGI app init" 2021-03-23 16:55:49 +00:00
test_versions.py Change API unexpected exception message 2021-02-17 21:30:07 +00:00
test_weights.py
test_wsgi.py Remove six.PY2 and six.PY3 2020-08-15 07:45:23 +00:00
utils.py Remove six.moves 2020-11-07 03:25:02 +00:00