From c2aa72122d811180ae8c8f7f4fcb19a251024528 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Fri, 29 Apr 2022 14:25:53 +0800 Subject: [PATCH] ovs: Do not validate on non-desired interface Currently nmstate is showing unmanaged ovs vxlan with empty parent which failure the apply() even it is not mentioned in desire state. The fix is skip all the validations on non-desired interfaces. Integration test case included. Signed-off-by: Gris Ge --- libnmstate/ifaces/ifaces.py | 14 ++++++++++---- tests/integration/ovs_test.py | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/libnmstate/ifaces/ifaces.py b/libnmstate/ifaces/ifaces.py index c2a5d3c4..c2f9bfa9 100644 --- a/libnmstate/ifaces/ifaces.py +++ b/libnmstate/ifaces/ifaces.py @@ -159,7 +159,8 @@ class Ifaces: self._apply_copy_mac_from() self.gen_metadata() for iface in self.all_ifaces(): - iface.pre_edit_validation_and_cleanup() + if iface.is_desired and iface.is_up: + iface.pre_edit_validation_and_cleanup() self._pre_edit_validation_and_cleanup() @@ -293,7 +294,11 @@ class Ifaces: When OVS patch peer does not exist or is down, raise an error. """ for iface in self._kernel_ifaces.values(): - if iface.type == InterfaceType.OVS_INTERFACE and iface.is_up: + if ( + iface.type == InterfaceType.OVS_INTERFACE + and iface.is_up + and iface.is_desired + ): if iface.peer: peer_iface = self._kernel_ifaces.get(iface.peer) if not peer_iface or not peer_iface.is_up: @@ -315,9 +320,9 @@ class Ifaces: Validate that vlan is not being created over infiniband interface """ for iface in self._kernel_ifaces.values(): - if ( iface.type in [InterfaceType.VLAN, InterfaceType.VXLAN] + and iface.is_desired and iface.is_up ): if ( @@ -338,9 +343,9 @@ class Ifaces: If base MTU is not present, set same as vlan MTU """ for iface in self._kernel_ifaces.values(): - if ( iface.type in [InterfaceType.VLAN, InterfaceType.VXLAN] + and iface.is_desired and iface.is_up and iface.mtu ): @@ -423,6 +428,7 @@ class Ifaces: for ifname, iface in self._kernel_ifaces.items(): if ( iface.type == InterfaceType.VETH + and iface.is_desired and iface.is_up and not iface.peer ): -- 2.35.1