From ad8e9c25b0201c77bca4776b3ee72c485dd0c2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Mon, 8 Dec 2025 12:54:08 +0100 Subject: [PATCH] Avoid boot loop when there are dnf network issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../cidata.TEMPLATE.d/boot/00-reboot-if-required.sh | 12 +++++++++--- pkg/cidata/cidata.TEMPLATE.d/lima.env | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh index fe75c1ae72e..49cf166ca7b 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh @@ -5,15 +5,21 @@ set -eux +[ "$LIMA_CIDATA_UPGRADE_PACKAGES" = "1" ] || exit 0 + # Check if cloud-init forgot to reboot_if_required # (only implemented for apt at the moment, not dnf) if command -v dnf >/dev/null 2>&1; then # dnf-utils needs to be installed, for needs-restarting if dnf -h needs-restarting >/dev/null 2>&1; then - # needs-restarting returns "false" if needed (!) - if ! dnf needs-restarting -r >/dev/null 2>&1; then - systemctl reboot + # check-update returns "false" (100) if updates (!) + dnf check-update >/dev/null + if [ "$?" != "1" ]; then + # needs-restarting returns "false" if needed (!) + if ! dnf needs-restarting -r; then + systemctl reboot + fi fi fi fi diff --git a/pkg/cidata/cidata.TEMPLATE.d/lima.env b/pkg/cidata/cidata.TEMPLATE.d/lima.env index 8cd9453ccdc..4c78fe814a6 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/lima.env +++ b/pkg/cidata/cidata.TEMPLATE.d/lima.env @@ -32,6 +32,11 @@ LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PATH={{$yqProvision.Path}} LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PERMISSIONS={{$yqProvision.Permissions}} {{- end}} LIMA_CIDATA_GUEST_INSTALL_PREFIX={{ .GuestInstallPrefix }} +{{- if .UpgradePackages}} +LIMA_CIDATA_UPGRADE_PACKAGES=1 +{{- else}} +LIMA_CIDATA_UPGRADE_PACKAGES= +{{- end}} {{- if .Containerd.User}} LIMA_CIDATA_CONTAINERD_USER=1 {{- else}}