Skip to content

Commit 72405c7

Browse files
committed
fix: filter out device mapper/lvm disks from block devices
Detect and filter out the device mapper devices (`dm-0`, `dm-1` etc.), commonly used for `lvm`, from the machine's block devices. This will make them not appear in the list of disks on machines screen/`MachineStatus` resource. They will also not be listed in the install disk dropdown. Signed-off-by: Utku Ozdemir <[email protected]>
1 parent a91bb04 commit 72405c7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

internal/backend/runtime/omni/controllers/omni/internal/task/machine/poll.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ func pollDisks(ctx context.Context, c *client.Client, info *Info) error {
353353
return nil
354354
}
355355

356+
if len(spec.SecondaryDisks) > 0 || spec.BusPath == "/virtual" { // not a real disk, e.g., a device mapper device (lvm)
357+
return nil
358+
}
359+
356360
info.Blockdevices = append(info.Blockdevices, &specs.MachineStatusSpec_HardwareStatus_BlockDevice{
357361
Size: spec.Size,
358362
Model: spec.Model,

internal/backend/runtime/omni/controllers/omni/machine_config_gen_options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func GenInstallConfig(machineStatus *omni.MachineStatus, clusterMachineTalosVers
9292
candidates := machineStatus.TypedSpec().Value.Hardware.Blockdevices
9393

9494
candidates = xslices.Filter(candidates, func(disk *specs.MachineStatusSpec_HardwareStatus_BlockDevice) bool {
95-
return !disk.Readonly && disk.Type != storage.Disk_CD.String() && disk.Size > installDiskMinSize
95+
return !disk.Readonly && disk.Type != storage.Disk_CD.String() && disk.Size > installDiskMinSize && disk.BusPath != "/virtual"
9696
})
9797

9898
sortFunc := func(a, b *specs.MachineStatusSpec_HardwareStatus_BlockDevice) int {

internal/backend/runtime/omni/controllers/omni/machine_config_gen_options_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestGenInstallConfig(t *testing.T) {
6868
},
6969
},
7070
{
71-
name: "matched not usb",
71+
name: "matched not usb not virtual",
7272
machineStatusSpec: &specs.MachineStatusSpec{
7373
Hardware: &specs.MachineStatusSpec_HardwareStatus{
7474
Blockdevices: []*specs.MachineStatusSpec_HardwareStatus_BlockDevice{
@@ -77,6 +77,11 @@ func TestGenInstallConfig(t *testing.T) {
7777
Size: 8e9,
7878
Transport: "usb",
7979
},
80+
{
81+
LinuxName: "/dev/dm-0",
82+
Size: 8e9,
83+
BusPath: "/virtual",
84+
},
8085
{
8186
LinuxName: "/dev/sdb",
8287
Size: 10e9,
@@ -90,6 +95,11 @@ func TestGenInstallConfig(t *testing.T) {
9095
Size: 7e9,
9196
Transport: "usb",
9297
},
98+
{
99+
LinuxName: "/dev/dm-1",
100+
Size: 7e9,
101+
BusPath: "/virtual",
102+
},
93103
},
94104
},
95105
},

0 commit comments

Comments
 (0)