From: Yonatan Zaken Date: Mon, 12 Aug 2024 20:00:39 +0000 (+0300) Subject: mgr/orchestrator: fix encrypted flag handling in orch daemon add osd X-Git-Tag: v19.2.1~234^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6b0775fda1961022b7b7f4dad8313531e9ebab58;p=ceph.git 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 (cherry picked from commit 42721c03ee6f2c47a20dfb4d40af4f7f7afe6113) --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index ce8e6652b3a42..6558ae2eb38f4 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -1335,7 +1335,8 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule, usage = """ Usage: ceph orch daemon add osd host:device1,device2,... - ceph orch daemon add osd host:data_devices=device1,device2,db_devices=device3,osds_per_device=2,... + ceph orch daemon add osd host:data_devices=device1,device2,db_devices=device3,osds_per_device=2[,encrypted=true|True|1] + ceph orch daemon add osd host:data_devices=device1[,encrypted=false|False|0] """ if not svc_arg: return HandleCommandResult(-errno.EINVAL, stderr=usage) @@ -1368,6 +1369,16 @@ Usage: drive_group_spec[dev_type] = DeviceSelection( paths=drive_group_spec[dev_type]) if drive_group_spec.get(dev_type) else None + valid_true_vals = {'true', '1'} + valid_false_vals = {'false', '0'} + for drive_group_spec_bool_arg in ['encrypted', 'unmanaged', 'preview_only']: + drive_group_spec_value: Optional[str] = drive_group_spec.get(drive_group_spec_bool_arg) + if isinstance(drive_group_spec_value, str): + value_lower = drive_group_spec_value.lower() + if value_lower not in valid_true_vals and value_lower not in valid_false_vals: + raise OrchestratorValidationError(usage) + drive_group_spec[drive_group_spec_bool_arg] = value_lower in valid_true_vals + drive_group = DriveGroupSpec( placement=PlacementSpec(host_pattern=host_name), method=method,