]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: allow count == 0
authorSage Weil <sage@redhat.com>
Sun, 8 Mar 2020 17:01:09 +0000 (12:01 -0500)
committerSage Weil <sage@redhat.com>
Sun, 8 Mar 2020 17:04:22 +0000 (12:04 -0500)
Scale a service down to 0 without removing the spec.

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

index dab91bed559f1ff98056c0e0206e36ff7e99f29b..362dbeb8db1f93698dcd6d9d70245f7218beafc8 100644 (file)
@@ -2980,6 +2980,10 @@ class HostAssignment(object):
         """
         Load hosts into the spec.placement.hosts container.
         """
+        # count == 0
+        if self.spec.placement.count == 0:
+            return []
+
         # respect any explicit host list
         if self.spec.placement.hosts and not self.spec.placement.count:
             logger.debug('Provided hosts: %s' % self.spec.placement.hosts)
@@ -2994,6 +2998,7 @@ class HostAssignment(object):
             logger.debug('All hosts: {}'.format(candidates))
             return candidates
 
+
         count = 0
         if self.spec.placement.hosts and \
            self.spec.placement.count and \
index 7c6132c098d3335ccae1a2bc70881f091cb2cc7d..abd3b3e4e2da3b864b96464a11a18028ca65b960 100644 (file)
@@ -22,6 +22,15 @@ class NodeAssignmentTest(NamedTuple):
             [],
             ['smithi060']
         ),
+        # zero count
+        NodeAssignmentTest(
+            'mon',
+            PlacementSpec(count=0),
+            ['smithi060'],
+            [],
+            []
+        ),
+
         # all_hosts
         NodeAssignmentTest(
             'mon',
@@ -44,6 +53,17 @@ class NodeAssignmentTest(NamedTuple):
             ],
             ['host1', 'host2', 'host3']
         ),
+        # zero count + partial host list
+        NodeAssignmentTest(
+            'mon',
+            PlacementSpec(count=0, hosts=['host3']),
+            'host1 host2 host3'.split(),
+            [
+                DaemonDescription('mon', 'a', 'host1'),
+                DaemonDescription('mon', 'b', 'host2'),
+            ],
+            []
+        ),
         # count + partial host list + existing
         NodeAssignmentTest(
             'mon',