From: John Mulligan Date: Fri, 10 Dec 2021 13:16:19 +0000 (-0500) Subject: python-common: make count & count-per-host >= 1 checks consistent X-Git-Tag: v16.2.8~260^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8b4681e2d1300047d65470f5e314b6e041419b57;p=ceph.git python-common: make count & count-per-host >= 1 checks consistent 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 (cherry picked from commit 6169eb7f8e2462eb58338d6fc312b1347858b47f) --- diff --git a/src/pybind/mgr/cephadm/tests/test_scheduling.py b/src/pybind/mgr/cephadm/tests/test_scheduling.py index e4f8efa0784..ec4b87f59e4 100644 --- a/src/pybind/mgr/cephadm/tests/test_scheduling.py +++ b/src/pybind/mgr/cephadm/tests/test_scheduling.py @@ -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 : No matching hosts for label mylabel')), (k("* e N p"), error(OrchestratorValidationError, 'Cannot place : No matching hosts')), (k("* e N h"), error(OrchestratorValidationError, 'placement spec is empty: no hosts, no label, no pattern, no count')), diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 46b6aa16498..ea5f1106a32 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -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)