-
Notifications
You must be signed in to change notification settings - Fork 99
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: Support to run transactions offline #1543
Conversation
download_packages(session, *transaction); | ||
if (offline) { | ||
session.store_transaction_offline(); | ||
// TODO(mblaha): signalize reboot? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add API to check whether there's a pending offline update, please? It can be used by gnome-shell, to check whether the offline update is ready, then it asks the user [x] Install pending update
in the power off/restart dialog and, when the user unchecks the option, the prepared update is "cancelled" (another new API) and the machine powers off/reboots without applying the offline update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestions! I'll add them. We actually have similar funcionality on CLI already - dnf offline status
and dnf offline clean
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the do_transaction
part and it works as expected. Thank you.
Clean the offline transaction configured for the next reboot by removing the /system-update symlink (see systemd.offline-updates(7)). | ||
|
||
Following @options are supported: | ||
- clean_datadir: boolean, default true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would using a false
as the default be a bit safer variant? You do not want to download 3GB of packages again just because you need to turn off the laptop and the app calling this does not pass the option, relying on the default value (or not knowing it exists, or when you split the option into clear packages, clear the other thing,...).
|
||
Unknown options are ignored. | ||
--> | ||
<method name="do_transaction"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct the name
<arg name="options" type="a{sv}" direction="in" /> | ||
<arg name="transaction_cleaned" type="b" direction="out" /> | ||
</method> | ||
|
||
</interface> | ||
|
||
</node> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether adding this to the Goal
is the best place. For me, the Goal manages actual transactions, something ready to be started. These two look like a method not related to actual transactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's not the best possible place. It's kind of loosely connected - the offline transactions are scheduled using Goal::do_transaction(offline=true)
. But maybe introducing completely new Offline
interface would be cleaner way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not think of a completely new interface, I thought some could be extended, but it seems none matches cleanly. The Base
does only the read_all_repos
and some signals, the SessionManager
is not ideal either. I mean, you are right, adding the Offline
interface looks like the best option.
|
||
Check whether there is an offline transaction configured for the next reboot (i.e. checks the /system-update symlink existence). | ||
--> | ||
<method name="offline_transaction_pending"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call it get_offline_transaction_pending
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we are moving to a new Offline interface, I'd call it simply check_pending()
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sounds good to me. The get_status
would imply it can be more than just "is/is-not ready".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. Actually we can later provide a call returning all the details about the scheduled transaction.
Also, looking in how gnome-shell uses the PackageKit side of thing, there is a "trigger" method in the PackageKit's D-Bus "offline-update" interface and depending on what the user chose in the gnome-shell they run:
In other words, the "trigger" function can set what to do after the offline update is finished. I see you have there a |
The |
Nice, in that case it behaves as I expected and it can be (re)used.
I'm not sure whether the What dnf5 may do is to add something like |
677b8b5
to
78d7390
Compare
I pushed a new version that
|
Looks good to me overall! A few comments:
|
You are right, having a single method sounds better than having two.
The suggestion makes sense to me too. I'm not the change owner, my comment is from the "client/API consumer" point of view. |
Currently It differs from
I like this idea! |
The patch adds a new supported option "offline" to the do_transaction method of the Goal interface. If set to "true", the transaction is not executed, but only prepared to run during the next reboot.
I think it's not great, neither the When I ask dnf5 whether there's an offline update/upgrade ready, I mean with it that the dnf5 has scheduled update/upgrade for the next boot, not that dnf5 or any other software happened to have scheduled an offline update. Aka the symlink presence is not a good indicator that the offline update is ready. I understand it still means that something will do the update/upgrade", but as long as it's not the dnf5, I'd just return "no" when asking dnf5 about the state. For me, the symlink is just an implementation detail. Maybe it'll work differently in the future, or without systemd, or whatever, thus I use the library API to check the status instead of using the symlink directly. I'd not even mention it in the API documentation. Imagine a case where something else will schedule the offline update - the symlink is there. The user will pick in the Power Off dialog of the GNOME Shell to not update, then the gnome-shell will ask dnf5 to discard/postpone the update. Will dnf5 unconditionally remove the symlink, even when it's not its, or it'll give up? What if the cancellation means for the other app something else than just removing the symlink, maybe some cleanup, state change written somewhere, then the dnf5 would make the other app in an inconsistent state. I'm only thinking aloud. Feel free to ignore me. |
Actually your comment makes a lot of sense. You are right that dnf5 should not touch upgrades not scheduled by it. |
Adds new `Offline` interface for interacting with offline transactions. The interface provides three methods: - check_pending() - check whether there is an offline update scheduled for the next reboot - cancel() - cancel the scheduled offline update - clean() - cancel the scheduled offline update and remove all stored offline transaction data. - set_finish_action() - to set whether after applying the offline transaction the system should be rebooted (default) or powered off.
880ae2b
to
e7db9ec
Compare
I did another change suggested by reviewers:
|
// set the poweroff_after item accordingly | ||
std::string finish_action; | ||
call >> finish_action; | ||
state.get_data().set_poweroff_after(finish_action == "poweroff"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine to have it like this, even case sensitive, but it might be good to at least test whether the other action is "reboot"
and claim a warning on the console about "unknown finish action" if it's neither "poweroff"
nor "reboot"
. That way one can check for typos and the older library will not crash when a new value is proposed in the future.
This may touch also the documentation in the D-Bus interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fill the error_msg
output parameter with such warning. Returning an error reply seems too me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning an error, aka failing the call, would make the parameter strict. It's fine by me, it only has certain consequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then, let's make the value check strict and return an error in case of unsupported value.
Check that only one of "poweroff", or "reboot" value was passed to set_finish_action() call.
Yeah,
I could go either way, but I still prefer one |
OK, so let's replace check_pending() with get_status() which will have two out parameters:
@evan-goode are you OK with this? |
Replace check_pending() method of the Offline interface with richer get_status() method. The new method returns two values: - boolean whether there is a dnf5 offline transaction scheduled for the next reboot - a string->variant dictionary with the status of the dnf5 offline transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
I will be on PTO until 2024-07-16, so if you make more changes, or want another pair of eyes, you may want to find an additional reviewer.
Thanks! I don't plan any other changes right now, feel free to merge it. |
I can confirm these changes do what I'd expect to be done from the gnome-software side. |
Adds support for "offline" option to Goal::do_transaction() dbus API method.