Skip to content

Commit 1f74b5d

Browse files
mgr/cephadm: support tls creds via uri in service spec
Support populating the cert data sent to the cephadm binary using special `URI:` prefixed strings instead of putting the cert data itself in the smb service spec. This avoids having an extra copy of the cert floating around but still matches the behavior of other services where cephadm writes the certs into files. In the future we may be able to avoid even putting the data in here as sambacc can use rados apis - but for simplicity and matching other services we will send the data this way for now. Signed-off-by: John Mulligan <[email protected]>
1 parent ef84df2 commit 1f74b5d

File tree

1 file changed

+17
-3
lines changed
  • src/pybind/mgr/cephadm/services

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,37 @@ def generate_config(
163163
_add_cfg(
164164
files,
165165
'remote_control.ssl.crt',
166-
smb_spec.remote_control_ssl_cert,
166+
self._cert_or_uri(smb_spec.remote_control_ssl_cert),
167167
)
168168
_add_cfg(
169169
files,
170170
'remote_control.ssl.key',
171-
smb_spec.remote_control_ssl_key,
171+
self._cert_or_uri(smb_spec.remote_control_ssl_key),
172172
)
173173
_add_cfg(
174174
files,
175175
'remote_control.ca.crt',
176-
smb_spec.remote_control_ca_cert,
176+
self._cert_or_uri(smb_spec.remote_control_ca_cert),
177177
)
178178

179179
logger.debug('smb generate_config: %r', config_blobs)
180180
self._configure_cluster_meta(smb_spec, daemon_spec)
181181
return config_blobs, []
182182

183+
def _cert_or_uri(self, data: Optional[str]) -> Optional[str]:
184+
if data is None:
185+
return None
186+
if not data.startswith("URI:"):
187+
return data
188+
uri = data[4:]
189+
if not uri.startswith('rados:mon-config-key'):
190+
raise ValueError('unhandled URI scheme')
191+
192+
from smb.mon_store import MonKeyConfigStore
193+
store = MonKeyConfigStore(self.mgr)
194+
entry = store.lookup_uri(uri)
195+
return entry.get_data()
196+
183197
def config_dashboard(
184198
self, daemon_descrs: List[DaemonDescription]
185199
) -> None:

0 commit comments

Comments
 (0)