From e96fb7ffb592b949c2e427a4d41d657ea32013bd Mon Sep 17 00:00:00 2001 From: Sayan Paul Date: Tue, 5 Dec 2023 17:54:14 +0530 Subject: [PATCH] blueprint/customization:filesystem customizations for raw Filesystem customizations is enabled for edge-raw-image relevent testing config is added to run in CI Signed-off-by: Sayan Paul --- pkg/distro/rhel9/distro_test.go | 6 +- pkg/distro/rhel9/imagetype.go | 19 +++--- test/config-map.json | 8 +++ .../ostree-filesystem-customizations.json | 68 +++++++++++++++++++ 4 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 test/configs/ostree-filesystem-customizations.json diff --git a/pkg/distro/rhel9/distro_test.go b/pkg/distro/rhel9/distro_test.go index 0f741ade3e..72572cde1f 100644 --- a/pkg/distro/rhel9/distro_test.go +++ b/pkg/distro/rhel9/distro_test.go @@ -671,7 +671,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) { imgType, _ := arch.GetImageType(imgTypeName) _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + assert.EqualError(t, err, "Custom mountpoints are not supported for edge-container and edge-commit") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { continue } else { @@ -699,7 +699,7 @@ func TestDistro_TestRootMountPoint(t *testing.T) { imgType, _ := arch.GetImageType(imgTypeName) _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + assert.EqualError(t, err, "Custom mountpoints are not supported for edge-container and edge-commit") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { continue } else { @@ -829,7 +829,7 @@ func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { imgType, _ := arch.GetImageType(imgTypeName) _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + assert.EqualError(t, err, "Custom mountpoints are not supported for edge-container and edge-commit") } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" || imgTypeName == "edge-vsphere" { continue } else { diff --git a/pkg/distro/rhel9/imagetype.go b/pkg/distro/rhel9/imagetype.go index a307caec32..d15fc8c9d8 100644 --- a/pkg/distro/rhel9/imagetype.go +++ b/pkg/distro/rhel9/imagetype.go @@ -164,12 +164,7 @@ func (t *imageType) getPartitionTable( partitioningMode := options.PartitioningMode if t.rpmOstree { // Edge supports only LVM, force it. - // Raw is not supported, return an error if it is requested // TODO Need a central location for logic like this - if partitioningMode == disk.RawPartitioningMode { - return nil, fmt.Errorf("partitioning mode raw not supported for %s on %s", t.Name(), t.arch.Name()) - } - partitioningMode = disk.LVMPartitioningMode } @@ -355,8 +350,10 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp if options.OSTree == nil || options.OSTree.URL == "" { return warnings, fmt.Errorf("%q images require specifying a URL from which to retrieve the OSTree commit", t.name) } - allowed := []string{"Ignition", "Kernel", "User", "Group", "FIPS"} + if t.name == "edge-raw-image" { + allowed = append(allowed, "Filesystem") + } if err := customizations.CheckAllowed(allowed...); err != nil { return warnings, fmt.Errorf("unsupported blueprint customizations found for image type %q: (allowed: %s)", t.name, strings.Join(allowed, ", ")) } @@ -383,9 +380,13 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp } mountpoints := customizations.GetFilesystems() - - if mountpoints != nil && t.rpmOstree { - return warnings, fmt.Errorf("Custom mountpoints are not supported for ostree types") + if mountpoints != nil && t.rpmOstree && t.name != "edge-raw-image" { + return warnings, fmt.Errorf("Custom mountpoints are not supported for edge-container and edge-commit") + } else if t.name == "edge-raw-image" { + err := blueprint.CheckMountpointsPolicy(mountpoints, pathpolicy.OstreeMountpointPolicies) + if err != nil { + return warnings, err + } } err := blueprint.CheckMountpointsPolicy(mountpoints, pathpolicy.MountpointPolicies) diff --git a/test/config-map.json b/test/config-map.json index 2a7e555c26..4e361ab86c 100644 --- a/test/config-map.json +++ b/test/config-map.json @@ -193,5 +193,13 @@ "image-types": [ "ec2-sap" ] + }, + "./configs/ostree-filesystem-customization.json": { + "image-types": [ + "edge-raw-image" + ], + "distros": [ + "rhel-9*" + ] } } diff --git a/test/configs/ostree-filesystem-customizations.json b/test/configs/ostree-filesystem-customizations.json new file mode 100644 index 0000000000..fc52929bab --- /dev/null +++ b/test/configs/ostree-filesystem-customizations.json @@ -0,0 +1,68 @@ +{ + "name": "ostree-filesystem-customizations", + "ostree": { + "url": "http://example.com/repo" + }, + "blueprint": { + "customizations": { + "filesystem": [ + { + "mountpoint": "/foo", + "minsize": "2147483648" + }, + { + "mountpoint": "/foo/bar", + "minsize": "2 GiB" + }, + { + "mountpoint": "/home", + "minsize": "2 GiB" + }, + { + "mountpoint": "/home/shadowman", + "minsize": "500 MiB" + }, + { + "mountpoint": "/root", + "minsize": "1 GiB" + }, + { + "mountpoint": "/mnt", + "minsize": "3 GiB" + }, + { + "mountpoint": "/srv", + "minsize": "4 GiB" + }, + { + "mountpoint": "/opt", + "minsize": "1 GiB" + }, + { + "mountpoint": "/var/mydata", + "minsize": "1 GiB" + }, + { + "mountpoint": "/var/mnt", + "minsize": "1 GiB" + }, + { + "mountpoint": "/var/opt", + "minsize": "1 GiB" + }, + { + "mountpoint": "/var/srv", + "minsize": "500 MiB" + }, + { + "mountpoint": "/var/roothome", + "minsize": "1 GiB" + } + ] + } + }, + "depends": { + "image-type": "edge-container", + "config": "empty.json" + } +}