|
|
245567 |
From fb2f233d5156a3516b309336a310570c368c7a89 Mon Sep 17 00:00:00 2001
|
|
|
245567 |
From: Miguel Duarte Barroso <mdbarroso@redhat.com>
|
|
|
245567 |
Date: Thu, 22 Aug 2019 10:39:10 +0200
|
|
|
245567 |
Subject: [PATCH] nm.applier: Prioritize master interfaces activaction
|
|
|
245567 |
|
|
|
245567 |
The master interfaces - that are not slaves themselves - must be
|
|
|
245567 |
activated first, otherwise NetworkManager fails with errors such
|
|
|
245567 |
as:
|
|
|
245567 |
|
|
|
245567 |
"""
|
|
|
245567 |
NetworkManager[858]: <debug>
|
|
|
245567 |
[1565960861.2223] manager: Activation of <slave> requires master
|
|
|
245567 |
device <master device>
|
|
|
245567 |
"""
|
|
|
245567 |
|
|
|
245567 |
The supplied test fails roughly >= 50% of the times without this
|
|
|
245567 |
patch - it all comes to the timing.
|
|
|
245567 |
|
|
|
245567 |
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
|
|
|
245567 |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
245567 |
---
|
|
|
245567 |
libnmstate/nm/applier.py | 25 ++++++++++++++++++++++---
|
|
|
245567 |
1 file changed, 22 insertions(+), 3 deletions(-)
|
|
|
245567 |
|
|
|
245567 |
diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py
|
|
|
245567 |
index 750ca3d..974460b 100644
|
|
|
245567 |
--- a/libnmstate/nm/applier.py
|
|
|
245567 |
+++ b/libnmstate/nm/applier.py
|
|
|
245567 |
@@ -41,6 +41,7 @@ from . import wired
|
|
|
245567 |
|
|
|
245567 |
MASTER_METADATA = '_master'
|
|
|
245567 |
MASTER_TYPE_METADATA = '_master_type'
|
|
|
245567 |
+MASTER_IFACE_TYPES = ovs.BRIDGE_TYPE, bond.BOND_TYPE, LB.TYPE
|
|
|
245567 |
|
|
|
245567 |
BRPORT_OPTIONS_METADATA = '_brport_options'
|
|
|
245567 |
|
|
|
245567 |
@@ -111,6 +112,7 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
|
|
|
245567 |
leaving it to choose the correct profile.
|
|
|
245567 |
|
|
|
245567 |
In order to activate correctly the interfaces, the order is significant:
|
|
|
245567 |
+ - Master-less master interfaces.
|
|
|
245567 |
- New interfaces (virtual interfaces, but not OVS ones).
|
|
|
245567 |
- Master interfaces.
|
|
|
245567 |
- OVS ports.
|
|
|
245567 |
@@ -123,6 +125,7 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
|
|
|
245567 |
new_vlan_ifaces_to_activate = set()
|
|
|
245567 |
new_ovs_interface_to_activate = set()
|
|
|
245567 |
new_ovs_port_to_activate = set()
|
|
|
245567 |
+ new_master_not_enslaved_ifaces = set()
|
|
|
245567 |
master_ifaces_to_edit = set()
|
|
|
245567 |
ifaces_to_edit = set()
|
|
|
245567 |
remove_devs_actions = {}
|
|
|
245567 |
@@ -132,7 +135,13 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
|
|
|
245567 |
nmdev = device.get_device_by_name(ifname)
|
|
|
245567 |
if not nmdev:
|
|
|
245567 |
if ifname in new_ifaces and iface_desired_state['state'] == 'up':
|
|
|
245567 |
- if iface_desired_state['type'] == ovs.INTERNAL_INTERFACE_TYPE:
|
|
|
245567 |
+ if _is_master_iface(
|
|
|
245567 |
+ iface_desired_state
|
|
|
245567 |
+ ) and not _is_slave_iface(iface_desired_state):
|
|
|
245567 |
+ new_master_not_enslaved_ifaces.add(ifname)
|
|
|
245567 |
+ elif (
|
|
|
245567 |
+ iface_desired_state['type'] == ovs.INTERNAL_INTERFACE_TYPE
|
|
|
245567 |
+ ):
|
|
|
245567 |
new_ovs_interface_to_activate.add(ifname)
|
|
|
245567 |
elif iface_desired_state['type'] == ovs.PORT_TYPE:
|
|
|
245567 |
new_ovs_port_to_activate.add(ifname)
|
|
|
245567 |
@@ -142,8 +151,7 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
|
|
|
245567 |
new_ifaces_to_activate.add(ifname)
|
|
|
245567 |
else:
|
|
|
245567 |
if iface_desired_state['state'] == 'up':
|
|
|
245567 |
- master_iface_types = ovs.BRIDGE_TYPE, bond.BOND_TYPE, LB.TYPE
|
|
|
245567 |
- if iface_desired_state['type'] in master_iface_types:
|
|
|
245567 |
+ if _is_master_iface(iface_desired_state):
|
|
|
245567 |
master_ifaces_to_edit.add(
|
|
|
245567 |
(nmdev, con_profiles_by_devname[ifname].profile)
|
|
|
245567 |
)
|
|
|
245567 |
@@ -176,6 +184,9 @@ def set_ifaces_admin_state(ifaces_desired_state, con_profiles=()):
|
|
|
245567 |
for dev, _ in itertools.chain(master_ifaces_to_edit, ifaces_to_edit):
|
|
|
245567 |
remove_devs_actions.pop(dev, None)
|
|
|
245567 |
|
|
|
245567 |
+ for ifname in new_master_not_enslaved_ifaces:
|
|
|
245567 |
+ device.activate(dev=None, connection_id=ifname)
|
|
|
245567 |
+
|
|
|
245567 |
for ifname in new_ifaces_to_activate:
|
|
|
245567 |
device.activate(dev=None, connection_id=ifname)
|
|
|
245567 |
|
|
|
245567 |
@@ -213,6 +224,14 @@ def _get_new_ifaces(con_profiles):
|
|
|
245567 |
return ifaces_without_device
|
|
|
245567 |
|
|
|
245567 |
|
|
|
245567 |
+def _is_master_iface(iface_state):
|
|
|
245567 |
+ return iface_state[Interface.TYPE] in MASTER_IFACE_TYPES
|
|
|
245567 |
+
|
|
|
245567 |
+
|
|
|
245567 |
+def _is_slave_iface(iface_state):
|
|
|
245567 |
+ return iface_state.get(MASTER_METADATA)
|
|
|
245567 |
+
|
|
|
245567 |
+
|
|
|
245567 |
def _get_affected_devices(iface_state):
|
|
|
245567 |
nmdev = device.get_device_by_name(iface_state['name'])
|
|
|
245567 |
devs = []
|
|
|
245567 |
--
|
|
|
245567 |
2.23.0
|
|
|
245567 |
|