From 6169eb7f8e2462eb58338d6fc312b1347858b47f Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 10 Dec 2021 08:16:19 -0500 Subject: [PATCH] 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 --- src/pybind/mgr/cephadm/tests/test_scheduling.py | 2 +- src/python-common/ceph/deployment/service_spec.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 e8fd14e9ca6..2f021388ed2 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) -- 2.39.5