Merge ~raharper/curtin:fix/centos-grub into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: a011d9d8e965fd87e737a380e6fa3423b6ee3634
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:fix/centos-grub
Merge into: curtin:master
Diff against target: 64 lines (+19/-13)
1 file modified
examples/tests/centos_defaults.yaml (+19/-13)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+399028@code.launchpad.net

Commit message

vmtest/centos: handle different paths to grub config

Centos images used to always have grub installed at
/boot/grub/grub.conf. The most recent build of centos70,
centos70/amd64/20210210_01/root-tgz, now has grub conf located at
/boot/grub2/grub.cfg. This patch checks for either path before
running the sed fixup command.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

As discussed on IRC this is possibly more than is needed. Indeed it seems that MAAS no longer publishes centos 6 images at all so maybe all of this can be droppped. But it fixes the tests so I'm going to merge this and then we can work on cleaning it up later.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/examples/tests/centos_defaults.yaml b/examples/tests/centos_defaults.yaml
2index 85e1c03..94e2ae8 100644
3--- a/examples/tests/centos_defaults.yaml
4+++ b/examples/tests/centos_defaults.yaml
5@@ -27,7 +27,7 @@ write_files:
6 [ -e "$ofile" ] || return 0
7 cp "$ofile" "$bk" || rerror "failed backup ($ofile -> $bk):" "$@";
8 }
9-
10+
11 update_grub1() {
12 local cfg="$1" r=""
13 [ -e "$cfg" ] ||
14@@ -48,7 +48,7 @@ write_files:
15 { rerror "failed to update grub1 cfg '$cfg'."; return; }
16 info "updated grub1 cfg '$cfg'."
17 }
18-
19+
20 update_grub2() {
21 local cfg="$1" defgrub="$2"
22 [ -e "$cfg" ] || { info "no grub2 config '$cfg'"; return 0; }
23@@ -56,8 +56,8 @@ write_files:
24 sed -i -e '/kernel/n' -e '/console=/n' \
25 -e "s/root=\([^ ]*\)/root=\1 ${CONPARM}/" "$cfg" ||
26 { rerror "failed to update grub2 '$cfg'"; return; }
27-
28- # update /etc/default/grub. any GRUB_CMDLINE_LINUX remove
29+
30+ # update /etc/default/grub. any GRUB_CMDLINE_LINUX remove
31 # any console= and add conparm at the beginning.
32 local var="GRUB_CMDLINE_LINUX" msg="updated grub2 '$cfg'."
33 if [ ! -e "$defgrub" ]; then
34@@ -77,15 +77,21 @@ write_files:
35 update_grub1 "$grub1conf" || fail "failed update grub1"
36 update_grub2 "$grub2conf" "$grub2def" || fail "failed update grub2"
37
38+
39+# centos66 images include grub 0.97 which will detect vmtests' ephemeral disk
40+# and the install disk which leaves grub configured with two disks. When
41+# vmtest reboots into installed disk, there is only one disk and the grub
42+# map is no longer valid. Here in 00_grub, we switch hd1 to hd0. MAAS
43+# is not affected as their ephemeral image (iscsi or http) is not discovered
44+# by grub and therefor the device.map doesn't contain a second device. Cent7
45+# has grub2 which uses root by UUID.
46+_update_grub_conf:
47+ - &update_grub |
48+ CONF="/boot/grub2/grub.cfg"
49+ [ -f "${CONF}" ] || CONF="/boot/grub/grub.conf"
50+ sed -i.curtin -e 's|(hd1,0)|(hd0,0)|g' ${CONF}
51+
52 late_commands:
53- # centos66 images include grub 0.97 which will detect vmtests' ephemeral disk
54- # and the install disk which leaves grub configured with two disks. When
55- # vmtest reboots into installed disk, there is only one disk and the grub
56- # map is no longer valid. Here in 00_grub, we switch hd1 to hd0. MAAS
57- # is not affected as their ephemeral image (iscsi or http) is not discovered
58- # by grub and therefor the device.map doesn't contain a second device. Cent7
59- # has grub2 which uses root by UUID
60- 00_grub1_boot: [curtin, in-target, --, sed, -i.curtin, -e,
61- 's|(hd1,0)|(hd0,0)|g', /boot/grub/grub.conf]
62+ 00_grub1_boot: [curtin, in-target, --, 'sh', '-c', *update_grub]
63 # vmtest wants output to go to serial console so we update grub inside.
64 00_grub_serial: [curtin, in-target, --, '/root/curtin-send-console-to-serial']

Subscribers

People subscribed via source and target branches