nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: osbuild/osbuild-composer
Pull request #2599 (2022-04-28 11:53:35)

[RHEL 8.6] disk: fix ensureLVM for partition tables without /boot
#2580 for RHEL 8.6 branch


Patch:
diff --git a/internal/disk/partition_table.go b/internal/disk/partition_table.go
index d61c0931a..f3fcc1e35 100644
--- a/internal/disk/partition_table.go
+++ b/internal/disk/partition_table.go
@@ -477,7 +477,12 @@ func (pt *PartitionTable) ensureLVM() error {
 	bootPath := entityPath(pt, "/boot")
 	if bootPath == nil {
 		_, err := pt.CreateMountpoint("/boot", 512*1024*1024)
-		return err
+
+		if err != nil {
+			return err
+		}
+
+		rootPath = entityPath(pt, "/")
 	}
 
 	parent := rootPath[1] // NB: entityPath has reversed order


Test patch:
diff --git a/internal/disk/disk_test.go b/internal/disk/disk_test.go
index 499f70fe5..a5a97e392 100644
--- a/internal/disk/disk_test.go
+++ b/internal/disk/disk_test.go
@@ -372,6 +372,13 @@ var bp = []blueprint.FilesystemCustomization{
 	},
 }
 
+var bp2 = []blueprint.FilesystemCustomization{
+	{
+		Mountpoint: "/opt",
+		MinSize:    7 * 1024 * 1024 * 1024,
+	},
+}
+
 func TestDisk_ForEachEntity(t *testing.T) {
 
 	count := 0
@@ -415,32 +422,35 @@ func TestCreatePartitionTableLVMify(t *testing.T) {
 	// math/rand is good enough in this case
 	/* #nosec G404 */
 	rng := rand.New(rand.NewSource(13))
-	for name := range testPartitionTables {
-		pt := testPartitionTables[name]
+	blueprints := [][]blueprint.FilesystemCustomization{bp, bp2}
+	for _, tbp := range blueprints {
+		for name := range testPartitionTables {
+			pt := testPartitionTables[name]
 
-		if name == "btrfs" || name == "luks" {
-			assert.Panics(func() {
-				_, _ = NewPartitionTable(&pt, bp, uint64(13*1024*1024), true, rng)
-			})
-			continue
-		}
+			if name == "btrfs" || name == "luks" {
+				assert.Panics(func() {
+					_, _ = NewPartitionTable(&pt, tbp, uint64(13*1024*1024), true, rng)
+				})
+				continue
+			}
 
-		mpt, err := NewPartitionTable(&pt, bp, uint64(13*1024*1024), true, rng)
-		assert.NoError(err, "Partition table generation failed: %s (%s)", name, err)
+			mpt, err := NewPartitionTable(&pt, tbp, uint64(13*1024*1024), true, rng)
+			assert.NoError(err, "Partition table generation failed: %s (%s)", name, err)
 
-		rootPath := entityPath(mpt, "/")
-		if rootPath == nil {
-			panic("no root mountpoint for PartitionTable")
-		}
+			rootPath := entityPath(mpt, "/")
+			if rootPath == nil {
+				panic("no root mountpoint for PartitionTable")
+			}
 
-		bootPath := entityPath(mpt, "/boot")
-		if bootPath == nil {
-			panic("no boot mountpoint for PartitionTable")
-		}
+			bootPath := entityPath(mpt, "/boot")
+			if bootPath == nil {
+				panic("no boot mountpoint for PartitionTable")
+			}
 
-		parent := rootPath[1]
-		_, ok := parent.(*LVMLogicalVolume)
-		assert.True(ok, "Partition table '%s': root's parent (%q) is not an LVM logical volume", name, parent)
+			parent := rootPath[1]
+			_, ok := parent.(*LVMLogicalVolume)
+			assert.True(ok, "Partition table '%s': root's parent (%q) is not an LVM logical volume", name, parent)
+		}
 	}
 }