libvirt: Always delegate OVS plug to os-vif

In change I11fb5d3ada7f27b39c183157ea73c8b72b4e672e, we started
delegating plugging of OVS ports to os-vif to work around a number of
bugs. However, this was only introduced for live migration. Plugging is
still handled by libvirt for spawn. This results in an odd situation,
whereby an interface of type 'bridge' will be use when creating the
instance initially, only for this to change to 'ethernet' on live
migration. Resolve this by *always* delegating plugging to os-vif. This
is achieved by consistently setting the 'delegate_create' attribute of
'nova.network.model.VIF' to 'True', which will later get transformed to
the 'create_port' attribute of the 'os_vif.objects.vif.VIFOpenVSwitch'
object(s) created in 'nova.network.os_vif_util._nova_to_osvif_vif_ovs'
and ultimately result in delegate port creation.

Note that we don't need to worry about making the setting of
'delegate_create' conditional on whether we're looking at an OVS port or
not: this will be handled by '_nova_to_osvif_vif_ovs'. We also don't
need to worry about unsetting this attribute before a live migration:
the 'delegate_create' attribute is always overridden as part of
'nova.objects.migrate_data.VIFMigrateData.get_dest_vif'.

Change-Id: I014c5a81752f86c6b99d19d769c42f318e18e676
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Related-Bug: #1734320
Related-Bug: #1815989
This commit is contained in:
Stephen Finucane 2021-06-22 11:37:22 +01:00
parent 99cf5292c7
commit fa0fb2fe3d
2 changed files with 3 additions and 1 deletions

View File

@ -3075,7 +3075,8 @@ class API(base.Base):
ovs_interfaceid=ovs_interfaceid,
devname=devname,
active=vif_active,
preserve_on_delete=preserve_on_delete
preserve_on_delete=preserve_on_delete,
delegate_create=True,
)
def _build_network_info_model(self, context, instance, networks=None,

View File

@ -3271,6 +3271,7 @@ class TestAPI(TestAPIBase):
requested_ports[index].get(
constants.BINDING_PROFILE) or {},
nw_info.get('profile'))
self.assertTrue(nw_info.get('delegate_create'))
index += 1
self.assertFalse(nw_infos[0]['active'])