From: Michael Fritch Date: Wed, 1 Jul 2020 14:27:02 +0000 (-0600) Subject: python-common: RGW service_id might not contain a zone X-Git-Tag: wip-pdonnell-testing-20200918.022351~666^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b54a800b748dc94cb847cc44e23b481c8c3a85b4;p=ceph-ci.git python-common: RGW service_id might not contain a zone also adds missing RGWSpec.validate() Fixes: https://tracker.ceph.com/issues/46268 Signed-off-by: Michael Fritch --- diff --git a/src/pybind/mgr/cephadm/tests/test_scheduling.py b/src/pybind/mgr/cephadm/tests/test_scheduling.py index 4c4d10dddf4..806625934bf 100644 --- a/src/pybind/mgr/cephadm/tests/test_scheduling.py +++ b/src/pybind/mgr/cephadm/tests/test_scheduling.py @@ -430,9 +430,16 @@ def test_node_assignment(service_type, placement, hosts, daemons, expected): return [HostSpec(h) for h in hosts] return hosts + service_id = None + if service_type == 'rgw': + service_id = 'realm.zone' + + spec = ServiceSpec(service_type=service_type, + service_id=service_id, + placement=placement) hosts = HostAssignment( - spec=ServiceSpec(service_type, placement=placement), + spec=spec, get_hosts_func=get_hosts_func, get_daemons_func=lambda _: daemons).place() assert sorted([h.hostname for h in hosts]) == sorted(expected) diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 3c3c017d209..9111c75ad71 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -612,7 +612,8 @@ class RGWSpec(ServiceSpec): if service_id: a = service_id.split('.', 2) rgw_realm = a[0] - rgw_zone = a[1] + if len(a) > 1: + rgw_zone = a[1] if len(a) > 2: subcluster = a[2] else: @@ -650,6 +651,16 @@ class RGWSpec(ServiceSpec): ports.append(f"port={self.get_port()}") return f'beast {" ".join(ports)}' + def validate(self): + super(RGWSpec, self).validate() + + if not self.rgw_realm: + raise ServiceSpecValidationError( + 'Cannot add RGW: No realm specified') + if not self.rgw_zone: + raise ServiceSpecValidationError( + 'Cannot add RGW: No zone specified') + yaml.add_representer(RGWSpec, ServiceSpec.yaml_representer)