From 61f793040e6eb1a95b086ee9331a6b0a4bc9d2bb Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 6 Oct 2020 17:14:20 -0400 Subject: [PATCH] Avoid setting uuid and mac in pxe if already set Notably the uuid change can end up recursing. Fix the behavior that will cause never ending loops, which in some IO situations can end in recursion limits. --- confluent_server/confluent/discovery/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 9d436427..65986a8e 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -1129,11 +1129,13 @@ def do_pxe_discovery(cfg, handler, info, manual, nodename, policies): # use uuid based scheme in lieu of tls cert, ideally only # for stateless 'discovery' targets like pxe, where data does not # change - uuidinfo = cfg.get_node_attributes(nodename, ['id.uuid', 'id.serial', 'id.model', 'net*.bootable']) + uuidinfo = cfg.get_node_attributes(nodename, ['id.uuid', 'id.serial', 'id.model', 'net*.hwaddr', 'net*.bootable']) if manual or policies & set(('open', 'pxe')): enrich_pxe_info(info) attribs = {} olduuid = uuidinfo.get(nodename, {}).get('id.uuid', None) + if isinstance(olduuid, dict): + olduuid = olduuid.get('value', None) uuid = info.get('uuid', None) if uuid and uuid != olduuid: attribs['id.uuid'] = info['uuid'] @@ -1146,7 +1148,9 @@ def do_pxe_discovery(cfg, handler, info, manual, nodename, policies): for attrname in uuidinfo.get(nodename, {}): if attrname.endswith('.bootable') and uuidinfo[nodename][attrname].get('value', None): newattrname = attrname[:-8] + 'hwaddr' - attribs[newattrname] = info['hwaddr'] + oldhwaddr = uuidinfo.get(nodename, {}).get(newattrname, {}).get('value', None) + if info['hwaddr'] != oldhwaddr: + attribs[newattrname] = info['hwaddr'] if attribs: cfg.set_node_attributes({nodename: attribs}) if info['uuid'] in known_pxe_uuids: