Commit 0389c42a authored by Stephen Shirley's avatar Stephen Shirley Committed by Iustin Pop
Browse files

Prevent removal of last node group

- Add check in ConfigWriter to prevent last node group from being
- Tidy up error message a bit
Signed-off-by: default avatarStephen Shirley <>
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarIustin Pop <>
parent e431074f
......@@ -10359,9 +10359,9 @@ class LUGroupRemove(LogicalUnit):
# Verify the cluster would not be left group-less.
if len(self.cfg.GetNodeGroupList()) == 1:
raise errors.OpPrereqError("Group '%s' is the last group in the cluster,"
" which cannot be left without at least one"
" group" % self.op.group_name,
raise errors.OpPrereqError("Group '%s' is the only group,"
" cannot be removed" %
def BuildHooksEnv(self):
......@@ -916,6 +916,9 @@ class ConfigWriter:
if group_uuid not in self._config_data.nodegroups:
raise errors.ConfigurationError("Unknown node group '%s'" % group_uuid)
assert len(self._config_data.nodegroups) != 1, \
"Group '%s' is the only group, cannot be removed" % group_uuid
del self._config_data.nodegroups[group_uuid]
self._config_data.cluster.serial_no += 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment