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

Merged
28 changes: 23 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,30 @@ 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
INTERNAL_NETWORK: ["true"]
- CUSTOMIZATION_TYPE: "disk-plain"
RUNNER:
- aws/rhel-9.4-ga-x86_64
- aws/rhel-10.0-nightly-x86_64
INTERNAL_NETWORK: ["true"]
- CUSTOMIZATION_TYPE: "disk-lvm"
RUNNER:
- aws/rhel-9.6-nightly-x86_64
INTERNAL_NETWORK: ["true"]
- 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 @@ -305,6 +411,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"`
mvo5 marked this conversation as resolved.
Show resolved Hide resolved
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