Skip to content

Commit ad8e9c2

Browse files
committed
Avoid boot loop when there are dnf network issues
Only try to reboot when upgradePackages is true, and check the network connectivity before checking if a restart is needed. Also don't hide the stderr output, in case of any errors, and also show the list of packages that are requiring the reboot. Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
1 parent 4a3f723 commit ad8e9c2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55

66
set -eux
77

8+
[ "$LIMA_CIDATA_UPGRADE_PACKAGES" = "1" ] || exit 0
9+
810
# Check if cloud-init forgot to reboot_if_required
911
# (only implemented for apt at the moment, not dnf)
1012

1113
if command -v dnf >/dev/null 2>&1; then
1214
# dnf-utils needs to be installed, for needs-restarting
1315
if dnf -h needs-restarting >/dev/null 2>&1; then
14-
# needs-restarting returns "false" if needed (!)
15-
if ! dnf needs-restarting -r >/dev/null 2>&1; then
16-
systemctl reboot
16+
# check-update returns "false" (100) if updates (!)
17+
dnf check-update >/dev/null
18+
if [ "$?" != "1" ]; then
19+
# needs-restarting returns "false" if needed (!)
20+
if ! dnf needs-restarting -r; then
21+
systemctl reboot
22+
fi
1723
fi
1824
fi
1925
fi

pkg/cidata/cidata.TEMPLATE.d/lima.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PATH={{$yqProvision.Path}}
3232
LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PERMISSIONS={{$yqProvision.Permissions}}
3333
{{- end}}
3434
LIMA_CIDATA_GUEST_INSTALL_PREFIX={{ .GuestInstallPrefix }}
35+
{{- if .UpgradePackages}}
36+
LIMA_CIDATA_UPGRADE_PACKAGES=1
37+
{{- else}}
38+
LIMA_CIDATA_UPGRADE_PACKAGES=
39+
{{- end}}
3540
{{- if .Containerd.User}}
3641
LIMA_CIDATA_CONTAINERD_USER=1
3742
{{- else}}

0 commit comments

Comments
 (0)