From: Sage Weil Date: Tue, 9 Mar 2021 21:09:12 +0000 (-0500) Subject: python-common/ceph/deployment/service_spec: disallow max-per-host + explicit placement X-Git-Tag: v17.1.0~2613^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42d1f5a0a3843ecc369f1df998e867080d5f178f;p=ceph.git python-common/ceph/deployment/service_spec: disallow max-per-host + explicit placement At least for now we don't have a reasonable way to stamp out N placements when we're also constraining the name/network/ip--not in the general case. Signed-off-by: Sage Weil --- diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 2e6b4ab1e59c..2a954f6d313f 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -295,6 +295,14 @@ class PlacementSpec(object): raise ServiceSpecValidationError("count-per-host must be >= 1") if self.count is not None and self.count_per_host is not None: raise ServiceSpecValidationError("cannot combine count and count-per-host") + if ( + self.count_per_host is not None + and self.hosts + and any([hs.network or hs.name for hs in self.hosts]) + ): + raise ServiceSpecValidationError( + "count-per-host cannot be combined explicit placement with names or networks" + ) if self.host_pattern and self.hosts: raise ServiceSpecValidationError('cannot combine host patterns and hosts') for h in self.hosts: diff --git a/src/python-common/ceph/tests/test_service_spec.py b/src/python-common/ceph/tests/test_service_spec.py index 7364ce07c5a0..8cbadcf8c8a3 100644 --- a/src/python-common/ceph/tests/test_service_spec.py +++ b/src/python-common/ceph/tests/test_service_spec.py @@ -78,6 +78,8 @@ def test_parse_placement_specs(test_input, expected): ('host=a count-per-host:0'), ('host=a count-per-host:-10'), ('count:2 count-per-host:1'), + ('host1=a host2=b count-per-host:2'), + ('host1:10/8 count-per-host:2'), ] ) def test_parse_placement_specs_raises(test_input):