From 43ea54f8de3379db26279c369b79a947ecbdecce Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Fri, 17 Dec 2021 12:28:57 +0100 Subject: [PATCH] RHEL-90: replace `ec2X86_64BaseTreePipeline` by `osPipeline` Move the x86_64 specific configuration from `ec2X86_64BaseTreePipeline` to x86_64-specific image configurations for EC2 / AMI images. As a result, remove the `ec2X86_64BaseTreePipeline` entirely and replace it with `osPipeline`. Regenerate image test cases. While there are changed in the manifests, the actual image configuration didn't change at all and thus the `image-info` report was not changed. Signed-off-by: Tomas Hozza --- internal/distro/rhel90/distro.go | 27 ++++++++--- internal/distro/rhel90/pipelines.go | 45 +------------------ .../manifests/rhel_90-x86_64-ami-boot.json | 24 +++++----- .../manifests/rhel_90-x86_64-ec2-boot.json | 24 +++++----- .../manifests/rhel_90-x86_64-ec2_ha-boot.json | 24 +++++----- .../rhel_90-x86_64-ec2_sap-boot.json | 24 +++++----- 6 files changed, 72 insertions(+), 96 deletions(-) diff --git a/internal/distro/rhel90/distro.go b/internal/distro/rhel90/distro.go index b76266ff9..2b040b564 100644 --- a/internal/distro/rhel90/distro.go +++ b/internal/distro/rhel90/distro.go @@ -808,7 +808,7 @@ func newDistro(distroName string) distro.Distro { basePartitionTables: defaultBasePartitionTables, } - // default EC2 images config + // default EC2 images config (common for all architectures) defaultEc2ImageConfig := &distro.ImageConfig{ Timezone: "UTC", TimeSynchronization: &osbuild.ChronyStageOptions{ @@ -947,6 +947,22 @@ func newDistro(distroName string) distro.Distro { }, } + // default EC2 images config (x86_64) + defaultEc2ImageConfigX86_64 := &distro.ImageConfig{ + DracutConf: append(defaultEc2ImageConfig.DracutConf, + &osbuild.DracutConfStageOptions{ + Filename: "ec2.conf", + Config: osbuild.DracutConfigFile{ + AddDrivers: []string{ + "nvme", + "xen-blkfront", + }, + }, + }), + } + defaultEc2ImageConfigX86_64 = defaultEc2ImageConfigX86_64.InheritFrom(defaultEc2ImageConfig) + + // default AMI (EC2 BYOS) images config defaultAMIImageConfig := &distro.ImageConfig{ RHSMConfig: map[distro.RHSMSubscriptionStatus]*osbuild.RHSMStageOptions{ distro.RHSMConfigNoSubscription: { @@ -976,6 +992,7 @@ func newDistro(distroName string) distro.Distro { }, }, } + defaultAMIImageConfigX86_64 := defaultAMIImageConfig.InheritFrom(defaultEc2ImageConfigX86_64) defaultAMIImageConfig = defaultAMIImageConfig.InheritFrom(defaultEc2ImageConfig) amiImgTypeX86_64 := imageType{ @@ -986,7 +1003,7 @@ func newDistro(distroName string) distro.Distro { buildPkgsKey: ec2BuildPackageSet, osPkgsKey: ec2CommonPackageSet, }, - defaultImageConfig: defaultAMIImageConfig, + defaultImageConfig: defaultAMIImageConfigX86_64, kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto", bootable: true, bootType: distro.LegacyBootType, @@ -1025,7 +1042,7 @@ func newDistro(distroName string) distro.Distro { buildPkgsKey: ec2BuildPackageSet, osPkgsKey: rhelEc2PackageSet, }, - defaultImageConfig: defaultEc2ImageConfig, + defaultImageConfig: defaultEc2ImageConfigX86_64, kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto", bootable: true, bootType: distro.LegacyBootType, @@ -1064,7 +1081,7 @@ func newDistro(distroName string) distro.Distro { buildPkgsKey: ec2BuildPackageSet, osPkgsKey: rhelEc2HaPackageSet, }, - defaultImageConfig: defaultEc2ImageConfig, + defaultImageConfig: defaultEc2ImageConfigX86_64, kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto", bootable: true, bootType: distro.LegacyBootType, @@ -1084,7 +1101,7 @@ func newDistro(distroName string) distro.Distro { buildPkgsKey: ec2BuildPackageSet, osPkgsKey: rhelEc2SapPackageSet, }, - defaultImageConfig: defaultEc2ImageConfig, + defaultImageConfig: defaultEc2ImageConfigX86_64, kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto processor.max_cstate=1 intel_idle.max_cstate=1", bootable: true, bootType: distro.LegacyBootType, diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index 74f027e3c..2669e2184 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -144,30 +144,6 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations, return pipelines, nil } -func ec2X86_64BaseTreePipeline(t *imageType, repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, bpPackages []rpmmd.PackageSpec, - c *blueprint.Customizations, options distro.ImageOptions, pt *disk.PartitionTable) (*osbuild.Pipeline, error) { - - treePipeline, err := osPipeline(t, repos, packages, bpPackages, c, options, pt) - if err != nil { - return nil, err - } - - // EC2 x86_64-specific stages - // Add 'nvme' driver to handle the case when initramfs is getting forcefully - // rebuild on a Xen instance (and not able to boot on Nitro after that). - treePipeline.AddStage(osbuild.NewDracutConfStage(&osbuild.DracutConfStageOptions{ - Filename: "ec2.conf", - Config: osbuild.DracutConfigFile{ - AddDrivers: []string{ - "nvme", - "xen-blkfront", - }, - }, - })) - - return treePipeline, nil -} - func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand, diskfile string) ([]osbuild.Pipeline, error) { @@ -179,17 +155,7 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations, return nil, err } - var treePipeline *osbuild.Pipeline - switch arch := t.arch.Name(); arch { - // rhel-ec2-x86_64, rhel-ha-ec2 - case distro.X86_64ArchName: - treePipeline, err = ec2X86_64BaseTreePipeline(t, repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, &partitionTable) - // rhel-ec2-aarch64 - case distro.Aarch64ArchName: - treePipeline, err = osPipeline(t, repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, &partitionTable) - default: - return nil, fmt.Errorf("ec2CommonPipelines: unsupported image architecture: %q", arch) - } + treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, &partitionTable) if err != nil { return nil, err } @@ -218,14 +184,7 @@ func ec2SapPipelines(t *imageType, customizations *blueprint.Customizations, opt return nil, err } - var treePipeline *osbuild.Pipeline - switch arch := t.arch.Name(); arch { - // rhel-sap-ec2 - case distro.X86_64ArchName: - treePipeline, err = ec2X86_64BaseTreePipeline(t, repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, &partitionTable) - default: - return nil, fmt.Errorf("ec2SapPipelines: unsupported image architecture: %q", arch) - } + treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], packageSetSpecs[blueprintPkgsKey], customizations, options, &partitionTable) if err != nil { return nil, err } diff --git a/test/data/manifests/rhel_90-x86_64-ami-boot.json b/test/data/manifests/rhel_90-x86_64-ami-boot.json index cb795c1b9..614d8da79 100644 --- a/test/data/manifests/rhel_90-x86_64-ami-boot.json +++ b/test/data/manifests/rhel_90-x86_64-ami-boot.json @@ -942,6 +942,18 @@ } } }, + { + "type": "org.osbuild.dracut.conf", + "options": { + "filename": "ec2.conf", + "config": { + "add_drivers": [ + "nvme", + "xen-blkfront" + ] + } + } + }, { "type": "org.osbuild.systemd.unit", "options": { @@ -960,18 +972,6 @@ "profile": "sssd" } }, - { - "type": "org.osbuild.dracut.conf", - "options": { - "filename": "ec2.conf", - "config": { - "add_drivers": [ - "nvme", - "xen-blkfront" - ] - } - } - }, { "type": "org.osbuild.fstab", "options": { diff --git a/test/data/manifests/rhel_90-x86_64-ec2-boot.json b/test/data/manifests/rhel_90-x86_64-ec2-boot.json index c6377c403..127e6846d 100644 --- a/test/data/manifests/rhel_90-x86_64-ec2-boot.json +++ b/test/data/manifests/rhel_90-x86_64-ec2-boot.json @@ -958,6 +958,18 @@ } } }, + { + "type": "org.osbuild.dracut.conf", + "options": { + "filename": "ec2.conf", + "config": { + "add_drivers": [ + "nvme", + "xen-blkfront" + ] + } + } + }, { "type": "org.osbuild.systemd.unit", "options": { @@ -976,18 +988,6 @@ "profile": "sssd" } }, - { - "type": "org.osbuild.dracut.conf", - "options": { - "filename": "ec2.conf", - "config": { - "add_drivers": [ - "nvme", - "xen-blkfront" - ] - } - } - }, { "type": "org.osbuild.fstab", "options": { diff --git a/test/data/manifests/rhel_90-x86_64-ec2_ha-boot.json b/test/data/manifests/rhel_90-x86_64-ec2_ha-boot.json index fc97d5d0b..45580fc43 100644 --- a/test/data/manifests/rhel_90-x86_64-ec2_ha-boot.json +++ b/test/data/manifests/rhel_90-x86_64-ec2_ha-boot.json @@ -1152,6 +1152,18 @@ } } }, + { + "type": "org.osbuild.dracut.conf", + "options": { + "filename": "ec2.conf", + "config": { + "add_drivers": [ + "nvme", + "xen-blkfront" + ] + } + } + }, { "type": "org.osbuild.systemd.unit", "options": { @@ -1170,18 +1182,6 @@ "profile": "sssd" } }, - { - "type": "org.osbuild.dracut.conf", - "options": { - "filename": "ec2.conf", - "config": { - "add_drivers": [ - "nvme", - "xen-blkfront" - ] - } - } - }, { "type": "org.osbuild.fstab", "options": { diff --git a/test/data/manifests/rhel_90-x86_64-ec2_sap-boot.json b/test/data/manifests/rhel_90-x86_64-ec2_sap-boot.json index c89a5e49c..8791c9e26 100644 --- a/test/data/manifests/rhel_90-x86_64-ec2_sap-boot.json +++ b/test/data/manifests/rhel_90-x86_64-ec2_sap-boot.json @@ -1206,6 +1206,18 @@ } } }, + { + "type": "org.osbuild.dracut.conf", + "options": { + "filename": "ec2.conf", + "config": { + "add_drivers": [ + "nvme", + "xen-blkfront" + ] + } + } + }, { "type": "org.osbuild.systemd.unit", "options": { @@ -1224,18 +1236,6 @@ "profile": "sssd" } }, - { - "type": "org.osbuild.dracut.conf", - "options": { - "filename": "ec2.conf", - "config": { - "add_drivers": [ - "nvme", - "xen-blkfront" - ] - } - } - }, { "type": "org.osbuild.selinux.config", "options": {