Handle upgrade of autohold held nodes

An earlier change alters the autohold held node IDs from a list
to a dict structure. If someone upgrades to this change, but has
existing autoholds with the old format, we will break them. This
change handles both cases.

Change-Id: Ib6381e459a9694cae61ba3229d48ddfe8f55f392
This commit is contained in:
David Shrewsbury 2019-10-25 08:49:40 -04:00
parent 81e3508938
commit fdbabc863c
1 changed files with 9 additions and 1 deletions

View File

@ -592,7 +592,15 @@ class ZooKeeper(object):
def getHeldNodeIDs(request):
node_ids = []
for data in request.nodes:
node_ids += data['nodes']
# TODO(Shrews): Remove type check at some point.
# When autoholds were initially changed to be stored in ZK,
# the node IDs were originally stored as a list of strings.
# A later change embedded them within a dict. Handle both
# cases here to deal with the upgrade.
if isinstance(data, dict):
node_ids += data['nodes']
else:
node_ids.append(data)
return node_ids
failure = False