Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnfdaemon: system-upgrade API and command #1588

Merged
merged 3 commits into from
Aug 7, 2024
Merged

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Jul 17, 2024

Changes:

c583173 (Marek Blaha, 72 minutes ago)
doc: Add system-upgrade example using D-Bus API

960882b (Marek Blaha, 6 days ago)
dnf5daemon-client: system-upgrade command

fe4b380 (Marek Blaha, 7 weeks ago)
dnfdaemon: Add system_upgrade() method to Rpm interface

The method fills the goal to perform upgrade of the distribution to the new
release.

Following @options are supported:

- mode: string (one of "distrosync", "upgrade", default is "distrosync")
By default the system_upgrade behaves like `dnf distro-sync`, always installing packages from the new release, even if they are older then the currently installed version. If set to "upgrade", packages from the new release are not installed if they are older then what is currently installed (behave like `dnf upgrade`).
Copy link
Contributor

Choose a reason for hiding this comment

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

older than , twice in the text

- mode: string (one of "distrosync", "upgrade", default is "distrosync")
By default the system_upgrade behaves like `dnf distro-sync`, always installing packages from the new release, even if they are older then the currently installed version. If set to "upgrade", packages from the new release are not installed if they are older then what is currently installed (behave like `dnf upgrade`).

Unknown options are ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

how to I set the release version to be upgraded to? It seems to be "detected" somehow, but one can upgrade both to N+1 and N+2. An explicit "upgrade to releasever X" would be better.

The python example suggests the releasever is set within the open_session. Could there be added an argument, which will override that value if set, here as well, please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Releasever should be set using the open_session() option. It needs to be set before the repositories metadata are loaded and setting it here can be too late. I'll add this information to the method description.

throw sdbus::Error(
dnfdaemon::ERROR,
fmt::format(
"Unsupported system-ugrade mode \"{}\". Only \"distrosync\" and \"upgrade\" modes are supported.",
Copy link
Contributor

Choose a reason for hiding this comment

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

s/system-ugrade/system-upgrade/ (missing p in the second word)

# along with libdnf. If not, see <https://www.gnu.org/licenses/>.

"""
This is an example how to perform a system-upgrade with dnf5daemon-server.
Copy link
Contributor

Choose a reason for hiding this comment

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

are the two spaces near the end of the line intentional?

Following @options are supported:

- mode: string (one of "distrosync", "upgrade", default is "distrosync")
By default the system_upgrade behaves like `dnf distro-sync`, always installing packages from the new release, even if they are older then the currently installed version. If set to "upgrade", packages from the new release are not installed if they are older then what is currently installed (behave like `dnf upgrade`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the similarities with those modes the dnf5 distro-sync and dnf5 system-upgrade? I see some differences between the two, like the first can run "online" or "offline" while the other is always "offline". The first has --download only, the second is always split into two phases, download and reboot.

For the gnome-software it'll be always download and then reboot-to-install. It should be possible to change my mind and not install previously prepared system upgrade.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's more about what method system-upgrade uses in background. By default the dnf5 system-upgrade download is roughly equivalent to dnf5 distro-sync --offline. But with dnf5 system-upgrade download --no-downgrade option the system upgrade makes sure, that packages from the new release that are of older version then currently installed are not used. In this case its roughly equivalent to dnf5 upgrade --offline.

I will add code to enforce "offline" behavior to "Rpm.system_upgrade()" call, because currently it relies on offline option being passed to Goal.do_transaction() method.

@m-blaha m-blaha force-pushed the mblaha/daemon-system-upgrade branch from c583173 to 1bd0414 Compare August 1, 2024 12:08
@kontura kontura self-assigned this Aug 5, 2024
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

This looks good I am only thinking how we could CI test it.
Perhaps some special step?

doc/dnf_daemon/examples/system_upgrade.py Outdated Show resolved Hide resolved
@m-blaha m-blaha force-pushed the mblaha/daemon-system-upgrade branch from 1bd0414 to e90f79e Compare August 7, 2024 09:05
@kontura kontura added this pull request to the merge queue Aug 7, 2024
Merged via the queue into main with commit ea8a9a2 Aug 7, 2024
16 checks passed
@kontura kontura deleted the mblaha/daemon-system-upgrade branch August 7, 2024 11:06
@mcrha
Copy link
Contributor

mcrha commented Aug 20, 2024

I'm trying it here, and I noticed one thing:

$ cat /system-update/offline-transaction-state.toml 

[offline-transaction-state]
module_platform_id = ""
poweroff_after = false
verb = ""
system_releasever = "39"
target_releasever = "40"
cachedir = "/var/cache/libdnf5"
status = "download-incomplete"
cmd_line = "dnf5daemon-server"
state_version = 1

The status = "download-incomplete" is scary, because this is the "magic directory", thus restarting the machine will cause an upgrade attempt, with incomplete download. I'd say, if anything like this fails (or just really anything), then this should fail, report the error to the caller and do not prepare the upgrade for the next reboot.

This is with the default options, thus the distrosync mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants