From 5607a6bb62acf21fbe31c74c982a0b144ed92c9e Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 17 Jun 2021 01:45:22 -0400 Subject: [PATCH] Avoid overwriting VF data Ensures that the configuration of a VF is not overwritten in Zookeeper on a node restart. The SRIOVVFInstance handlers were modified to start with None values, so that the DataWatch statements will always trigger updates to the live system interfaces on daemon startup, thus ensuring that the config stored in Zookeeper is applied to the system on startup (mostly relevant after a cold boot or if the API changes them during a daemon restart). --- node-daemon/pvcnoded/Daemon.py | 32 +++++++++++++------------ node-daemon/pvcnoded/SRIOVVFInstance.py | 19 ++++++++------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index 247ea38c..53a6decd 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -1121,21 +1121,23 @@ if enable_networking: # 'query_rss_en': False # } vfphy = '{}v{}'.format(pf, vf['vf']) - zkhandler.write([ - (('node.sriov.vf', myhostname, 'sriov_vf', vfphy), ''), - (('node.sriov.vf', myhostname, 'sriov_vf.pf', vfphy), pf), - (('node.sriov.vf', myhostname, 'sriov_vf.mtu', vfphy), mtu), - (('node.sriov.vf', myhostname, 'sriov_vf.mac', vfphy), vf['address']), - (('node.sriov.vf', myhostname, 'sriov_vf.config', vfphy), ''), - (('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_id', vfphy), vf['vlan_list'][0].get('vlan', '')), - (('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_qos', vfphy), vf['vlan_list'][0].get('qos', '')), - (('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_min', vfphy), vf['rate']['min_tx']), - (('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_max', vfphy), vf['rate']['max_tx']), - (('node.sriov.vf', myhostname, 'sriov_vf.config.spoof_check', vfphy), vf['spoofchk']), - (('node.sriov.vf', myhostname, 'sriov_vf.config.link_state', vfphy), vf['link_state']), - (('node.sriov.vf', myhostname, 'sriov_vf.config.trust', vfphy), vf['trust']), - (('node.sriov.vf', myhostname, 'sriov_vf.config.query_rss', vfphy), vf['query_rss_en']), - ]) + # Add the VF to Zookeeper if it does not yet exist + if not zkhandler.exists(('node.sriov.vf', myhostname, 'sriov_vf', vfphy)): + zkhandler.write([ + (('node.sriov.vf', myhostname, 'sriov_vf', vfphy), ''), + (('node.sriov.vf', myhostname, 'sriov_vf.pf', vfphy), pf), + (('node.sriov.vf', myhostname, 'sriov_vf.mtu', vfphy), mtu), + (('node.sriov.vf', myhostname, 'sriov_vf.mac', vfphy), vf['address']), + (('node.sriov.vf', myhostname, 'sriov_vf.config', vfphy), ''), + (('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_id', vfphy), vf['vlan_list'][0].get('vlan', '')), + (('node.sriov.vf', myhostname, 'sriov_vf.config.vlan_qos', vfphy), vf['vlan_list'][0].get('qos', '')), + (('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_min', vfphy), vf['rate']['min_tx']), + (('node.sriov.vf', myhostname, 'sriov_vf.config.tx_rate_max', vfphy), vf['rate']['max_tx']), + (('node.sriov.vf', myhostname, 'sriov_vf.config.spoof_check', vfphy), vf['spoofchk']), + (('node.sriov.vf', myhostname, 'sriov_vf.config.link_state', vfphy), vf['link_state']), + (('node.sriov.vf', myhostname, 'sriov_vf.config.trust', vfphy), vf['trust']), + (('node.sriov.vf', myhostname, 'sriov_vf.config.query_rss', vfphy), vf['query_rss_en']), + ]) # Append the device to the list of VFs sriov_vf_list.append(vfphy) diff --git a/node-daemon/pvcnoded/SRIOVVFInstance.py b/node-daemon/pvcnoded/SRIOVVFInstance.py index ea20dff8..f079ab91 100644 --- a/node-daemon/pvcnoded/SRIOVVFInstance.py +++ b/node-daemon/pvcnoded/SRIOVVFInstance.py @@ -43,16 +43,17 @@ class SRIOVVFInstance(object): self.mtu = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.mtu', self.vf)) self.vfid = self.vf.replace('{}v'.format(self.pf), '') - self.mac = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.mac', self.vf)) - self.vlan_id = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.vlan_id', self.vf)) - self.vlan_qos = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.vlan_qos', self.vf)) - self.tx_rate_min = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.tx_rate_min', self.vf)) - self.tx_rate_max = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.tx_rate_max', self.vf)) - self.spoof_check = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.spoof_check', self.vf)) - self.link_state = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.link_state', self.vf)) - self.trust = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.trust', self.vf)) - self.query_rss = self.zkhandler.read(('node.sriov.vf', self.myhostname, 'sriov_vf.config.query_rss', self.vf)) + # These properties are set via the DataWatch functions, to ensure they are configured on the system + self.mac = None + self.vlan_id = None + self.vlan_qos = None + self.tx_rate_min = None + self.tx_rate_max = None + self.spoof_check = None + self.link_state = None + self.trust = None + self.query_rss = None # Zookeeper handlers for changed configs @self.zkhandler.zk_conn.DataWatch(self.zkhandler.schema.path('node.sriov.vf', self.myhostname) + self.zkhandler.schema.path('sriov_vf.mac', self.vf))