Skip to content
Snippets Groups Projects
Commit ace16501 authored by Guido Trotter's avatar Guido Trotter
Browse files

Check for duplicate nodegroup names


Since the nodegroups dict is indexed by uuid duplicate names might
happen as a result of bugs. Add a check to prevent them.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent c60abd62
No related branches found
No related tags found
No related merge requests found
...@@ -462,11 +462,16 @@ class ConfigWriter: ...@@ -462,11 +462,16 @@ class ConfigWriter:
node.offline)) node.offline))
# nodegroups checks # nodegroups checks
nodegroups_names = set()
for nodegroup_uuid in data.nodegroups: for nodegroup_uuid in data.nodegroups:
nodegroup = data.nodegroups[nodegroup_uuid] nodegroup = data.nodegroups[nodegroup_uuid]
if nodegroup.uuid != nodegroup_uuid: if nodegroup.uuid != nodegroup_uuid:
result.append("nodegroup '%s' (uuid: '%s') indexed by wrong uuid '%s'" result.append("nodegroup '%s' (uuid: '%s') indexed by wrong uuid '%s'"
% (nodegroup.name, nodegroup.uuid, nodegroup_uuid)) % (nodegroup.name, nodegroup.uuid, nodegroup_uuid))
if nodegroup.name in nodegroups_names:
result.append("duplicate nodegroup name '%s'" % nodegroup.name)
else:
nodegroups_names.add(nodegroup.name)
# drbd minors check # drbd minors check
_, duplicates = self._UnlockedComputeDRBDMap() _, duplicates = self._UnlockedComputeDRBDMap()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment