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

[RHEL-10] add internal-only image types (COMPOSER-2357) #1067

Merged
merged 12 commits into from
Nov 28, 2024
Merged
262 changes: 185 additions & 77 deletions pkg/distro/rhel/rhel10/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,162 @@ import (
"github.com/osbuild/images/pkg/rpmmd"
)

func mkAMIImgTypeX86_64() *rhel.ImageType {
it := rhel.NewImageType(
"ami",
"image.raw",
"application/octet-stream",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: ec2PackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image"},
[]string{"image"},
)

it.KernelOptions = amiKernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultEc2ImageConfigX86_64()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

func mkAMIImgTypeAarch64() *rhel.ImageType {
it := rhel.NewImageType(
"ami",
"image.raw",
"application/octet-stream",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: ec2PackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image"},
[]string{"image"},
)

it.KernelOptions = amiAarch64KernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultEc2ImageConfig()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

// RHEL internal-only x86_64 EC2 image type
func mkEc2ImgTypeX86_64() *rhel.ImageType {
it := rhel.NewImageType(
"ec2",
"image.raw.xz",
"application/xz",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: ec2PackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image", "xz"},
[]string{"xz"},
)

it.Compression = "xz"
it.KernelOptions = amiKernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultEc2ImageConfigX86_64()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

// RHEL internal-only aarch64 EC2 image type
func mkEC2ImgTypeAarch64() *rhel.ImageType {
it := rhel.NewImageType(
"ec2",
"image.raw.xz",
"application/xz",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: ec2PackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image", "xz"},
[]string{"xz"},
)

it.Compression = "xz"
it.KernelOptions = amiAarch64KernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultEc2ImageConfig()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

// RHEL internal-only x86_64 EC2 HA image type
func mkEc2HaImgTypeX86_64() *rhel.ImageType {
it := rhel.NewImageType(
"ec2-ha",
"image.raw.xz",
"application/xz",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: rhelEc2HaPackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image", "xz"},
[]string{"xz"},
)

it.Compression = "xz"
it.KernelOptions = amiKernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultEc2ImageConfigX86_64()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

func mkEC2SapImgTypeX86_64(osVersion string) *rhel.ImageType {
it := rhel.NewImageType(
"ec2-sap",
"image.raw.xz",
"application/xz",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: rhelEc2SapPackageSet,
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image", "xz"},
[]string{"xz"},
)

it.Compression = "xz"
it.KernelOptions = amiSapKernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = sapImageConfig(osVersion).InheritFrom(defaultEc2ImageConfigX86_64())
it.BasePartitionTables = defaultBasePartitionTables

return it
}

// IMAGE CONFIG

// TODO: move these to the EC2 environment
const amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295"
const (
amiKernelOptions = "console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295"
amiAarch64KernelOptions = amiKernelOptions + " iommu.strict=0"
amiSapKernelOptions = amiKernelOptions + " processor.max_cstate=1 intel_idle.max_cstate=1"
)

// default EC2 images config (common for all architectures)
func baseEc2ImageConfig() *distro.ImageConfig {
func defaultEc2ImageConfig() *distro.ImageConfig {
return &distro.ImageConfig{
Locale: common.ToPtr("en_US.UTF-8"),
Timezone: common.ToPtr("UTC"),
Expand Down Expand Up @@ -120,32 +271,28 @@ func baseEc2ImageConfig() *distro.ImageConfig {
}
}

// Default AMI (custom image built by users) images config.
// The configuration does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
func defaultAMIImageConfig() *distro.ImageConfig {
return baseEc2ImageConfig()
func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig {
ic.DracutConf = append(ic.DracutConf,
&osbuild.DracutConfStageOptions{
Filename: "ec2.conf",
Config: osbuild.DracutConfigFile{
AddDrivers: []string{
"nvme",
"xen-blkfront",
},
},
})
return ic
}

// Default AMI x86_64 (custom image built by users) images config.
// The configuration does not touch the RHSM configuration at all.
// https://issues.redhat.com/browse/COMPOSER-2157
func defaultAMIImageConfigX86_64() *distro.ImageConfig {
ic := defaultAMIImageConfig()
func defaultEc2ImageConfigX86_64() *distro.ImageConfig {
ic := defaultEc2ImageConfig()
return appendEC2DracutX86_64(ic)
}

// common ec2 image build package set
func ec2BuildPackageSet(t *rhel.ImageType) rpmmd.PackageSet {
return distroBuildPackageSet(t).Append(
rpmmd.PackageSet{
Include: []string{
"python3-pyyaml",
},
})
}
// PACKAGE SETS

func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet {
func ec2PackageSet(t *rhel.ImageType) rpmmd.PackageSet {
ps := rpmmd.PackageSet{
Include: []string{
"@core",
Expand Down Expand Up @@ -202,63 +349,24 @@ func ec2CommonPackageSet(t *rhel.ImageType) rpmmd.PackageSet {
return ps
}

func mkAMIImgTypeX86_64() *rhel.ImageType {
it := rhel.NewImageType(
"ami",
"image.raw",
"application/octet-stream",
map[string]rhel.PackageSetFunc{
rhel.OSPkgsKey: ec2CommonPackageSet,
// rhel-ha-ec2 image package set
func rhelEc2HaPackageSet(t *rhel.ImageType) rpmmd.PackageSet {
ec2HaPackageSet := ec2PackageSet(t)
ec2HaPackageSet = ec2HaPackageSet.Append(rpmmd.PackageSet{
Include: []string{
"fence-agents-all",
"pacemaker",
"pcs",
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image"},
[]string{"image"},
)

it.KernelOptions = amiKernelOptions
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultAMIImageConfigX86_64()
it.BasePartitionTables = defaultBasePartitionTables

return it
})
return ec2HaPackageSet
}

func mkAMIImgTypeAarch64() *rhel.ImageType {
it := rhel.NewImageType(
"ami",
"image.raw",
"application/octet-stream",
map[string]rhel.PackageSetFunc{
rhel.BuildPkgsKey: ec2BuildPackageSet,
rhel.OSPkgsKey: ec2CommonPackageSet,
// rhel-sap-ec2 image package set
func rhelEc2SapPackageSet(t *rhel.ImageType) rpmmd.PackageSet {
return rpmmd.PackageSet{
Include: []string{
//"libcanberra-gtk2", // libcanberra-gtk2 is not available in RHEL-10
},
rhel.DiskImage,
[]string{"build"},
[]string{"os", "image"},
[]string{"image"},
)

it.KernelOptions = "console=ttyS0,115200n8 console=tty0 nvme_core.io_timeout=4294967295 iommu.strict=0"
it.Bootable = true
it.DefaultSize = 10 * datasizes.GibiByte
it.DefaultImageConfig = defaultAMIImageConfig()
it.BasePartitionTables = defaultBasePartitionTables

return it
}

func appendEC2DracutX86_64(ic *distro.ImageConfig) *distro.ImageConfig {
ic.DracutConf = append(ic.DracutConf,
&osbuild.DracutConfStageOptions{
Filename: "ec2.conf",
Config: osbuild.DracutConfigFile{
AddDrivers: []string{
"nvme",
"xen-blkfront",
},
},
})
return ic
}.Append(ec2PackageSet(t)).Append(SapPackageSet(t))
}
Loading
Loading