Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for advanced partitioning customizations (COMPOSER-2399) #4535

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,29 @@ filesystem.sh:
extends: .integration
parallel:
matrix:
- RUNNER:
- aws/fedora-40-x86_64
- *rhel_runners

- CUSTOMIZATION_TYPE: "disk-btrfs"
RUNNER:
- aws/fedora-40-x86_64
- CUSTOMIZATION_TYPE: "filesystem"
RUNNER:
- aws/rhel-8.10-ga-x86_64
- CUSTOMIZATION_TYPE: "disk-plain"
RUNNER:
- aws/rhel-9.4-ga-x86_64
- CUSTOMIZATION_TYPE: "disk-lvm"
RUNNER:
- aws/rhel-9.6-nightly-x86_64
- CUSTOMIZATION_TYPE: "disk-plain"
RUNNER:
- aws/rhel-10.0-nightly-x86_64
- CUSTOMIZATION_TYPE: "disk-lvm"
RUNNER:
- aws/centos-stream-9-x86_64
- CUSTOMIZATION_TYPE: "filesystem"
RUNNER:
- aws/centos-stream-10-x86_64
variables:
SCRIPT: filesystem.sh
SCRIPT: filesystem.sh ${CUSTOMIZATION_TYPE}

cross-distro.sh:
extends: .integration
Expand Down
38 changes: 38 additions & 0 deletions internal/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,44 @@ func Convert(bp Blueprint) iblueprint.Blueprint {
}
customizations.Filesystem = ifs
}
if disk := c.Disk; disk != nil {
idisk := &iblueprint.DiskCustomization{
MinSize: disk.MinSize,
Partitions: make([]iblueprint.PartitionCustomization, len(disk.Partitions)),
}
for idx, part := range disk.Partitions {
ipart := iblueprint.PartitionCustomization{
Type: part.Type,
MinSize: part.MinSize,
BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{},
VGCustomization: iblueprint.VGCustomization{
Name: part.VGCustomization.Name,
},
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization(part.FilesystemTypedCustomization),
}

if len(part.LogicalVolumes) > 0 {
ipart.LogicalVolumes = make([]iblueprint.LVCustomization, len(part.LogicalVolumes))
for lvidx, lv := range part.LogicalVolumes {
ipart.LogicalVolumes[lvidx] = iblueprint.LVCustomization{
Name: lv.Name,
MinSize: lv.MinSize,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization(lv.FilesystemTypedCustomization),
}
}
}

if len(part.Subvolumes) > 0 {
ipart.Subvolumes = make([]iblueprint.BtrfsSubvolumeCustomization, len(part.Subvolumes))
for svidx, sv := range part.Subvolumes {
ipart.Subvolumes[svidx] = iblueprint.BtrfsSubvolumeCustomization(sv)
}
}

idisk.Partitions[idx] = ipart
}
customizations.Disk = idisk
}
if tz := c.Timezone; tz != nil {
itz := iblueprint.TimezoneCustomization(*tz)
customizations.Timezone = &itz
Expand Down
212 changes: 212 additions & 0 deletions internal/blueprint/blueprint_convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,112 @@ func TestConvert(t *testing.T) {
MinSize: 1024,
},
},
Disk: &DiskCustomization{
MinSize: 10240,
Partitions: []PartitionCustomization{
{
// this partition is invalid, since only one of
// btrfs, vg, or filesystem should be set, but
// the converter copies everything
// unconditionally, so let's test the full
// thing
Type: "plain",
MinSize: 1024,
BtrfsVolumeCustomization: BtrfsVolumeCustomization{
Subvolumes: []BtrfsSubvolumeCustomization{
{
Name: "subvol1",
Mountpoint: "/subvol1",
},
{
Name: "subvol2",
Mountpoint: "/subvol2",
},
},
},
VGCustomization: VGCustomization{
Name: "vg1",
LogicalVolumes: []LVCustomization{
{
Name: "vg1lv1",
MinSize: 0,
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/one",
Label: "one",
FSType: "xfs",
},
},
{
Name: "vg1lv2",
MinSize: 0,
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/two",
Label: "two",
FSType: "ext4",
},
},
},
},
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/root",
Label: "roothome",
FSType: "xfs",
},
},
{
Type: "plain",
MinSize: 1024,
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/root",
Label: "roothome",
FSType: "xfs",
},
},
{
Type: "lvm",
MinSize: 1024,
VGCustomization: VGCustomization{
Name: "vg1",
LogicalVolumes: []LVCustomization{
{
Name: "vg1lv1",
MinSize: 0,
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/one",
Label: "one",
FSType: "xfs",
},
},
{
Name: "vg1lv2",
MinSize: 0,
FilesystemTypedCustomization: FilesystemTypedCustomization{
Mountpoint: "/two",
Label: "two",
FSType: "ext4",
},
},
},
},
},
{
Type: "btrfs",
MinSize: 1024,
BtrfsVolumeCustomization: BtrfsVolumeCustomization{
Subvolumes: []BtrfsSubvolumeCustomization{
{
Name: "subvol1",
Mountpoint: "/subvol1",
},
{
Name: "subvol2",
Mountpoint: "/subvol2",
},
},
},
},
},
},
InstallationDevice: "/dev/sda",
FDO: &FDOCustomization{
ManufacturingServerURL: "http://manufacturing.fdo",
Expand Down Expand Up @@ -302,6 +408,112 @@ func TestConvert(t *testing.T) {
MinSize: 1024,
},
},
Disk: &iblueprint.DiskCustomization{
MinSize: 10240,
Partitions: []iblueprint.PartitionCustomization{
{
// this partition is invalid, since only one of
// btrfs, vg, or filesystem should be set, but
// the converter copies everything
// unconditionally, so let's test the full
// thing
Type: "plain",
MinSize: 1024,
BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{
Subvolumes: []iblueprint.BtrfsSubvolumeCustomization{
{
Name: "subvol1",
Mountpoint: "/subvol1",
},
{
Name: "subvol2",
Mountpoint: "/subvol2",
},
},
},
VGCustomization: iblueprint.VGCustomization{
Name: "vg1",
LogicalVolumes: []iblueprint.LVCustomization{
{
Name: "vg1lv1",
MinSize: 0,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/one",
Label: "one",
FSType: "xfs",
},
},
{
Name: "vg1lv2",
MinSize: 0,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/two",
Label: "two",
FSType: "ext4",
},
},
},
},
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/root",
Label: "roothome",
FSType: "xfs",
},
},
{
Type: "plain",
MinSize: 1024,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/root",
Label: "roothome",
FSType: "xfs",
},
},
{
Type: "lvm",
MinSize: 1024,
VGCustomization: iblueprint.VGCustomization{
Name: "vg1",
LogicalVolumes: []iblueprint.LVCustomization{
{
Name: "vg1lv1",
MinSize: 0,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/one",
Label: "one",
FSType: "xfs",
},
},
{
Name: "vg1lv2",
MinSize: 0,
FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{
Mountpoint: "/two",
Label: "two",
FSType: "ext4",
},
},
},
},
},
{
Type: "btrfs",
MinSize: 1024,
BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{
Subvolumes: []iblueprint.BtrfsSubvolumeCustomization{
{
Name: "subvol1",
Mountpoint: "/subvol1",
},
{
Name: "subvol2",
Mountpoint: "/subvol2",
},
},
},
},
},
},
InstallationDevice: "/dev/sda",
FDO: &iblueprint.FDOCustomization{
ManufacturingServerURL: "http://manufacturing.fdo",
Expand Down
1 change: 1 addition & 0 deletions internal/blueprint/customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Customizations struct {
Firewall *FirewallCustomization `json:"firewall,omitempty" toml:"firewall,omitempty"`
Services *ServicesCustomization `json:"services,omitempty" toml:"services,omitempty"`
Filesystem []FilesystemCustomization `json:"filesystem,omitempty" toml:"filesystem,omitempty"`
Disk *DiskCustomization `json:"disk,omitempty" toml:"disk,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a very stupid (sorry!) question - could we simply do:

iff --git a/internal/blueprint/customizations.go b/internal/blueprint/customiza
tions.go
index 9ec43401f..5efe3eb40 100644
--- a/internal/blueprint/customizations.go
+++ b/internal/blueprint/customizations.go
@@ -5,33 +5,34 @@ import (
        "reflect"
        "strings"
 
+       "github.com/osbuild/images/pkg/blueprint"
        "github.com/osbuild/images/pkg/disk"
 )
...
-       Disk               *DiskCustomization        `json:"disk,omitempty" toml:"disk,omitempty"`
+       Disk *blueprint.DiskCustomization `json:"disk,omitempty" toml:"disk,omitempty"`
...

here (and remove disk_customizations.go in this PR)?

And then we would add a "Validate()" that simply disallows the "dc.Type" (as it seems that is the only thing we do not support compared to the images disk_blueprint)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the work we're doing to unify blueprints, it might be a good idea to just drop the whole copy from here and make it use the one from images directly.

InstallationDevice string `json:"installation_device,omitempty" toml:"installation_device,omitempty"`
PartitioningMode string `json:"partitioning_mode,omitempty" toml:"partitioning_mode,omitempty"`
FDO *FDOCustomization `json:"fdo,omitempty" toml:"fdo,omitempty"`
Expand Down
Loading
Loading