Repository: openshift/assisted-service (language: python)

Issue:
[release-ocm-2.9] MGMT-17848: Assisted service should not format multipath devices
This is an automated cherry-pick of #6380

/assign adriengentil

/cherrypick release-ocm-2.8


Discussion / hints:

Fix patch:
diff --git a/internal/common/disk_formatting.go b/internal/common/disk_formatting.go
index 613aa8dd0bb..ed3d0fb30b1 100644
--- a/internal/common/disk_formatting.go
+++ b/internal/common/disk_formatting.go
@@ -13,7 +13,7 @@ import (
 func GetDisksToBeFormatted(inventory *models.Inventory) []*models.Disk {
 	formatDisks := make([]*models.Disk, 0, len(inventory.Disks))
 
-	skipDriveTypes := []string{string(models.DriveTypeFC), string(models.DriveTypeISCSI), string(models.DriveTypeLVM)}
+	skipDriveTypes := []string{string(models.DriveTypeFC), string(models.DriveTypeISCSI), string(models.DriveTypeLVM), string(models.DriveTypeMultipath)}
 	for _, disk := range inventory.Disks {
 		diskRemovable := disk.Removable || strings.Contains(disk.ByPath, "mmcblk") //mmc devices should be treated as removable
 


Test patch:
diff --git a/internal/host/hostcommands/install_cmd_test.go b/internal/host/hostcommands/install_cmd_test.go
index d90beb44e12..a289bda86b6 100644
--- a/internal/host/hostcommands/install_cmd_test.go
+++ b/internal/host/hostcommands/install_cmd_test.go
@@ -11,6 +11,7 @@ import (
 	"github.com/golang/mock/gomock"
 	"github.com/google/uuid"
 	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
 	. "github.com/onsi/gomega"
 	"github.com/openshift/assisted-service/internal/common"
 	eventgen "github.com/openshift/assisted-service/internal/common/events"
@@ -195,17 +196,25 @@ var _ = Describe("installcmd", func() {
 		sdh := createDisk("sdh", false)
 		sdc := createDisk("sdc", true)
 
-		It("Doesn't format removable disks", func() {
-			disks := []*models.Disk{
-				createRemovableDisk("sda", true), //removable disk
-				sdb,                              //installation disk
-			}
-			host.Inventory = getInventory(disks)
-			mockFormatEvent(disks[0], 0)
-			prepareGetStep(sdb)
-			installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
-			verifyDiskFormatCommand(installCmdSteps[0], disks[0].ID, false)
-		})
+		DescribeTable("Doesn't format",
+			func(disk *models.Disk) {
+				disks := []*models.Disk{
+					disk,
+					sdb, // installation disk
+				}
+				host.Inventory = getInventory(disks)
+				mockFormatEvent(disks[0], 0)
+				prepareGetStep(sdb)
+				installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
+				verifyDiskFormatCommand(installCmdSteps[0], disks[0].ID, false)
+			},
+			Entry("when disk is removable", createRemovableDisk("sda", true)),
+			Entry("when disk path contains mmcblk", &models.Disk{DriveType: models.DriveTypeHDD, ID: "/dev/disk/by-id/wwn-someid", ByPath: "/dev/mmcblk0", Name: "sda", SizeBytes: int64(128849018880), Bootable: true}),
+			Entry("when disk type is LVM", &models.Disk{DriveType: models.DriveTypeLVM, ID: "/dev/disk/by-id/wwn-someid", Name: "sda", SizeBytes: int64(128849018880), Bootable: true}),
+			Entry("when disk type is iSCSI", &models.Disk{DriveType: models.DriveTypeISCSI, ID: "/dev/disk/by-id/wwn-someid", Name: "sda", SizeBytes: int64(128849018880), Bootable: true}),
+			Entry("when disk type is FC", &models.Disk{DriveType: models.DriveTypeFC, ID: "/dev/disk/by-id/wwn-someid", Name: "sda", SizeBytes: int64(128849018880), Bootable: true}),
+			Entry("when disk type is multipath", &models.Disk{DriveType: models.DriveTypeMultipath, ID: "/dev/disk/by-id/wwn-someid", Name: "sda", SizeBytes: int64(128849018880), Bootable: true}),
+		)
 
 		It("Formats a single removable disk", func() {
 			disks := []*models.Disk{