Skip to content

Commit 42721c0

Browse files
committed
mgr/orchestrator: fix encrypted flag handling in orch daemon add osd
The current implementation incorrectly parses this `encrypted` flag as a string rather than a boolean value. This leads to unintended behavior causing an LVM encryption layer to be created regardless of whether `encrypted=True` or `encrypted=False` is passed. The only way to prevent this behavior is by omitting the `encrypted` flag entirely. This change prevents potential errors, aligning the behavior with user expectations. Fixes: https://tracker.ceph.com/issues/67372 Signed-off-by: Yonatan Zaken <[email protected]>
1 parent 2b06a57 commit 42721c0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pybind/mgr/orchestrator/module.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,8 @@ def _daemon_add_osd(self,
13361336
usage = """
13371337
Usage:
13381338
ceph orch daemon add osd host:device1,device2,...
1339-
ceph orch daemon add osd host:data_devices=device1,device2,db_devices=device3,osds_per_device=2,...
1339+
ceph orch daemon add osd host:data_devices=device1,device2,db_devices=device3,osds_per_device=2[,encrypted=true|True|1]
1340+
ceph orch daemon add osd host:data_devices=device1[,encrypted=false|False|0]
13401341
"""
13411342
if not svc_arg:
13421343
return HandleCommandResult(-errno.EINVAL, stderr=usage)
@@ -1369,6 +1370,16 @@ def _daemon_add_osd(self,
13691370
drive_group_spec[dev_type] = DeviceSelection(
13701371
paths=drive_group_spec[dev_type]) if drive_group_spec.get(dev_type) else None
13711372

1373+
valid_true_vals = {'true', '1'}
1374+
valid_false_vals = {'false', '0'}
1375+
for drive_group_spec_bool_arg in ['encrypted', 'unmanaged', 'preview_only']:
1376+
drive_group_spec_value: Optional[str] = drive_group_spec.get(drive_group_spec_bool_arg)
1377+
if isinstance(drive_group_spec_value, str):
1378+
value_lower = drive_group_spec_value.lower()
1379+
if value_lower not in valid_true_vals and value_lower not in valid_false_vals:
1380+
raise OrchestratorValidationError(usage)
1381+
drive_group_spec[drive_group_spec_bool_arg] = value_lower in valid_true_vals
1382+
13721383
drive_group = DriveGroupSpec(
13731384
placement=PlacementSpec(host_pattern=host_name),
13741385
method=method,

0 commit comments

Comments
 (0)