Skip to content

Commit 8dbc5f8

Browse files
committed
mgr/cephadm: adding the SSL cert as a dependency for ingress service
This way when the user changes the SSL certificate in the spec and performs an 'orch apply' cephadm will detect the change and reconfigure the ingress service automatically. In addition we are also adding the ssl_key because it was not included in the generated haproxy configuration. Signed-off-by: Redouane Kachach <[email protected]>
1 parent bd049ed commit 8dbc5f8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,18 @@ def get_haproxy_dependencies(mgr: "CephadmOrchestrator", spec: Optional[ServiceS
9797
# sufficient to detect changes.
9898
if not spec:
9999
return []
100+
100101
ingress_spec = cast(IngressSpec, spec)
101102
assert ingress_spec.backend_service
102103
daemons = mgr.cache.get_daemons_by_service(ingress_spec.backend_service)
103-
return sorted([d.name() for d in daemons])
104+
deps = [d.name() for d in daemons]
105+
for attr in ['ssl_cert', 'ssl_key']:
106+
ssl_cert_key = getattr(ingress_spec, attr, None)
107+
if ssl_cert_key:
108+
assert isinstance(ssl_cert_key, str)
109+
deps.append(f'ssl-cert-key:{str(utils.md5_hash(ssl_cert_key))}')
110+
111+
return sorted(deps)
104112

105113
def haproxy_generate_config(
106114
self,
@@ -221,11 +229,12 @@ def haproxy_generate_config(
221229
"haproxy.cfg": haproxy_conf,
222230
}
223231
}
232+
224233
if spec.ssl_cert:
225-
ssl_cert = spec.ssl_cert
226-
if isinstance(ssl_cert, list):
227-
ssl_cert = '\n'.join(ssl_cert)
228-
config_files['files']['haproxy.pem'] = ssl_cert
234+
config_files['files']['haproxy.pem'] = spec.ssl_cert
235+
236+
if spec.ssl_key:
237+
config_files['files']['haproxy.pem.key'] = spec.ssl_key
229238

230239
return config_files, self.get_haproxy_dependencies(self.mgr, spec)
231240

0 commit comments

Comments
 (0)