Skip to content

Commit 945b172

Browse files
committed
mgr/cephadm: fixing mgmt-gateway cert generation for HA scenarios
modified the code to include only the virtual IP in the certificate when running in high availability (HA) mode, excluding the host FQDN to ensure consistent certificate validation across all mgmt-gateway instances. https://tracker.ceph.com/issues/70391 Signed-off-by: Redouane Kachach <[email protected]>
1 parent 84edffd commit 945b172

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/pybind/mgr/cephadm/services/mgmt_gateway.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def get_active_daemon(self, daemon_descrs: List[DaemonDescription]) -> DaemonDes
4040
# if empty list provided, return empty Daemon Desc
4141
return DaemonDescription()
4242

43-
def get_mgmt_gw_ips(self, svc_spec: MgmtGatewaySpec, daemon_spec: CephadmDaemonDeploySpec) -> List[str]:
44-
mgmt_gw_ips = [self.mgr.inventory.get_addr(daemon_spec.host)]
43+
def get_mgmt_gw_ip(self, svc_spec: MgmtGatewaySpec, daemon_spec: CephadmDaemonDeploySpec) -> str:
4544
if svc_spec.virtual_ip is not None:
46-
mgmt_gw_ips.append(svc_spec.virtual_ip)
47-
return mgmt_gw_ips
45+
return svc_spec.virtual_ip
46+
else:
47+
return self.mgr.inventory.get_addr(daemon_spec.host)
4848

4949
def config_dashboard(self, daemon_descrs: List[DaemonDescription]) -> None:
5050
# we adjust the standby behaviour so rev-proxy can pick correctly the active instance
@@ -63,9 +63,12 @@ def get_external_certificates(self, svc_spec: MgmtGatewaySpec, daemon_spec: Ceph
6363
key = svc_spec.ssl_certificate_key
6464
else:
6565
# not provided on the spec, let's generate self-sigend certificates
66-
ips = self.get_mgmt_gw_ips(svc_spec, daemon_spec)
67-
host_fqdn = self.mgr.get_fqdn(daemon_spec.host)
68-
cert, key = self.mgr.cert_mgr.generate_cert(host_fqdn, ips)
66+
ip = self.get_mgmt_gw_ip(svc_spec, daemon_spec)
67+
# we don't include the host_fqdn in case of using a virtual_ip
68+
# because we may have several instances of the mgmt-gateway running
69+
# on different hosts
70+
host_fqdn = [] if svc_spec.virtual_ip else [self.mgr.get_fqdn(daemon_spec.host)]
71+
cert, key = self.mgr.cert_mgr.generate_cert(host_fqdn, ip)
6972
# save certificates
7073
if cert and key:
7174
self.mgr.cert_mgr.save_cert('mgmt_gw_cert', cert, user_made=user_made)
@@ -75,9 +78,9 @@ def get_external_certificates(self, svc_spec: MgmtGatewaySpec, daemon_spec: Ceph
7578
return cert, key
7679

7780
def get_internal_certificates(self, svc_spec: MgmtGatewaySpec, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[str, str]:
78-
ips = self.get_mgmt_gw_ips(svc_spec, daemon_spec)
81+
ip = self.get_mgmt_gw_ip(svc_spec, daemon_spec)
7982
host_fqdn = self.mgr.get_fqdn(daemon_spec.host)
80-
return self.mgr.cert_mgr.generate_cert(host_fqdn, ips)
83+
return self.mgr.cert_mgr.generate_cert(host_fqdn, ip)
8184

8285
def get_service_discovery_endpoints(self) -> List[str]:
8386
sd_endpoints = []

0 commit comments

Comments
 (0)