Repository: osbuild/osbuild-composer
Pull request #1656 (2021-08-23 09:41:17)

RHEL-85/90: modify the x86_64 EC2 images dracut configuration
Change the x86_64-specific dracut configuration of RHEL-8.5 and RHEL-9.0 EC2 and AMI images to not include `xen-netfront` driver and add `nvme` driver, which was previously not included. Since the configuration is no
longer Xen-specific, rename the configuration file to `ec2.conf`.

Justification:
There is no reason to put `xen-netfront` to initramfs as EC2 images don't boot from network root. In addition, 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).

Related to https://issues.redhat.com/browse/COMPOSER-1096.

Signed-off-by: Tomas Hozza <thozza@redhat.com>


This pull request includes:

- [x] adequate testing for the new functionality or fixed issue
  - image test cases were modified 
- [ ] adequate documentation informing people about the change such as
  - [ ] create a file in [news/unreleased](https://github.com/osbuild/osbuild-composer/tree/main/docs/news/unreleased) directory if this change should be mentioned in the release news
  - [ ] submit a PR for the [guides](https://github.com/osbuild/guides) repository if this PR changed any behavior described there: https://www.osbuild.org/guides/

<!--
Thanks for proposing a change to osbuild-composer!

Please don't remove the above check list. These are things that each pull
request must have before it is merged. It helps maintainers to not forget
anything.

If the reason for ticking any of the boxes is ambiguous, please add a short
note explaining why.

For user-visible changes, "adequate documentation" is an entry describing the
change for users in docs/news. Please refer to docs/news/README.md for details.

In addition, if this pull request fixes a downstream issue, please refer to
test/README.md and add these additional items:

- [ ] 1st commit of any `rhbz#` related PR contains bug reproducer; CI reports FAIL or
- [ ] PR contains automated tests for new functionality and
- [ ] QE has approved reproducer/new tests and
- [ ] Subsequent commits provide bug fixes without modifying the reproducer; CI reports PASS and
- [ ] QE approves this PR; RHBZ status is set to `MODIFIED + Verified=Tested`
-->


thozza: @teg I had to force push, because I replaced the link to Jira ticket in the source code with a comment explaining part of the configuration. The PR should be now finalised.

Patch:
diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go
index 702870f68..3452f1079 100644
--- a/internal/distro/rhel85/pipelines.go
+++ b/internal/distro/rhel85/pipelines.go
@@ -389,11 +389,13 @@ func ec2X86_64BaseTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.Packag
 	}
 
 	// 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: "xen.conf",
+		Filename: "ec2.conf",
 		Config: osbuild.DracutConfigFile{
 			AddDrivers: []string{
-				"xen-netfront",
+				"nvme",
 				"xen-blkfront",
 			},
 		},
diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go
index bd5ade2e7..3c4b7acd0 100644
--- a/internal/distro/rhel90/pipelines.go
+++ b/internal/distro/rhel90/pipelines.go
@@ -370,11 +370,13 @@ func ec2X86_64BaseTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.Packag
 	}
 
 	// 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: "xen.conf",
+		Filename: "ec2.conf",
 		Config: osbuild.DracutConfigFile{
 			AddDrivers: []string{
-				"xen-netfront",
+				"nvme",
 				"xen-blkfront",
 			},
 		},
diff --git a/internal/distro/rhel90/stage_options.go b/internal/distro/rhel90/stage_options.go
index 95a20c6b3..20e9047b7 100644
--- a/internal/distro/rhel90/stage_options.go
+++ b/internal/distro/rhel90/stage_options.go
@@ -332,7 +332,8 @@ func grub2StageOptions(rootPartition *disk.Partition, bootPartition *disk.Partit
 
 	if uefi {
 		stageOptions.UEFI = &osbuild.GRUB2UEFI{
-			Vendor: "redhat",
+			Vendor:  "redhat",
+			Unified: legacy == "", // force unified grub scheme for pure efi systems
 		}
 	}
 
diff --git a/internal/osbuild2/grub2_stage.go b/internal/osbuild2/grub2_stage.go
index 7ed0a0a97..4f416a706 100644
--- a/internal/osbuild2/grub2_stage.go
+++ b/internal/osbuild2/grub2_stage.go
@@ -20,7 +20,9 @@ type GRUB2StageOptions struct {
 }
 
 type GRUB2UEFI struct {
-	Vendor string `json:"vendor"`
+	Vendor  string `json:"vendor"`
+	Install bool   `json:"install,omitempty"`
+	Unified bool   `json:"unified,omitempty"`
 }
 
 func (GRUB2StageOptions) isStageOptions() {}


Test patch:
diff --git a/test/data/manifests/rhel_85-x86_64-ami-boot.json b/test/data/manifests/rhel_85-x86_64-ami-boot.json
index 310a36010..a564f6193 100644
--- a/test/data/manifests/rhel_85-x86_64-ami-boot.json
+++ b/test/data/manifests/rhel_85-x86_64-ami-boot.json
@@ -1073,10 +1073,10 @@
           {
             "type": "org.osbuild.dracut.conf",
             "options": {
-              "filename": "xen.conf",
+              "filename": "ec2.conf",
               "config": {
                 "add_drivers": [
-                  "xen-netfront",
+                  "nvme",
                   "xen-blkfront"
                 ]
               }
diff --git a/test/data/manifests/rhel_85-x86_64-ec2-boot.json b/test/data/manifests/rhel_85-x86_64-ec2-boot.json
index 4440dfe8c..f2e388c14 100644
--- a/test/data/manifests/rhel_85-x86_64-ec2-boot.json
+++ b/test/data/manifests/rhel_85-x86_64-ec2-boot.json
@@ -1077,10 +1077,10 @@
           {
             "type": "org.osbuild.dracut.conf",
             "options": {
-              "filename": "xen.conf",
+              "filename": "ec2.conf",
               "config": {
                 "add_drivers": [
-                  "xen-netfront",
+                  "nvme",
                   "xen-blkfront"
                 ]
               }
diff --git a/test/data/manifests/rhel_85-x86_64-ec2_ha-boot.json b/test/data/manifests/rhel_85-x86_64-ec2_ha-boot.json
index 15e357b25..60dc2761c 100644
--- a/test/data/manifests/rhel_85-x86_64-ec2_ha-boot.json
+++ b/test/data/manifests/rhel_85-x86_64-ec2_ha-boot.json
@@ -1251,10 +1251,10 @@
           {
             "type": "org.osbuild.dracut.conf",
             "options": {
-              "filename": "xen.conf",
+              "filename": "ec2.conf",
               "config": {
                 "add_drivers": [
-                  "xen-netfront",
+                  "nvme",
                   "xen-blkfront"
                 ]
               }
diff --git a/test/data/manifests/rhel_90-aarch64-ami-boot.json b/test/data/manifests/rhel_90-aarch64-ami-boot.json
index ceb40c7ef..5cc73a640 100644
--- a/test/data/manifests/rhel_90-aarch64-ami-boot.json
+++ b/test/data/manifests/rhel_90-aarch64-ami-boot.json
@@ -1018,6 +1018,7 @@
               "boot_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
               "kernel_opts": "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
               "uefi": {
+                "unified": true,
                 "vendor": "redhat"
               },
               "saved_entry": "ffffffffffffffffffffffffffffffff-5.14.0-0.rc3.29.el9.aarch64"
@@ -9920,4 +9921,4 @@
     },
     "timezone": "UTC"
   }
-}
+}
\ No newline at end of file
diff --git a/test/data/manifests/rhel_90-aarch64-qcow2-boot.json b/test/data/manifests/rhel_90-aarch64-qcow2-boot.json
index d2bb32cb6..71b3c527d 100644
--- a/test/data/manifests/rhel_90-aarch64-qcow2-boot.json
+++ b/test/data/manifests/rhel_90-aarch64-qcow2-boot.json
@@ -920,6 +920,7 @@
               "root_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
               "kernel_opts": "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto",
               "uefi": {
+                "unified": true,
                 "vendor": "redhat"
               },
               "saved_entry": "ffffffffffffffffffffffffffffffff-5.14.0-0.rc3.29.el9.aarch64"
@@ -9866,4 +9867,4 @@
     },
     "timezone": "New_York"
   }
-}
+}
\ No newline at end of file
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 67edf0330..fd4e5e4d3 100644
--- a/test/data/manifests/rhel_90-x86_64-ami-boot.json
+++ b/test/data/manifests/rhel_90-x86_64-ami-boot.json
@@ -973,10 +973,10 @@
           {
             "type": "org.osbuild.dracut.conf",
             "options": {
-              "filename": "xen.conf",
+              "filename": "ec2.conf",
               "config": {
                 "add_drivers": [
-                  "xen-netfront",
+                  "nvme",
                   "xen-blkfront"
                 ]
               }