]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: Bail if we cannot find a host for services 33205/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 11 Feb 2020 12:22:49 +0000 (13:22 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 11 Feb 2020 16:55:08 +0000 (17:55 +0100)
This would require tricky manipulation of ports etc.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 9c32b2fe4ff4bf863b5c065cf1f378735633865c..442da3a5164fe092753888ad244a7c176e287f8e 100644 (file)
@@ -1776,6 +1776,12 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             )
             daemons.append(sd)
             num_added += 1
+
+        if (len(our_daemons) + num_added) < spec.count:
+            missing = spec.count - len(our_daemons) - num_added
+            available = [p.hostname for p in hosts_without_daemons]
+            m = f'Cannot find placement for {missing} daemons. available hosts = {available}'
+            raise orchestrator.OrchestratorError(m)
         return create_func(args)
 
 
index d7399667c88d4f13622f7b5e627d88ace3bfe950..e4a02a170c27c8e90640bfb6b9b4c76301fc1492 100644 (file)
@@ -2,6 +2,8 @@ import json
 from contextlib import contextmanager
 import fnmatch
 
+import pytest
+
 from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection
 
 try:
@@ -10,7 +12,7 @@ except ImportError:
     pass
 
 from orchestrator import ServiceDescription, InventoryNode, \
-    ServiceSpec, PlacementSpec, RGWSpec, HostSpec
+    ServiceSpec, PlacementSpec, RGWSpec, HostSpec, OrchestratorError
 from tests import mock
 from .fixtures import cephadm_module, wait
 
@@ -186,15 +188,37 @@ class TestCephadm(object):
         with self._with_host(cephadm_module, 'host1'):
             with self._with_host(cephadm_module, 'host2'):
                 ps = PlacementSpec(hosts=['host1'], count=1)
-                c = cephadm_module.add_rgw(RGWSpec('realm', 'zone', placement=ps))
+                c = cephadm_module.add_rgw(RGWSpec('realm', 'zone1', placement=ps))
                 [out] = wait(cephadm_module, c)
-                match_glob(out, "Deployed rgw.realm.zone.host1.* on host 'host1'")
-
+                match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'")
 
                 ps = PlacementSpec(hosts=['host1', 'host2'], count=2)
-                c = cephadm_module.update_rgw(RGWSpec('realm', 'zone', placement=ps))
+                c = cephadm_module.update_rgw(RGWSpec('realm', 'zone1', placement=ps))
                 [out] = wait(cephadm_module, c)
-                match_glob(out, "Deployed rgw.realm.zone.host2.* on host 'host2'")
+                match_glob(out, "Deployed rgw.realm.zone1.host2.* on host 'host2'")
+
+    @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}'))
+    @mock.patch("cephadm.module.CephadmOrchestrator.send_command")
+    @mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command)
+    @mock.patch("cephadm.module.CephadmOrchestrator._get_connection")
+    def test_rgw_update_fail(self, _send_command, _get_connection, cephadm_module):
+
+        with self._with_host(cephadm_module, 'host1'):
+            with self._with_host(cephadm_module, 'host2'):
+                ps = PlacementSpec(hosts=['host1'], count=1)
+                c = cephadm_module.add_rgw(RGWSpec('realm', 'zone1', placement=ps))
+                [out] = wait(cephadm_module, c)
+                match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'")
+
+                ps = PlacementSpec(hosts=['host2'], count=1)
+                c = cephadm_module.add_rgw(RGWSpec('realm', 'zone2', placement=ps))
+                [out] = wait(cephadm_module, c)
+                match_glob(out, "Deployed rgw.realm.zone2.host2.* on host 'host2'")
+
+                with pytest.raises(OrchestratorError):
+                    ps = PlacementSpec(hosts=['host1', 'host2'], count=2)
+                    c = cephadm_module.update_rgw(RGWSpec('realm', 'zone1', placement=ps))
+                    [out] = wait(cephadm_module, c)
 
 
     @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm(