From 20c8466296561e27215772bfd9b009111c873808 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 4 Feb 2020 17:35:24 -0500 Subject: [PATCH] Handle invalid search fields better --- node-daemon/pvcd/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node-daemon/pvcd/common.py b/node-daemon/pvcd/common.py index 215c6b1b..b5621257 100644 --- a/node-daemon/pvcd/common.py +++ b/node-daemon/pvcd/common.py @@ -148,10 +148,14 @@ def findTargetNode(zk_conn, config, dom_uuid): node_limit = '' zkhandler.writedata(zk_conn, { '/domains/{}/node_limit'.format(dom_uuid): '' }) - # Determine VM search field or use default; set config value if read fails + # Determine VM search field try: search_field = zkhandler.readdata(zk_conn, '/domains/{}/node_selector'.format(dom_uuid)) - except: + except Exception as e: + search_field = None + + # If our search field is invalid, use and set the default (for next time) + if search_field is None or search_field == 'None': search_field = config['migration_target_selector'] zkhandler.writedata(zk_conn, { '/domains/{}/node_selector'.format(dom_uuid): config['migration_target_selector'] })