Skip to content
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
15 changes: 14 additions & 1 deletion pkg/distro/generic/bootc.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,21 @@ func NewBootcWithLoader(loader *defs.Loader, name string, cinfo *bootc.Info) (*B
if cinfo.Arch == "" {
missing = append(missing, "Arch")
}
// DefaultRootFs can be derived from the partition table in disk.yaml if not
// provided by the bootc container's install configuration. This allows
// containers to define their root filesystem type via disk.yaml instead of
// requiring bootc install print-configuration to return it.
if cinfo.DefaultRootFs == "" {
missing = append(missing, "DefaultRootFs")
if cinfo.OSInfo != nil && cinfo.OSInfo.PartitionTable != nil {
rootMountable := cinfo.OSInfo.PartitionTable.FindMountable("/")
if rootMountable != nil {
cinfo.DefaultRootFs = rootMountable.GetFSType()
}
}
// Only report as missing if we couldn't derive it from the partition table
if cinfo.DefaultRootFs == "" {
missing = append(missing, "DefaultRootFs")
}
}
if cinfo.Size == 0 {
missing = append(missing, "Size")
Expand Down
171 changes: 171 additions & 0 deletions pkg/distro/generic/bootc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,177 @@ func TestNewBootc(t *testing.T) {
expectedError: "failed to initialize bootc distro: missing required info: Arch, DefaultRootFs, Size, OSInfo",
},

"defaultrootfs-from-partition-table": {
// When DefaultRootFs is empty but disk.yaml provides a partition
// table with root filesystem, derive the fs type from the partition table
info: &bootc.Info{
Imgref: "example.com/containers/distro-bootc:version12",
ImageID: "acf88e518194fac963a1b2e2e4110e38a4ce5fb3fceddd624fae8997d4566930",
Arch: "x86_64",
Size: 100 * datasizes.MiB,
OSInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/",
},
},
},
},
},
},
expectedDistro: &BootcDistro{
imgref: "example.com/containers/distro-bootc:version12",
imageID: "acf88e518194fac963a1b2e2e4110e38a4ce5fb3fceddd624fae8997d4566930",
buildImgref: "example.com/containers/distro-bootc:version12",
sourceInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/",
},
},
},
},
},
buildSourceInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/",
},
},
},
},
},
id: distro.ID{
Name: "bootc-aos",
MajorVersion: 5000,
MinorVersion: -1,
},
releasever: "5000",
defaultFs: "ext4",
rootfsMinSize: 200 * datasizes.MiB,
arches: map[string]distro.Arch{
"x86_64": &architecture{
arch: arch.ARCH_X86_64,
},
},
},
},

"defaultrootfs-from-partition-table-btrfs": {
// Test with btrfs subvolumes as root filesystem
info: &bootc.Info{
Imgref: "example.com/containers/distro-bootc:version12",
ImageID: "acf88e518194fac963a1b2e2e4110e38a4ce5fb3fceddd624fae8997d4566930",
Arch: "x86_64",
Size: 100 * datasizes.MiB,
OSInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Btrfs{
Subvolumes: []disk.BtrfsSubvolume{
{
Name: "root",
Mountpoint: "/",
},
},
},
},
},
},
},
},
expectedDistro: &BootcDistro{
imgref: "example.com/containers/distro-bootc:version12",
imageID: "acf88e518194fac963a1b2e2e4110e38a4ce5fb3fceddd624fae8997d4566930",
buildImgref: "example.com/containers/distro-bootc:version12",
sourceInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Btrfs{
Subvolumes: []disk.BtrfsSubvolume{
{
Name: "root",
Mountpoint: "/",
},
},
},
},
},
},
},
buildSourceInfo: &osinfo.Info{
OSRelease: osinfo.OSRelease{
ID: "aos",
VersionID: "5000",
},
PartitionTable: &disk.PartitionTable{
Type: disk.PT_GPT,
Partitions: []disk.Partition{
{
Payload: &disk.Btrfs{
Subvolumes: []disk.BtrfsSubvolume{
{
Name: "root",
Mountpoint: "/",
},
},
},
},
},
},
},
id: distro.ID{
Name: "bootc-aos",
MajorVersion: 5000,
MinorVersion: -1,
},
releasever: "5000",
defaultFs: "btrfs",
rootfsMinSize: 200 * datasizes.MiB,
arches: map[string]distro.Arch{
"x86_64": &architecture{
arch: arch.ARCH_X86_64,
},
},
},
},

"osinfo-without-values": {
info: &bootc.Info{
Imgref: "example.com/containers/distro-bootc:version12",
Expand Down
Loading