-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
tuned: Rework logic to gracefully handle the service starting #20748
base: main
Are you sure you want to change the base?
tuned: Rework logic to gracefully handle the service starting #20748
Conversation
Previously starting the service would lead to a server disconnected message, these changes allow us to instead fully wait until the service has started before showing the profile selection, meaning we no longer encounter that error
de9ab3e
to
466b3dc
Compare
Hello @SludgeGirl !
This sounds like a bug in tuned? The card already explicitly starts This PR introduces a lot of extra UI (a whole dialog, etc) but doesn't really address the race other than by "slowing down" the user. I'd like to first understand what's going on. Thanks! |
Hey @martinpitt!! Alright so, I've had another dig through just to refresh myself (sorry for the wait). There's a couple things this aimed to handle First is that the current behavior feels undefined and unexpected. From everything I've seen of cockpit so far, it's very explicit and asks permission for every action it wants to do that's extra from the intended user action, this is a stance I have alot of respect for. Clicking "performance: None" isn't clear that it would start tuned. The extra dialog I've added aimed to make this clearer along with helping to handle the issue (Sorry I forgot to make this clear in my initial explanation) In terms of the technical issue, let me prefix this by saying please let me know if anything I say doesn't make sense or is wrong. I've done my best here but with all the react state changes, systemd service status changes and dbus then everything changing alot through it's execution, it's been a nightmare to try and get my head around. But I believe as this executes and we start tuned inside the dialog, the some of the references like poll, and tunedDbus don't get updated inside the dialog because it's not re-rendered: cockpit/pkg/systemd/overview-cards/tuned-dialog.jsx Lines 127 to 132 in 626b74c
So when we then go to call those once the cockpit/pkg/systemd/overview-cards/tuned-dialog.jsx Lines 269 to 273 in 626b74c
|
The problem seems to be that tuned just takes too long these days to start, times out and reports an error. So I guess we have two options:
@martinpitt alternative ideas welcome :) |
I don't believe that. |
So, yeah, what a mess. :-) I think what @SludgeGirl says is right: the DBusClient in the TunedDialog component is stale when the service is started as part of opening the dialog. Also, the state handling in tuned-dialog.jsx as a whole is needlessly obfuscated. I would recommend making one object with all the state ("TunedState") that exposes the necessary stuff to fill the UI, and emit a "changed" signal when the UI needs updating. It is almost always a mistake to try to get sensible state management out of a couple of spaghetti useEffect calls. It's almost like programming in Prolog! :-) This PR here is also too complex when it comes to showing two dialogs in sequence, IMO. |
What to do about starting tuned.service is another thing... I think I agree that we should be more explicit about it. The proper state of affairs seems to be that if you have tuned installed, it should be running. If you don't want any tuning, switch it off with its own configuration. |
Alright, I dug into this and my first try was to get the opening/closing of the DBus connection sorted out: #21114. Then I remembered that we don't need to reopen DBusClients when their service restarts. So I tried to keep the DBusClient open at all times so that it never gets stale: #21115. Both tries seem to be successful. What do you guys think? |
Previously starting the service would lead to a server disconnected message, these changes allow us to instead fully wait until the service has started before showing the profile selection, meaning we no longer encounter that error