From dc2d671aeb0336bb7529b7d0ff29476e5107d352 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 23 Feb 2020 13:38:25 -0600 Subject: [PATCH] mgr/cephadm: fix get_unique_name when name in use If we are not adding a uniqueifying suffix, we need to error out instead of looping. Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 10f489b00d4c..fa8da4b333a7 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -982,7 +982,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): ] if forcename: if len([d for d in existing if d.daemon_id == forcename]): - raise RuntimeError('specified name %s already in use', forcename) + raise orchestrator.OrchestratorValidationError('name %s already in use', forcename) return forcename if '.' in host: @@ -997,6 +997,8 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): name += '.' + ''.join(random.choice(string.ascii_lowercase) for _ in range(6)) if len([d for d in existing if d.daemon_id == name]): + if not suffix: + raise orchestrator.OrchestratorValidationError('name %s already in use', name) self.log.warning('name %s exists, trying again', name) continue return name -- 2.47.3