From c45f8f5bd51824994bf2039c8a45b32c29cc7edf Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 9 Oct 2021 17:51:45 -0400 Subject: [PATCH] Have VXNetworkInstance set MTU if unset Makes this explicit in Zookeeper if a network is unset, post-migration (schema version 6). Addresses #144 --- .../pvcnoded/objects/VXNetworkInstance.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/node-daemon/pvcnoded/objects/VXNetworkInstance.py b/node-daemon/pvcnoded/objects/VXNetworkInstance.py index 474b8ad6..fc2752a8 100644 --- a/node-daemon/pvcnoded/objects/VXNetworkInstance.py +++ b/node-daemon/pvcnoded/objects/VXNetworkInstance.py @@ -80,10 +80,19 @@ class VXNetworkInstance(object): try: self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni)) - if self.vx_mtu == '' or self.vx_mtu is None: - raise except Exception: + self.vx_mtu = None + + # Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists) + if self.vx_mtu == '' or self.vx_mtu is None: self.vx_mtu = self.max_mtu + # Try block for migration purposes + try: + self.zkhandler.write([ + (('network.mtu', self.vni), self.vx_mtu) + ]) + except Exception: + pass # Zookeper handlers for changed states @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network', self.vni)) @@ -97,6 +106,7 @@ class VXNetworkInstance(object): self.old_description = self.description self.description = data.decode('ascii') + # Try block for migration purposes try: @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni)) def watch_network_mtu(data, stat, event=''): @@ -132,10 +142,19 @@ class VXNetworkInstance(object): try: self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni)) - if self.vx_mtu == '' or self.vx_mtu is None: - raise except Exception: + self.vx_mtu = None + + # Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists) + if self.vx_mtu == '' or self.vx_mtu is None: self.vx_mtu = self.max_mtu + try: + # Try block for migration purposes + self.zkhandler.write([ + (('network.mtu', self.vni), self.vx_mtu) + ]) + except Exception: + pass self.nftables_netconf_filename = '{}/networks/{}.nft'.format(self.config['nft_dynamic_directory'], self.vni) self.firewall_rules = [] @@ -241,6 +260,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out self.stopDHCPServer() self.startDHCPServer() + # Try block for migration purposes try: @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni)) def watch_network_mtu(data, stat, event=''):