From 4d46bbf712d3eb3c72c318bd051c1cefcf5dbebc Mon Sep 17 00:00:00 2001
From: Julia Kreger <juliaashleykreger@gmail.com>
Date: Fri, 5 Jul 2024 21:43:28 -0700
Subject: [PATCH] grub: directly load linked config file

While troubleshooting grub network boot issues,
I did some reading and found out our model of config
was technically wrong to use a menuentry to load config
in another menuentry which may or may not be loaded.

I mean it worked, but it is simpler to just say
"go source this content into our state".

Change-Id: I5e2ec2dc5110fa0a4f9e11478502a199354454f5
---
 ironic/drivers/modules/initial_grub_cfg.template         | 9 +++------
 ironic/tests/unit/common/test_pxe_utils.py               | 2 +-
 .../grub-default-template-change-a7bacdef4543a9ae.yaml   | 7 +++++++
 3 files changed, 11 insertions(+), 7 deletions(-)
 create mode 100644 releasenotes/notes/grub-default-template-change-a7bacdef4543a9ae.yaml

diff --git a/ironic/drivers/modules/initial_grub_cfg.template b/ironic/drivers/modules/initial_grub_cfg.template
index 3c1a2d76db..a4cf15079b 100644
--- a/ironic/drivers/modules/initial_grub_cfg.template
+++ b/ironic/drivers/modules/initial_grub_cfg.template
@@ -1,7 +1,4 @@
-set default=initial
-set timeout=5
-set hidden_timeout_quiet=false
+echo Booting from $prefix
+
+source {{ tftp_root }}/$net_default_mac.conf
 
-menuentry "initial"  {
-configfile {{ tftp_root }}/$net_default_mac.conf
-}
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 55661cd6d4..50cfb5ee0d 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -1248,7 +1248,7 @@ class TestPXEUtils(db_base.DbTestCase):
         def write_to_file(path, contents):
             self.assertIn('/grub/grub.cfg', path)
             self.assertIn(
-                'configfile /tftpboot/$net_default_mac.conf',
+                'source /tftpboot/$net_default_mac.conf',
                 contents
             )
 
diff --git a/releasenotes/notes/grub-default-template-change-a7bacdef4543a9ae.yaml b/releasenotes/notes/grub-default-template-change-a7bacdef4543a9ae.yaml
new file mode 100644
index 0000000000..a23c62de06
--- /dev/null
+++ b/releasenotes/notes/grub-default-template-change-a7bacdef4543a9ae.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Fixes the default grub initial configuration to be simpler and directly
+    load the generated configuration file. The template also includes output
+    which also help operators understand the context as to where the node is
+    booting from, should issues be encountered.