]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fix placement when existing + specified don't overlap 33766/head
authorSage Weil <sage@redhat.com>
Thu, 5 Mar 2020 20:51:31 +0000 (14:51 -0600)
committerSage Weil <sage@redhat.com>
Thu, 5 Mar 2020 20:51:39 +0000 (14:51 -0600)
If we have a daemon on A, and our spec is (count=2, hosts=[B]), we should
always return [A,B], but we sometimes were returning [B,B].

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_scheduling.py

index 40c6ea38c3ab31566d32f932d1ad87ba0c89c37b..3bc90902ccde880b679496ae2edf19601b092bca 100644 (file)
@@ -3036,8 +3036,11 @@ class HostAssignment(object):
         # prefer hosts that already have services
         daemons = self.get_daemons_func(self.service_name)
         hosts_with_daemons = {d.hostname for d in daemons}
+        # calc existing daemons (that aren't already in chosen)
+        chosen_hosts = [hs.hostname for hs in chosen]
         existing = [hs for hs in hosts
-                    if hs.hostname in hosts_with_daemons]
+                    if hs.hostname in hosts_with_daemons and \
+                    hs.hostname not in chosen_hosts]
         if len(chosen + existing) >= self.spec.placement.count:
             chosen = chosen + self.scheduler.place(
                 existing,
index 9873233a6ed5206e1c553b1d41ca4fca54f479b3..b00bf365fcc6368de093c629984fee539d0cca03 100644 (file)
@@ -54,6 +54,26 @@ class NodeAssignmentTest(NamedTuple):
             ],
             ['host1', 'host3']
         ),
+        # count + partial host list + existing (deterministic)
+        NodeAssignmentTest(
+            'mon',
+            PlacementSpec(count=2, hosts=['host1']),
+            'host1 host2'.split(),
+            [
+                DaemonDescription('mon', 'a', 'host1'),
+            ],
+            ['host1', 'host2']
+        ),
+        # count + partial host list + existing (deterministic)
+        NodeAssignmentTest(
+            'mon',
+            PlacementSpec(count=2, hosts=['host1']),
+            'host1 host2'.split(),
+            [
+                DaemonDescription('mon', 'a', 'host2'),
+            ],
+            ['host1', 'host2']
+        ),
         # label only
         NodeAssignmentTest(
             'mon',