jstaf / onedriver

A native Linux filesystem for Microsoft OneDrive
GNU General Public License v3.0
1.99k stars 94 forks source link

Failed to Connect at Startup #151

Closed NicBOMB closed 3 years ago

NicBOMB commented 3 years ago

Similar error to #136 but was encountered at startup using AUR version on Manjaro Plasma and no shared files.

level=fatal
msg="Could not fetch root item of filesystem!"
func="000001:fs.NewCache()"
file="cache.go:84"
err="Get \"https://graph.microsoft.com/v1.0/me/drive/root\": dial tcp: lookup graph.microsoft.com: no such host"

Starting from desktop after I've logged in works but it always fails to connect at startup either when enabled in GUI or using systemd instructions in the readme.

NicBOMB commented 3 years ago

Seems like onedriver is dead before networking starts. I tried using https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ to improve the unit file, but adding

Requires=network-online.target
After=network.target network-online.target

or

Wants=network-online.target
After=network.target network-online.target

still had no noticeable improvement (same error). Could we get a onedriver.desktop file or command to mount a specific enabled (checkmarked/service-enabled) but inactive (unmounted/dead) onedrive account at DE without opening the GUI? We have a command that authenticates, but I've already authenticated. I just want to delay the auto-mount until my desktop environment is up, since I know networking is up regardless of how networking and systemd are configured or which services I need to add to the unit file. I know that the unit files themselves are functional since I can restart the service using the file and it will mount successfully, but the service is dead by trying to network too early as far as I can tell.

NicBOMB commented 3 years ago

After significantly more digging into my networking setup, I found that adding

[Unit]
Description=onedriver
Wants=NetworkManager-wait-online.service
After=NetworkManager-wait-online.service

solved my issue. @jstaf For anyone using systemd-networkd instead of network manager, you'd want systemd-networkd-wait-online.service instead.

Could we get a onedriver.desktop file or command to mount a specific enabled (checkmarked/service-enabled) but inactive (unmounted/dead) onedrive account at DE without opening the GUI? We have a command that authenticates, but I've already authenticated. I just want to delay the auto-mount until my desktop environment is up, since I know networking is up regardless of how networking and systemd are configured or which services I need to add to the unit file. I know that the unit files themselves are functional since I can restart the service using the file and it will mount successfully, but the service is dead by trying to network too early as far as I can tell.

My prior suggestion could work around this autostart issue on systems with differing networking setups, or you could include two service files with onedriver instead, one for network manager and another for systemd-networkd. However, this only solves the issue for default installations of those network managers. It looks to be common to disable the features which detect when networking is up since it can save boot time https://askubuntu.com/a/1018731.

jstaf commented 3 years ago

Hey, sorry to let you have a conversation by yourself on this one (was taking a break while doing some stuff in real life :sweat_smile: ).

When I first started writing this software, I discovered very early on (as you discovered here) that it's very difficult to come up with a solution in systemd that actually waits until the system is online to start the filesystem (assuming it works, the solution isn't portable depending on what network stack the user has). Instead, the strategy is to start offline in read-only mode and go to the normal read-write mode once the system goes online. This actually works quite well... as long as we detect that the network is offline properly.

In this case, detecting if the system was offline was the broken part.... we were just checking for a few specific error strings from the Go networking stack and "no such host" wasn't one of them: https://github.com/jstaf/onedriver/blob/b7ecb477ab171da0f4d2b9aaf9f285aaf98cfbb2/fs/graph/graph.go#L195-L202

Obviously this is not the greatest way of checking if the system is offline, but after re-reading the code there's a better way I think. Let me see what I can do to patch this to have a more reliable way of checking if the system is offline (not dependent on error message strings...).

jstaf commented 3 years ago

Should be fixed in #155. Please reopen if you're still running into issues.

NicBOMB commented 3 years ago

Should be fixed in #155. Please reopen if you're still running into issues.

Sure thing. Once AUR version updates I'll reset my unit file then use the GUI and/or your provided systemd commands to test the new commits.

jstaf commented 3 years ago

FYI there's a onedriver-git version on the AUR which tracks the master branch (which should have the latest changes): https://aur.archlinux.org/packages/onedriver-git/