From: Sebastian Wagner Date: Wed, 20 Oct 2021 13:41:18 +0000 (+0200) Subject: mgr/cephadm: Fix RGW ipv6 frontend configuration X-Git-Tag: v17.1.0~569^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f127e0829b3c512a380bedca46b868fc0c0c7f56;p=ceph.git mgr/cephadm: Fix RGW ipv6 frontend configuration Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index f611a2ec2f913..2dbfb67190761 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -10,6 +10,7 @@ from mgr_module import HandleCommandResult, MonCommandFailed from ceph.deployment.service_spec import ServiceSpec, RGWSpec from ceph.deployment.utils import is_ipv6, unwrap_ipv6 +from mgr_util import build_url from orchestrator import OrchestratorError, DaemonDescription, DaemonDescriptionStatus from orchestrator._interface import daemon_type_to_service from cephadm import utils @@ -822,25 +823,27 @@ class RgwService(CephService): if ftype == 'beast': if spec.ssl: if daemon_spec.ip: - args.append(f"ssl_endpoint={daemon_spec.ip}:{port}") + args.append( + f"ssl_endpoint={build_url(host=daemon_spec.ip, port=port).lstrip('/')}") else: args.append(f"ssl_port={port}") args.append(f"ssl_certificate=config://rgw/cert/{spec.service_name()}") else: if daemon_spec.ip: - args.append(f"endpoint={daemon_spec.ip}:{port}") + args.append(f"endpoint={build_url(host=daemon_spec.ip, port=port).lstrip('/')}") else: args.append(f"port={port}") elif ftype == 'civetweb': if spec.ssl: if daemon_spec.ip: - args.append(f"port={daemon_spec.ip}:{port}s") # note the 's' suffix on port + # note the 's' suffix on port + args.append(f"port={build_url(host=daemon_spec.ip, port=port).lstrip('/')}s") else: args.append(f"port={port}s") # note the 's' suffix on port args.append(f"ssl_certificate=config://rgw/cert/{spec.service_name()}") else: if daemon_spec.ip: - args.append(f"port={daemon_spec.ip}:{port}") + args.append(f"port={build_url(host=daemon_spec.ip, port=port).lstrip('/')}") else: args.append(f"port={port}") frontend = f'{ftype} {" ".join(args)}' diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index b47e6f732f4e3..5180d363d0d02 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -15,8 +15,9 @@ from cephadm.services.osd import OSDService from cephadm.services.monitoring import GrafanaService, AlertmanagerService, PrometheusService, \ NodeExporterService from cephadm.module import CephadmOrchestrator -from ceph.deployment.service_spec import IscsiServiceSpec, MonitoringSpec, AlertManagerSpec, ServiceSpec -from cephadm.tests.fixtures import with_host, with_service +from ceph.deployment.service_spec import IscsiServiceSpec, MonitoringSpec, AlertManagerSpec, \ + ServiceSpec, RGWSpec +from cephadm.tests.fixtures import with_host, with_service, _run_cephadm from orchestrator import OrchestratorError from orchestrator._interface import DaemonDescription @@ -419,3 +420,37 @@ spec: ], stdin='{}', image='') + + +class TestRGWService: + + @pytest.mark.parametrize( + "frontend, ssl, expected", + [ + ('beast', False, 'beast endpoint=[fd00:fd00:fd00:3000::1]:80'), + ('beast', True, + 'beast ssl_endpoint=[fd00:fd00:fd00:3000::1]:443 ssl_certificate=config://rgw/cert/rgw.foo'), + ('civetweb', False, 'civetweb port=[fd00:fd00:fd00:3000::1]:80'), + ('civetweb', True, + 'civetweb port=[fd00:fd00:fd00:3000::1]:443s ssl_certificate=config://rgw/cert/rgw.foo'), + ] + ) + @patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) + def test_rgw_update(self, frontend, ssl, expected, cephadm_module: CephadmOrchestrator): + with with_host(cephadm_module, 'host1'): + cephadm_module.cache.update_host_networks('host1', { + 'fd00:fd00:fd00:3000::/64': { + 'if0': ['fd00:fd00:fd00:3000::1'] + } + }) + s = RGWSpec(service_id="foo", + networks=['fd00:fd00:fd00:3000::/64'], + ssl=ssl, + rgw_frontend_type=frontend) + with with_service(cephadm_module, s) as dds: + _, f, _ = cephadm_module.check_mon_command({ + 'prefix': 'config get', + 'who': f'client.{dds[0]}', + 'key': 'rgw_frontends', + }) + assert f == expected