]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: check spec host when adding osd 45217/head
authorRedouane Kachach <rkachach@redhat.com>
Wed, 2 Mar 2022 11:38:42 +0000 (12:38 +0100)
committerRedouane Kachach <rkachach@redhat.com>
Mon, 28 Mar 2022 08:30:27 +0000 (10:30 +0200)
Fixes: https://tracker.ceph.com/issues/47872
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator/module.py

index 0bba96b8c512e82bc6af6e9ca42e4cfca5bf453f..65f7d2443f44d62a40c9327313be9c894b62dcb2 100644 (file)
@@ -2208,6 +2208,10 @@ Then run the following:
 
     @handle_orch_error
     def create_osds(self, drive_group: DriveGroupSpec) -> str:
+        hosts: List[HostSpec] = self.inventory.all_specs()
+        filtered_hosts: List[str] = drive_group.placement.filter_matching_hostspecs(hosts)
+        if not filtered_hosts:
+            return "Invalid 'host:device' spec: host not found in cluster. Please check 'ceph orch host ls' for available hosts"
         return self.osd_service.create_from_spec(drive_group)
 
     def _preview_osdspecs(self,
index e0669ecf10e93a76f9b8f040bd2c23f0690acb3c..6ce21c6c433b8bcdf80b73d4661754d8a4c961ca 100644 (file)
@@ -811,6 +811,11 @@ class TestCephadm(object):
             c = cephadm_module.create_osds(dg)
             out = wait(cephadm_module, c)
             assert out == "Created no osd(s) on host test; already created?"
+            bad_dg = DriveGroupSpec(placement=PlacementSpec(host_pattern='invalid_hsot'),
+                                    data_devices=DeviceSelection(paths=['']))
+            c = cephadm_module.create_osds(bad_dg)
+            out = wait(cephadm_module, c)
+            assert "Invalid 'host:device' spec: host not found in cluster" in out
 
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}'))
     def test_create_noncollocated_osd(self, cephadm_module):
index f33ecd50d021c34ac1041cbd9a396cc744d25224..4ef15b1236506484c57d4f0b0addf1611ff96e52 100644 (file)
@@ -799,7 +799,7 @@ Usage:
                 method=method,
             )
         except (TypeError, KeyError, ValueError) as e:
-            msg = f"Invalid host:device spec: '{svc_arg}': {e}" + usage
+            msg = f"Invalid 'host:device' spec: '{svc_arg}': {e}" + usage
             return HandleCommandResult(-errno.EINVAL, stderr=msg)
 
         completion = self.create_osds(drive_group)