Conversation
|
Can you please provide some deeper context here, and what platform this change has been tested on |
|
Further to the above question, I have now gone considerably deeper into the implications of replacing: ExecStartPre=/bin/sh -c 'sleep 15'with: After=dbus.socketacross both supplied systemd unit files. There are a few concerns that I think need to be addressed before this can be merged. The first point is that this does not appear to be a systemd version compatibility problem. The concern is instead around systemd dependency semantics, service-manager scope, and whether 1.
|
|
i tested this on fedora and debian the current solution was delaying plasma start up by 15s:
both units have an after statement for network-online so that already guarantees that the network is in a functional state. but i agree that the template ondrive@ change is not relevant as system units can't contact the user dbus session anyways. |
ef88696 to
f8d52bd
Compare
|
Thanks for taking the earlier feedback into account and for dropping the change to However, after reviewing the revised commit, I still cannot accept the current implementation. The PR has now moved beyond replacing the startup delay with D-Bus ordering and changes the lifecycle of After=network-online.target dbus.socket graphical-session.target
Wants=network-online.target dbus.socket
PartOf=graphical-session.target
...
WantedBy=graphical-session.targetThis creates a significant behavioural change.
The OneDrive service is not a graphical-session-only service. Desktop notifications are optional functionality, but the synchronisation service itself is explicitly supported in environments where there is no graphical session at all. For example, the OneDrive documentation currently supports configuring a user service to start without user login using: That is specifically intended to allow the user's OneDrive service to start and continue operating independently of an interactive graphical login. Changing: WantedBy=default.targetto: WantedBy=graphical-session.targetbreaks that operating model for headless / non-graphical users. Adding: PartOf=graphical-session.targetalso means the OneDrive service can be stopped when the graphical session terminates. Your commit message explicitly describes this as:
That is not behaviour we want for the OneDrive synchronisation service. Logging out of KDE/GNOME must not imply that a user's background OneDrive synchronisation service should stop, particularly when systemd lingering has intentionally been configured. There is also an important distinction regarding: After=graphical-session.target
It is primarily a lifecycle/synchronisation target indicating that a graphical session exists. Similarly, I agree that: Wants=dbus.socket
After=dbus.socketis a stronger relationship than The existing delay was deliberately useful for more than D-Bus alone. It provides a short period for the wider boot/login environment to settle before OneDrive begins monitor and synchronisation processing. I think we should solve the actual problem more narrowlyThe ExecStartPre=/bin/sh -c 'sleep 15'means the OneDrive service remains in its startup phase for those 15 seconds and can therefore delay completion of the user However, I do not think solving that requires changing the service from a normal user background service into a graphical-session-scoped service. The current service does not specify With I therefore think we should investigate a much more focused change: ExecStart=/bin/sh -c 'sleep 15; exec @prefix@/bin/onedrive --monitor'rather than: ExecStartPre=/bin/sh -c 'sleep 15'
ExecStart=@prefix@/bin/onedrive --monitorThe shell becomes the initial main process, so systemd can consider the After 15 seconds the shell uses That potentially preserves all of the existing behaviour we actually require:
This is the direction I would prefer to test before making further changes to the service dependency/lifecycle model. In particular I would test the revised service with: and confirm that:
I think this would address the issue demonstrated by your systemd plot without changing the supported operating model of the OneDrive service. |
|
@abraunegg what do you think of adding a systemd timer instead of using the shell trick? |
|
Thanks for suggesting the timer approach. I have considered it, and while I agree that a timer could technically avoid the current 15-second delay contributing to completion of A timer would introduce a second activation mechanism purely to control when an existing long-running service starts. That creates several additional support and lifecycle considerations which do not exist today. For example:
That is a considerable amount of additional operational complexity to solve what is fundamentally a service-start ordering problem. I would prefer that we keep the existing service model and solve the underlying problem directly. The requirement that should be worked towardsThe goal should be:
There are two important parts to that. Firstly, OneDrive should start as late as we can reasonably and portably arrange within normal The current service is pulled into: WantedBy=default.targetand the existing 15-second That explains the behaviour shown in your Rather than adding another activation mechanism, I think we should investigate whether the service can be ordered at a later appropriate synchronization point in the normal user-manager startup graph. The objective is effectively: rather than: This must remain independent of graphical loginI specifically do not want to use OneDrive is not a graphical-session application. The user service is also used on:
So whatever point we select must remain valid for a normal user manager regardless of whether KDE, GNOME or any other graphical desktop session exists. The graphical session may be one of the things that has finished starting by the time OneDrive begins on a normal desktop machine, but it must not become a prerequisite for the synchronization service itself. The delay can then become much smallerI also do not believe that the existing 15-second delay necessarily needs to remain 15 seconds if we move OneDrive later in the startup sequence. The original delay provides a broad grace period for a number of things to settle:
If systemd ordering can already move OneDrive much closer to the end of normal user-manager startup, then most of that work should already have happened before OneDrive becomes eligible to run. At that point the remaining delay is no longer responsible for allowing the whole user environment to initialise. It becomes only a small final settling period for things which cannot be represented reliably through systemd dependencies. For example, we may find through testing that: or: is sufficient once OneDrive is being started at the correct point. I would rather establish that empirically across several distributions than preserve an arbitrary 15 seconds forever. Proposed directionI therefore suggest you pause the timer approach and first investigate the systemd user dependency graph properly. The questions I think that need to be answered are:
I think that produces a substantially cleaner end result: rather than adding a timer solely to work around where the service currently sits in the startup transaction. So my preference is:
I think that solves the actual problem while keeping the service architecture simple for users and maintainers. |
|
nevermind, i didn't notice the exec on your previous suggestion, that will work |
|
Thanks for continuing to work through this. I have re-reviewed the latest revision of this PR. The current approach is now materially different from the original D-Bus-based proposal and from the later The PR now effectively changes: ExecStartPre=/bin/sh -c 'sleep 15'
ExecStart=@prefix@/bin/onedrive --monitorto: ExecStart=/bin/sh -c 'sleep 15; exec @prefix@/bin/onedrive --monitor'and applies the same general approach to This is a substantially cleaner and safer direction than introducing additional D-Bus dependencies, tying OneDrive to There are, however, several points that need to be addressed before this can be considered for merge. 1. There is currently a functional regression in
|
Adjust service startup ordering so OneDrive does not delay session initialization while waiting for the default or multi-user target.
|
to answer your question, all the distros that i tested(fedora,arch,debian,ubuntu) activate dbus on basic.target that is always reached before default.target after thinking over this some more, i think I've reached a cleaner solution that keeps your delay, doesn't delay session init and doesn't change any semantics about the service. |
Update PR with solution, tested with systemd 257
|
Please can you test the proposed change I have just made. |
fix some ordering/ dependency issues with the systemd service, which could cause delayed start of the desktop session.