Fix migration bugs and invalid vx_mtu

Addresses #144
This commit is contained in:
Joshua Boniface 2021-10-09 17:35:10 -04:00
parent 50d8aa0586
commit 3690a2c1e0
1 changed files with 26 additions and 20 deletions

View File

@ -80,7 +80,7 @@ class VXNetworkInstance(object):
try: try:
self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni)) self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni))
if self.vx_mtu == '': if self.vx_mtu == '' or self.vx_mtu is None:
raise raise
except Exception: except Exception:
self.vx_mtu = self.max_mtu self.vx_mtu = self.max_mtu
@ -97,16 +97,19 @@ class VXNetworkInstance(object):
self.old_description = self.description self.old_description = self.description
self.description = data.decode('ascii') self.description = data.decode('ascii')
@self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni)) try:
def watch_network_mtu(data, stat, event=''): @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni))
if event and event.type == 'DELETED': def watch_network_mtu(data, stat, event=''):
# The key has been deleted after existing before; terminate this watcher if event and event.type == 'DELETED':
# because this class instance is about to be reaped in Daemon.py # The key has been deleted after existing before; terminate this watcher
return False # because this class instance is about to be reaped in Daemon.py
return False
if data and self.vx_mtu != data.decode('ascii'): if data and self.vx_mtu != data.decode('ascii'):
self.vx_mtu = data.decode('ascii') self.vx_mtu = data.decode('ascii')
self.updateNetworkMTU() self.updateNetworkMTU()
except Exception:
pass
self.createNetworkBridged() self.createNetworkBridged()
@ -129,7 +132,7 @@ class VXNetworkInstance(object):
try: try:
self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni)) self.vx_mtu = self.zkhandler.read(('network.mtu', self.vni))
if self.vx_mtu == '': if self.vx_mtu == '' or self.vx_mtu is None:
raise raise
except Exception: except Exception:
self.vx_mtu = self.max_mtu self.vx_mtu = self.max_mtu
@ -238,16 +241,19 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
self.stopDHCPServer() self.stopDHCPServer()
self.startDHCPServer() self.startDHCPServer()
@self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni)) try:
def watch_network_mtu(data, stat, event=''): @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.mtu', self.vni))
if event and event.type == 'DELETED': def watch_network_mtu(data, stat, event=''):
# The key has been deleted after existing before; terminate this watcher if event and event.type == 'DELETED':
# because this class instance is about to be reaped in Daemon.py # The key has been deleted after existing before; terminate this watcher
return False # because this class instance is about to be reaped in Daemon.py
return False
if data and self.vx_mtu != data.decode('ascii'): if data and self.vx_mtu != data.decode('ascii'):
self.vx_mtu = data.decode('ascii') self.vx_mtu = data.decode('ascii')
self.updateNetworkMTU() self.updateNetworkMTU()
except Exception:
pass
@self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.ip6.network', self.vni)) @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('network.ip6.network', self.vni))
def watch_network_ip6_network(data, stat, event=''): def watch_network_ip6_network(data, stat, event=''):