From 8dd66211b7e0ed6bda336ab89533352901d26f85 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 75ed0278..b4a3ab80 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -1139,11 +1139,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'] @@ -1156,7 +1158,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: