diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 2aba269270fc6227c0bb5e657ebfb1209257c93d..edc91358ce2e85e517298f808b5fb2a0b6af9fcc 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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" % + self.op.group_name, errors.ECODE_STATE) def BuildHooksEnv(self): diff --git a/lib/config.py b/lib/config.py index 76e6b59dd8aee87dfd6befbf19c48e9f3047950e..6cec7c4ac5a210933cbb2b0ef7a0f2407a6e24bd 100644 --- a/lib/config.py +++ b/lib/config.py @@ -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 self._WriteConfig()