]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
python-common: make count & count-per-host >= 1 checks consistent
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 10 Dec 2021 13:16:19 +0000 (08:16 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 10 Dec 2021 17:18:49 +0000 (12:18 -0500)
The previous version of the validate function had a incorrect error
statement that suggested the count must be >1  when it should have
been >=1. This confusion was possibly due to using "n < 1" on
one line and "n <= 0" on another line. Since both values are supposed
to be integers this change corrects the error message and makes
the comparisons on the lines both use "n < 1" (since I find it easier
to see that the check "n < 1" is the inverse of the error text
asserting "n >= 1").

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/cephadm/tests/test_scheduling.py
src/python-common/ceph/deployment/service_spec.py

index e4f8efa0784362e03ae537c13e1a406e50c48685..ec4b87f59e486f6453f1df97b21a5fcc91dc1dc8 100644 (file)
@@ -167,7 +167,7 @@ def run_scheduler_test(results, mk_spec, hosts, daemons, key_elems):
 #       |   |   | |     + expected result
 #       |   |   | |     |
 test_explicit_scheduler_results = [
-    (k("*   *   0 *"), error(SpecValidationError, 'num/count must be > 1')),
+    (k("*   *   0 *"), error(SpecValidationError, 'num/count must be >= 1')),
     (k("*   e   N l"), error(OrchestratorValidationError, 'Cannot place <ServiceSpec for service_name=mgr>: No matching hosts for label mylabel')),
     (k("*   e   N p"), error(OrchestratorValidationError, 'Cannot place <ServiceSpec for service_name=mgr>: No matching hosts')),
     (k("*   e   N h"), error(OrchestratorValidationError, 'placement spec is empty: no hosts, no label, no pattern, no count')),
index e8fd14e9ca6a99aff94464f7e2864ab2557d3024..2f021388ed22fd928bbe23aebb5c7081713c16ec 100644 (file)
@@ -280,8 +280,8 @@ class PlacementSpec(object):
                 raise SpecValidationError("num/count must be a numeric value")
             if self.count != intval:
                 raise SpecValidationError("num/count must be an integer value")
-            if self.count <= 0:
-                raise SpecValidationError("num/count must be > 1")
+            if self.count < 1:
+                raise SpecValidationError("num/count must be >= 1")
         if self.count_per_host is not None:
             try:
                 intval = int(self.count_per_host)