Bug 2211844

Summary: `dnf offline-upgrade reboot --poweroff` doesn't poweroff after upgrade
Product: [Fedora] Fedora Reporter: konradmb <konradmb>
Component: dnf-plugins-coreAssignee: Jan Kolarik <jkolarik>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: daniel.mach, jkolarik, jmracek, mblaha, packaging-team-maint, pkratoch, praiskup, rpm-software-management
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: dnf-plugins-core-4.4.2-1.fc37 dnf-plugins-core-4.4.2-1.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2214510 (view as bug list) Environment:
Last Closed: 2023-07-29 01:19:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2214510    
Attachments:
Description Flags
Journal from CLI attempt
none
Journal from GUI attempt none

Description konradmb@o2.pl 2023-06-02 08:32:08 UTC
Man page for `dnf-offline-upgrade` specifies:
"       --poweroff
              When applied with the reboot subcommand, the system  will  power
              off after upgrades are completed, instead of restarting."

Adding `--poweroff` doesn't change the default behaviour of `dnf offline-upgrade reboot`. The system reboots instead as without the `--poweroff` option.

Reproducible: Always

Steps to Reproduce:
1. `sudo dnf offline-upgrade download`
2. `sudo dnf offline-upgrade reboot --poweroff`

Actual Results:  
1. System reboots to upgrade in offline mode
2. System reboots after upgrade and waits for login

Expected Results:  
1. System reboots to upgrade in offline mode
2. System powers off after upgrade and stays shutdown

$ dnf --version
4.15.1
  Installed: dnf-0:4.15.1-1.fc38.noarch at Sat May 20 18:25:43 2023
  Built    : Fedora Project at Thu May 18 09:11:03 2023

  Installed: rpm-0:4.18.1-3.fc38.x86_64 at Sun May  7 21:48:47 2023
  Built    : Fedora Project at Wed Apr 26 05:35:27 2023

$ dnf info dnf-plugins-core
Installed Packages
Name         : dnf-plugins-core
Version      : 4.4.1
Release      : 1.fc38
Architecture : noarch
Size         : 22 k
Source       : dnf-plugins-core-4.4.1-1.fc38.src.rpm
Repository   : @System
From repo    : updates
Summary      : Core Plugins for DNF
URL          : https://github.com/rpm-software-management/dnf-plugins-core
License      : GPL-2.0-or-later
Description  : Core Plugins for DNF. This package enhances DNF with builddep,
             : config-manager, copr, debug, debuginfo-install, download,
             : needs-restarting, groups-manager, repoclosure, repograph,
             : repomanage, reposync, changelog and repodiff commands.
             : Additionally provides generate_completion_cache passive plugin.

Comment 1 Jan Kolarik 2023-06-06 12:36:34 UTC
I've connected the related bug where the fix was verified in the RHEL 9: https://bugzilla.redhat.com/show_bug.cgi?id=2157844.

But anyway, I've tested it in Fedora 38 VM and it really seems not working properly in some cases.

First I tried (several times) using only the CLI mode (systemd target = multi-user.target). After the upgrades were installed, it rebooted the system, although according to logs, the shut down was triggered.
Then I tried installing the GUI environment and setting up the graphical.target. After that, I did the same procedure and the system really shut down in the end.

From the logs it seems, that in the CLI case both poweroff and reboot services were triggered for some reason. I will need to investigate it further...

I am attaching the logs from CLI and GUI attempts also here.

Comment 2 Jan Kolarik 2023-06-06 12:38:32 UTC
Created attachment 1969293 [details]
Journal from CLI attempt

Comment 3 Jan Kolarik 2023-06-06 12:39:02 UTC
Created attachment 1969294 [details]
Journal from GUI attempt

Comment 4 Jan Kolarik 2023-06-09 11:43:17 UTC
In case of the CLI usage, dnf-system-upgrade.service gets killed before being deactivated successfully which will trigger the dnf-system-upgrade-cleanup.service doing the reboot instead of requested poweroff. The question is still why it is getting killed and why not in the GUI case...

Comment 5 Jan Kolarik 2023-06-09 12:04:06 UTC
There was a problem in missing systemd unit dependency.

The following PR was created to fix this issue: https://github.com/rpm-software-management/dnf-plugins-core/pull/496.

Comment 6 Jan Kolarik 2023-06-13 07:55:12 UTC
Cloned into RHEL 9 bug: https://bugzilla.redhat.com/show_bug.cgi?id=2214510.

Comment 7 Fedora Update System 2023-07-27 11:52:59 UTC
FEDORA-2023-dc793cd506 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-dc793cd506

Comment 8 Fedora Update System 2023-07-27 11:53:00 UTC
FEDORA-2023-bb4b4355a7 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-bb4b4355a7

Comment 9 Fedora Update System 2023-07-28 01:43:21 UTC
FEDORA-2023-bb4b4355a7 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-bb4b4355a7`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-bb4b4355a7

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2023-07-28 01:43:31 UTC
FEDORA-2023-dc793cd506 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-dc793cd506`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-dc793cd506

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2023-07-29 01:19:34 UTC
FEDORA-2023-bb4b4355a7 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2023-07-29 01:47:18 UTC
FEDORA-2023-dc793cd506 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 konradmb@o2.pl 2023-08-02 19:03:43 UTC
I hate to say that, but after upgrading I still see the same behaviour. I've confirmed that /usr/lib/systemd/system/dnf-system-upgrade.service contains the fix.
I've also checked in a fresh and upgraded 38 VM. Same thing.