From d0d546ce8e18adb0eeb9f3aa502e726be7979582 Mon Sep 17 00:00:00 2001 From: Huan Xie Date: Sun, 7 May 2017 22:38:00 -0700 Subject: [PATCH] XenAPI: Deprecate nicira-iface-id for XenServer VIF When using neutron polling mode, booting a VM will timeout because cannot receive network-vif-plugged event. After investigation we found we set vif['id'](i.e. neutron port uuid from neutron's perspective of view) to two different OVS ports. One is the Xenserver VIF, the other is tap device qvo-XXXX which neutron ovs agent will monitor and deal with. This patch is to deprecate the setting of 'nicira-iface-id' to XenServer VIF (which will result in 'iface-id' in ovsdb) and use 'neutron-port-id'. Note: There is no problem if we don't use neutron-ovs-agent polling mode Change-Id: I878602b5a84106634a211735c0002580293e3c06 --- nova/tests/unit/virt/xenapi/test_vif.py | 6 ++++-- nova/tests/unit/virt/xenapi/test_vmops.py | 8 ++++---- nova/virt/xenapi/vif.py | 12 ++++++------ nova/virt/xenapi/vmops.py | 2 +- ...icira-iface-id-in-xenserver-dc3c147aef1bc2c8.yaml | 8 ++++++++ 5 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/deprecate-nicira-iface-id-in-xenserver-dc3c147aef1bc2c8.yaml diff --git a/nova/tests/unit/virt/xenapi/test_vif.py b/nova/tests/unit/virt/xenapi/test_vif.py index 377c9a852c08..64104b96bd21 100644 --- a/nova/tests/unit/virt/xenapi/test_vif.py +++ b/nova/tests/unit/virt/xenapi/test_vif.py @@ -279,7 +279,8 @@ class XenAPIOpenVswitchDriverTestCase(XenVIFDriverTestBase): 'MAC': fake_vif['address'], 'network': 'fake_network', 'other_config': { - 'nicira-iface-id': 'fake-nicira-iface-id'} + 'nicira-iface-id': 'fake-nicira-iface-id', + 'neutron-port-id': 'fake-neutron-port-id'} } mock_VIF_get_record = self.mock_patch_object( self._session.VIF, 'get_record', return_val=fake_vif_rec) @@ -312,7 +313,8 @@ class XenAPIOpenVswitchDriverTestCase(XenVIFDriverTestBase): 'MAC': fake_vif['address'], 'network': 'fake_network', 'other_config': { - 'nicira-iface-id': 'fake-nicira-iface-id'} + 'nicira-iface-id': 'fake-nicira-iface-id', + 'neutron-port-id': 'fake-neutron-port-id'} } mock_VIF_get_record = self.mock_patch_object( self._session.VIF, 'get_record', return_val=fake_vif_rec) diff --git a/nova/tests/unit/virt/xenapi/test_vmops.py b/nova/tests/unit/virt/xenapi/test_vmops.py index 6f8b4c503fec..0ff4d434b937 100644 --- a/nova/tests/unit/virt/xenapi/test_vmops.py +++ b/nova/tests/unit/virt/xenapi/test_vmops.py @@ -1636,8 +1636,8 @@ class LiveMigrateHelperTestCase(VMOpsTestBase): 'get_other_config') as mock_other_config, \ mock.patch.object(self._session.VM, 'get_VIFs') as mock_get_vif: - mock_other_config.side_effect = [{'nicira-iface-id': 'vif_id_a'}, - {'nicira-iface-id': 'vif_id_b'}] + mock_other_config.side_effect = [{'neutron-port-id': 'vif_id_a'}, + {'neutron-port-id': 'vif_id_b'}] mock_get_vif.return_value = ['vif_ref1', 'vif_ref2'] vif_uuid_map = {'vif_id_b': 'dest_net_ref2', 'vif_id_a': 'dest_net_ref1'} @@ -1666,8 +1666,8 @@ class LiveMigrateHelperTestCase(VMOpsTestBase): 'get_other_config') as mock_other_config, \ mock.patch.object(self._session.VM, 'get_VIFs') as mock_get_vif: - mock_other_config.side_effect = [{'nicira-iface-id': 'vif_id_a'}, - {'nicira-iface-id': 'vif_id_b'}] + mock_other_config.side_effect = [{'neutron-port-id': 'vif_id_a'}, + {'neutron-port-id': 'vif_id_b'}] mock_get_vif.return_value = ['vif_ref1', 'vif_ref2'] vif_uuid_map = {'vif_id_c': 'dest_net_ref2', 'vif_id_d': 'dest_net_ref1'} diff --git a/nova/virt/xenapi/vif.py b/nova/virt/xenapi/vif.py index 653386478dca..e42aefb850d3 100644 --- a/nova/virt/xenapi/vif.py +++ b/nova/virt/xenapi/vif.py @@ -268,9 +268,9 @@ class XenAPIOpenVswitchDriver(XenVIFDriver): vif_rec['MTU'] = '1500' vif_rec['qos_algorithm_type'] = '' vif_rec['qos_algorithm_params'] = {} - # OVS on the hypervisor monitors this key and uses it to - # set the iface-id attribute - vif_rec['other_config'] = {'nicira-iface-id': vif['id']} + # Deprecated: 'niciria-iface-id', will remove it in the next release + vif_rec['other_config'] = {'nicira-iface-id': vif['id'], + 'neutron-port-id': vif['id']} vif_ref = self._create_vif(vif, vif_rec, vm_ref) # call XenAPI to plug vif @@ -421,7 +421,7 @@ class XenAPIOpenVswitchDriver(XenVIFDriver): def _create_linux_bridge(self, vif_rec): """create a qbr linux bridge for neutron security group """ - iface_id = vif_rec['other_config']['nicira-iface-id'] + iface_id = vif_rec['other_config']['neutron-port-id'] linux_br_name = self._get_qbr_name(iface_id) if not self._device_exists(linux_br_name): LOG.debug("Create linux bridge %s", linux_br_name) @@ -468,7 +468,7 @@ class XenAPIOpenVswitchDriver(XenVIFDriver): network_ref = vif_rec['network'] bridge_name = self._session.network.get_bridge(network_ref) network_uuid = self._session.network.get_uuid(network_ref) - iface_id = vif_rec['other_config']['nicira-iface-id'] + iface_id = vif_rec['other_config']['neutron-port-id'] patch_port1, tap_name = self._get_patch_port_pair_names(iface_id) LOG.debug('plug_ovs_bridge: port1=%(port1)s, port2=%(port2)s,' 'network_uuid=%(uuid)s, bridge_name=%(bridge_name)s', @@ -546,7 +546,7 @@ class XenAPIOpenVswitchDriver(XenVIFDriver): '''set external ids on the integration bridge vif ''' mac = vif_rec['MAC'] - iface_id = vif_rec['other_config']['nicira-iface-id'] + iface_id = vif_rec['other_config']['neutron-port-id'] vif_uuid = vif_rec['uuid'] status = 'active' diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 5418309f8d45..514a9a73883b 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -2383,7 +2383,7 @@ class VMOps(object): default_net_ref = vif_uuid_map.get('') for vif in vifs: other_config = self._session.VIF.get_other_config(vif) - neutron_id = other_config.get('nicira-iface-id') + neutron_id = other_config.get('neutron-port-id') network_ref = vif_uuid_map.get(neutron_id, default_net_ref) if network_ref is None: raise exception.MigrationError( diff --git a/releasenotes/notes/deprecate-nicira-iface-id-in-xenserver-dc3c147aef1bc2c8.yaml b/releasenotes/notes/deprecate-nicira-iface-id-in-xenserver-dc3c147aef1bc2c8.yaml new file mode 100644 index 000000000000..5657236016fc --- /dev/null +++ b/releasenotes/notes/deprecate-nicira-iface-id-in-xenserver-dc3c147aef1bc2c8.yaml @@ -0,0 +1,8 @@ +--- +deprecations: + - | + When using neutron polling mode with XenAPI driver, booting a VM will + timeout because ``nova-compute`` cannot receive network-vif-plugged event. + This is because it set vif['id'](i.e. neutron port uuid) to two different + OVS ports. One is XenServer VIF, the other is tap device qvo-XXXX, but + setting 'nicira-iface-id' to XenServer VIF isn't correct, so deprecate it.