Repository navigation
Closed
Description
Output of rclone version
rclone v1.47.0
- os/arch: linux/amd64
- go version: go1.12.3
Describe the issue
I have been trying to add a few rclone-mounts to my autofs configuration without success
Mounting the drive using the exact commandline that autofs uses works though, so something is weird...
handle_packet_missing_indirect: token 20, name TeamDrive-Archive, request pid 3291
attempting to mount entry /media/GoogleTest/TeamDrive-Archive
lookup_mount: lookup(file): looking up TeamDrive-Archive
lookup_mount: lookup(file): TeamDrive-Archive -> -fstype=fuse,config=/home/scuttle/.config/rclone/rclone.conf :rclonefs\#dom-td01\:
parse_mount: parse(sun): expanded entry: -fstype=fuse,config=/home/scuttle/.config/rclone/rclone.conf :rclonefs\#dom-td01\:
parse_mount: parse(sun): gathered options: fstype=fuse,config=/home/scuttle/.config/rclone/rclone.conf
parse_mount: parse(sun): dequote(":rclonefs\#dom-td01\:") -> :rclonefs#dom-td01:
parse_mount: parse(sun): core of entry: options=fstype=fuse,config=/home/scuttle/.config/rclone/rclone.conf, loc=:rclonefs#dom-td01:
sun_mount: parse(sun): mounting root /media/GoogleTest, mountpoint TeamDrive-Archive, what rclonefs#dom-td01:, fstype fuse, options config=/home/scuttle/.config/rclone/rclone.conf
do_mount: rclonefs#dom-td01: /media/GoogleTest/TeamDrive-Archive type fuse options config=/home/scuttle/.config/rclone/rclone.conf using module generic
mount_mount: mount(generic): calling mkdir_path /media/GoogleTest/TeamDrive-Archive
mount_mount: mount(generic): calling mount -t fuse -o config=/home/scuttle/.config/rclone/rclone.conf rclonefs#dom-td01: /media/GoogleTest/TeamDrive-Archive
Just running "mount -t fuse -o config=/home/scuttle/.config/rclone/rclone.conf rclonefs#dom-td01: /media/GoogleTest/TeamDrive-Archive" mounts the folder just fine, but when automount tries it, it just hangs on that last line
Activity
ScuttleSE commentedon Jun 5, 2019
Oh, and I'm using the mount helper script from here https://github.com/ncw/rclone/wiki/rclone-fstab-mount-helper-script
ncw commentedon Jun 6, 2019
I suggest you add the
--log-fileoption or the--syslogoption to the rclone invocation so you can see any errors and post them here - thanks!ScuttleSE commentedon Jun 7, 2019
This is what the rclone-log showed:
ScuttleSE commentedon Jun 7, 2019
Tried adding --daemon to the commandline as suggested here: https://forum.rclone.org/t/issues-with-rclone-mount-root-node-err-nil/6749
Still not working, but I got another set of messages in the log
ncw commentedon Jun 7, 2019
There are no obvious errors in there... The first one looks like it is working.
So the symptoms are that
lsthe automounted directorylshangs due to some automounter interaction?So do we think what is wrong is some interaction between automount and rclone?
Adding
--daemonwas a good idea.ScuttleSE commentedon Jun 7, 2019
Yes
[email protected] -fstype=fuse,config=/home/scuttle/.config/rclone/rclone.conf,allow-other,daemon,default-permissions,max-read-ahead=16M,[email protected] :rclonefs#dom-01:The folder never gets mounted, but if I run the commandline from the rclone-log it mounts it just fine.
ncw commentedon Jun 7, 2019
Can you check from another terminal that isn't hung to see if the folder did get mounted or not?
ScuttleSE commentedon Jun 7, 2019
Same as the first terminal. the ls-command just hangs
No additional lines in the rclone logfile
ncw commentedon Jun 7, 2019
If you look at
mountorcat /proc/mountsis it mounted in there?ScuttleSE commentedon Jun 7, 2019
Nope, doesn't show up in either.
Other autofs mounts do show up.
ScuttleSE commentedon Jun 7, 2019
Here's the rclone.conf btw
ncw commentedon Jun 7, 2019
What you could try is when it has locked up, find the rclone PID then
kill -QUIT pid.This will cause rclone to emit a stack trace of exactly what it is up to to the log file. Hopefully that will give us a clue!
ScuttleSE commentedon Jun 7, 2019
Hm,
kill -QUITdidn't kill the process so I had some issues getting it... but this ended up in the logfile after a few triesOne thing that was interesting was that if I did
kill -9on the rclone process, it would start another one with the same command line arguments, but the "mount" still won't workncw commentedon Jun 7, 2019
Ah, that makes sense. rclone is blocked on
github.com/ncw/rclone/cmd/mountlib.checkMountEmpty- it is listing the mountpoint to see if it is empty. This is likely to cause some recursion or other funkiness with autofs.If you add the
--allow-non-emptyflag it will skip that check - perhaps that will make it work!ncw commentedon Jun 7, 2019
Assuming that does work, I wonder if there is some way rclone could detect it is being run from autofs (maybe an environment variable) and turn that check off automatically?
38 remaining items
ScuttleSE commentedon Jul 28, 2021
So, I must admit I've been a bit out of the loop here for a while. Right now I have rclone working with autofs, no extra patches, what should I test? :)
ivandeex commentedon Jul 28, 2021
@ScuttleSE
I would like to understand your situation.
Did you do something special to make it work?
What is your OS, rclone version, autofs config?
If this is not an issue for you, let's close out this ticket. I'd then open another ticket where I'd describe my case.
At any rate the patch fixes my case.
I'm interested to know that it does not break your case. If you take your working rclone+autofs environment and replace rclone with patched one, will it still work?
ScuttleSE commentedon Jul 28, 2021
Well, back when the bug was originally opened, there were some minor adjustments, but right now it looks like this:
Autofs:
Music -fstype=fuse.rclonefs,config=/home/scuttle/.config/rclone/rclone.conf,allow-other,default-permissions,allow-non-empty,max-read-ahead=16M,uid=1000,gid=1000Rclonefs:
The mount:
Tried the new binary, and works fine that one too
ivandeex commentedon Jul 28, 2021
@ScuttleSE
Thanks a lot for checking amd confirming that my patch works in your environment.
I see now: you avoid
--daemonusing the&in wrapper (note that this won't applysetsid, cc @ncw)This solution almost replicates case
1from above #3246 (comment):Two minor differences:
/proc/mountsfor the mount (it's linux-only) you poll mountpoint directory for files (works on BSD too but can get stuck if the mounted fs is empty).@ncw
The original case reported here can work fine without my patch. I am solving slightly different case. In fact, I do three things:
rclone --daemonso wrapper can avoid&and justexec rclone--daemon-wait-timeoutor whatever name you aporove), so it can use more robust ProcFS method on Linux with a fallback for BSDMy patch leaves the wrapper with only one function: translation of
-o opt=valmount options into--opt=valrclone flags.If I find a way to use cobra for that (e.g. triggered by executable name
/sbin/mount.rcloneexpected by/bin/mount), we can get rid of the wrapper completely!@ncw @ScuttleSE
I propose to close out this ticket. I can open another one as in fact I'm solving a different problem.
karagian commentedon Jul 28, 2021
Hi and thanks for looking into this @ivandeex , but I must admin that rclone with autofs was working fine, that was not the problem.
The reason this issue was reopened was these last lines in the wrapper script that will loop forever if the remote is empty! I saw your changes and it should work almost fine. My only objection is when ${mountpoint} contains spaces, in which case that grep will fail. I just propose using ${mountpoint// /\\040} istead of just ${mountpoint} there
ivandeex commentedon Jul 28, 2021
@karagian
Hit
Editon the wiki page and add your change. You don't need an issue for that.https://github.com/rclone/rclone/wiki/rclone-mount-helper-script
karagian commentedon Jul 28, 2021
Oh ok.. can anyone edit that? Isn't it dangerous?
ivandeex commentedon Jul 28, 2021
Yes, any github user.
No, we'll fix after you if anything.
karagian commentedon Jul 28, 2021
ok done :)
ivandeex commentedon Jul 28, 2021
@ncw
Let's close this ticket.
I will open another PR with ultimate goal to get rid of shell wrappers so rclone like
sshfscan work natively withmountandautofs!My last open task is to teach cobra translate
-o xxxinto rclone flags...ivandeex commentedon Jul 28, 2021
@ncw
setsid
I found discussion about setsid in the good old
sshfsproject. It works fine as a mount helper (if you symlink it as/sbin/mount.sshfs) and fully supports autofs so we could use it as a primer. They wanted to addsetsid()right afterfork()in the child - libfuse/sshfs#141. In the end they don't call it by default, only if they need to read a string from stdin - https://github.com/libfuse/sshfs/blob/master/sshfs.c#L1200.Again, we don't
fork()likesshfs. We run an independent rclone process which does not inherit anything from the "parent" rclone. We just run it with the same cli flags and environment, just let it know its role via a special environment var.autofs hooks
Here is how
/proc/mountslooks when an autofs mountpoint is idle - our path has aautofspseudo-mount attached:autofs attaches a pseudo-mount to the path, the kernel catches accesses there and sends event records to a pipe which autofs daemon acquired from it. autofs calls
poll()on the pipe and handles the records.Here is how it looks after autofs detects access and invokes rclone to do the mount - two mounts now attached on the path:
If we don't access active mount for a long time, autofs triggers idle event and unmounts the rclone mount, but the autofs pseudo-mount stays (the picture returns to the former state above).
The unmount triggers FUSE which returns a error code on a go channel in rclone. rclone exits and calls atexit with
umount(mountPoint). This would be correct if rclone finished due to^CorSIGINTwhen autofs pseudo-mount wasn't there. However, if it exits after external unmount, it should not unmount the remaining autofs pseudo-mount (in fact, it's an access hook).Here is what happens if rclone by mistake unmounts autofs hooks:
When we unmounted the path hooks, kernel sent an event for it to the autofs daemon (systemd in my case) who got angry, marked the automount unit as failed and suspended checking for path access on
/mnt/remoteuntil I runsystemctl restart mnt-remote.automount.ScuttleSE commentedon Jul 29, 2021
Hm, just wanted to add... none of my idle autofs-mounts shows up in /proc/mounts, they only show up there when they are actually mounted. No matter if it's a rclone-mount or a regular filesystem mount
ncw commentedon Jul 29, 2021
@ivandeex - thank you for the explanation :-)
Yes if we don't fork, we don't need to call setsid - that seems obvious now.
Gotcha.
ivandeex commentedon Jul 29, 2021
Thank you. It explains why you don't hit the unmount bug.
Looks like the pseudo-mount abstraction is used only by systemd automounter while the Autofs daemon uses an alternative kernel mechanism for that. I will mention it when I submit final patch for rclone.