nova/nova/objects
Artom Lifshitz d9892abd2f Revert resize: wait for events according to hybrid plug
Since 4817165fc5, when reverting a
resized instance back to the source host, the libvirt driver waits for
vif-plugged events when spawning the instance. When called from
finish_revert_resize() in the source compute manager, libvirt's
finish_revert_migration() does not pass vifs_already_plugged to
_create_domain_and_network(), making the latter use the default False
value.

When the source compute manager calls
network_api.migrate_instance_finish() in finish_revert_resize(), this
updates the port binding back to the source host. If Neutron is
configured to use OVS hybrid plug, it will send the vif-plugged event
immediately after completing this request. This happens before the
virt driver's finish_revert_migration() method is called. This causes
the wait in the libvirt driver to time out because the event is
received before Nova starts waiting for it.

The neutron ovs l2 agent sends vif-plugged events when two conditions
are met. First the port must be bound to the host managed by the
l2 agent and second, the agent must have completed configuring the
port on ovs. This involves assigning the port a local VLAN for tenant
isolation, applying security group rules if required and applying
QoS policies or other agent extensions like service function chaining.

During the boot process, we bind the port first to the host
then plug the interface into ovs which triggers the l2 agent to
configure it resulting in the emission of the vif-plugged event.
In the revert case, as noted above, since the vif is already plugged
on the source node when hybrid-plug is used, binding the port to the
source node fulfils the second condition to send the vif-plugged event.

Events sent immediately after port binding update are hereafter known
as "bind-time" events. For ports that do not use OVS hybrid plug,
Neutron will continue to send vif-plugged events only when Nova
actually plugs the VIF. These types of events are hereafter known as
"plug-time" events. OVS hybrid plug is a per agent setting, so for
a particular host, bind-time events are an all-or-nothing thing for the
ovs backend: either all VIF_TYPE=ovs ports have them, or no ovs ports
have them. In general, a host will only have one network backend.
The only exception to this is SR-IOV. SR-IOV is commonly deployed on
the same host as other network backends such as OVS or linuxbridge.
SR-IOV ports with VNIC_TYPE=direct-physical will always have only
bind-time events. If an instance mixes OVS ports with hybrid-plug=False
with direct physical ports, it will have both kinds of events.

For same host resize reverts we do not update the binding host as the
host does not change, as such for same host resize we do not receive
bind time events. For same host revert we therefore do not wait for
bind time events in the compute manager.

This patch adds functions to the NetworkInfo model that return what
kinds of events each VIF has. These are then used in the migration
revert logic to decide when to wait for external events: in the
compute manager, when binding the port, for bind-time events,
and/or in libvirt, when plugging the VIFs, for plug-time events.

(cherry picked from commit 7a7a223602)
Conflicts in nova/tests/unit/objects/test_migration.py due to
1cf3da87027d87251920c2df665b850abb31178e's addition of
test_obj_make_compatible() and test_get_by_uuid().

(cherry picked from commit 7a3a8f325e)
NOTE(artom) uuidsentinel was moved to oslo_utils.fixture in Stein, in
Rocky it was still in nova.tests.

Closes-bug: #1832028
Closes-Bug: #1833902
Co-Authored-By: Sean Mooney <work@seanmooney.info>
Change-Id: I51673e58fc8d5f051df911630f6d7a928d123a5b
2019-07-12 19:19:58 -04:00
..
__init__.py network: Always retrieve network information if available 2018-07-03 16:50:06 +01:00
agent.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
aggregate.py Transform aggregate.update_prop notification 2018-07-15 23:36:31 +09:00
bandwidth_usage.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
base.py [placement] Object changes to support last-modified headers 2017-12-07 18:47:17 +00:00
block_device.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
build_request.py Fix incompatible version handling in BuildRequest 2019-01-18 09:55:11 +01:00
cell_mapping.py Fix using template cell urls with nova-manage 2019-01-24 18:08:20 -05:00
compute_node.py Ignore uuid if already set in ComputeNode.update_from_virt_driver 2018-10-17 16:24:10 +02:00
console_auth_token.py Use nova-consoleauth only if workaround enabled 2018-10-15 17:38:39 +00:00
diagnostics.py Added nova objects for intance diagnostics 2017-05-30 00:39:44 +04:00
dns_domain.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
ec2.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
external_event.py Add ability to signal and perform online volume size change 2017-07-12 11:53:20 -04:00
fields.py Assorted cleanups from numa-aware-vswitches series 2018-07-27 09:49:12 -07:00
fixed_ip.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
flavor.py Merge "Remove old flavor_create db api method" 2018-03-20 18:11:06 +00:00
floating_ip.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
host_mapping.py Add --by-service to discover_hosts 2018-03-16 15:55:19 -07:00
hv_spec.py objects: Move 'hv_type' to 'fields.HVType' 2016-11-25 16:19:43 +00:00
image_meta.py Update ImageMetaProp object to expose traits 2018-04-05 16:18:59 -07:00
instance.py Check hosts have no instances for AZ rename 2019-03-06 16:31:28 +03:00
instance_action.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
instance_fault.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
instance_group.py Merge "Delete instance_group_member records from API DB during archive" into stable/rocky 2018-09-21 12:01:46 +00:00
instance_info_cache.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
instance_mapping.py Fix InstanceMapping to always default queued_for_delete=False 2019-02-07 16:16:17 +01:00
instance_numa_topology.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
instance_pci_requests.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
keypair.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
migrate_data.py Avoid redundant initialize_connection on source post live migration 2019-02-14 10:10:36 +00:00
migration.py Revert resize: wait for events according to hybrid plug 2019-07-12 19:19:58 -04:00
migration_context.py Move get_pci_mapping_for_migration to MigrationContext 2019-06-05 17:43:15 +03:00
monitor_metric.py Fix MonitorMetric obj_make_compatible 2016-09-12 14:10:41 +00:00
network.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
network_metadata.py Assorted cleanups from numa-aware-vswitches series 2018-07-27 09:49:12 -07:00
network_request.py Merge "Remove DictCompat from NetworkRequest" 2016-06-30 10:23:36 +00:00
numa.py Fix overcommit for NUMA-based instances 2019-01-25 12:57:49 +00:00
pci_device.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
pci_device_pool.py [2/3]Replace six.iteritems() with .items() 2017-01-09 09:11:00 +00:00
quotas.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
request_spec.py Workaround missing RequestSpec.instance_group.uuid 2019-06-03 21:01:42 -04:00
security_group.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
security_group_rule.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
selection.py Move the to_dict() method to the Selection object 2017-12-07 15:01:09 +00:00
service.py Annotate flows and handle PortBindingDeletionFailed in ComputeManager 2018-07-19 09:09:55 -04:00
tag.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
task_log.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
trusted_certs.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
vcpu_model.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
virt_cpu_topology.py cleanup NovaObjectDictCompat from virt_cpu_topology 2015-08-05 08:56:30 +05:30
virt_device_metadata.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
virtual_interface.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
volume_usage.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00