]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: fix encrypted flag handling in orch daemon add osd 59473/head
authorYonatan Zaken <yonatan.zaken@gmail.com>
Mon, 12 Aug 2024 20:00:39 +0000 (23:00 +0300)
committerAdam King <adking@redhat.com>
Tue, 27 Aug 2024 22:04:29 +0000 (18:04 -0400)
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 <yonatan.zaken@gmail.com>
(cherry picked from commit 42721c03ee6f2c47a20dfb4d40af4f7f7afe6113)

src/pybind/mgr/orchestrator/module.py

index ce8e6652b3a42e5e659def047df08167984651ca..6558ae2eb38f41ed0bd3713fad96f26ba2082672 100644 (file)
@@ -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,