Skip to content

Conversation

@afbjorklund
Copy link
Member

@afbjorklund afbjorklund commented Dec 8, 2025

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.

Closes #4440

first boot:

+ command -v dnf
+ dnf -h needs-restarting
+ dnf check-update
Updating and loading repositories:
Repositories loaded.
+ '[' 0 '!=' 1 ']'
+ dnf needs-restarting -r
Updating and loading repositories:
 Fedora 43 openh264 (From Cisco) - x86_ 100% |   1.6 KiB/s |  10.1 KiB |  00m06s
 Fedora 43 - x86_64 - Updates           100% |   1.7 MiB/s |  21.9 MiB |  00m13s
 Fedora 43 - x86_64                     100% |   2.2 MiB/s |  57.8 MiB |  00m26s
Repositories loaded.
Core libraries or services have been updated since boot-up:
  * glib2
  * gnutls
  * kernel-core
  * kernel-modules-core
  * libxcrypt
  * openssl-libs
  * systemd

Reboot is required to fully utilize these updates.
More information: https://access.redhat.com/solutions/27943
+ systemctl reboot

Broadcast message from root@localhost (Mon 2025-12-08 12:46:02 CET):

The system will reboot now!

second boot:

+ command -v dnf
+ dnf -h needs-restarting
+ dnf check-update
Updating and loading repositories:
Repositories loaded.
+ '[' 0 '!=' 1 ']'
+ dnf needs-restarting -r
Updating and loading repositories:
Repositories loaded.
No core libraries or services have been updated since boot-up.
Reboot should not be necessary.

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand which part of the PR is supposed to stop the reboot loop in case there is a network problem.

@afbjorklund

This comment was marked as resolved.

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>
dnf check-update >/dev/null
if [ "$?" != "1" ]; then
# needs-restarting returns "false" if needed (!)
if ! dnf needs-restarting -r; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the command fails due to other reasons, this results in reboot loop too?
Should this match the stdout/stderr to avoid that?

Copy link
Member Author

@afbjorklund afbjorklund Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit codes are hopelessly confused, scraping the plugin output could make it worse

But I think it is possible, as long as you select the C locale (the messages are translated)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the output is unclear it should default to avoid the potential reboot loop

@afbjorklund
Copy link
Member Author

afbjorklund commented Dec 17, 2025

I don't understand which part of the PR is supposed to stop the reboot loop in case there is a network problem.

The check-update will return an error in that case (just need to check that it is not 100, which means "updates")

Also it now checks if the upgradePackages flag is used...

If the feature is not activated (the default), the script exits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

guest/fedora Guest: Fedora

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fedora Lima image gets stuck in reboot loop if mirror is unavailable

3 participants