mineshaftgap / d4m-nfs

Docker for Mac with NFS for performance improvements over osxfs
296 stars 26 forks source link

Unable to mount home dir to /mnt #37

Closed wyuenho closed 7 years ago

wyuenho commented 7 years ago

On the latest Docker for Mac CE, MobyVM by default has /mnt created with a db/ subdirectory in it. When d4m-nfs.sh tries to mount $HOME from the host to the VM, a permission error results.

sh /tmp/d4m-mount-nfs.sh
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
v3.5.1-77-g9de0a6fd7f [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
OK: 5655 distinct packages available
(1/9) Installing libtirpc (1.0.1-r0)
(2/9) Installing rpcbind (0.2.3-r3)
Executing rpcbind-0.2.3-r3.pre-install
(3/9) Installing device-mapper-libs (2.02.168-r3)
(4/9) Installing libevent (2.0.22-r2)
(5/9) Installing libmount (2.28.2-r1)
(6/9) Installing libnfsidmap (0.25-r1)
(7/9) Installing sqlite-libs (3.15.2-r0)
(8/9) Installing nfs-utils (1.3.4-r0)
(9/9) Installing sntpc (0.9-r6)
Executing busybox-1.25.1-r0.trigger
OK: 41 MiB in 59 packages
adding d4m nfs config to /etc/fstab:
# d4m-nfs mounts
192.168.65.1:/Users/jwong /mnt nfs nolock,local_lock=all 0 0
192.168.65.1:/Users/jwong/Documents/workspace/cloudflare/repos /repos nfs nolock,local_lock=all 0 0
192.168.65.1:/Users/jwong/dev-stack-data /data nfs nolock,local_lock=all 0 0
mount.nfs: access denied by server while mounting 192.168.65.1:/Users/jwong
mount.nfs: access denied by server while mounting 192.168.65.1:/Users/jwong
mount: mounting 192.168.65.1:/Users/jwong on /mnt failed: Permission denied
/ # touch /repos/.d4m /data/.d4m
/ #
screen shot 2017-03-08 at 23 17 27 screen shot 2017-03-08 at 23 13 26
$ cat etc/d4m-nfs-mounts.txt 
/Users/jwong/Documents/workspace/cloudflare/repos:/repos:0:0
/Users/jwong/dev-stack-data:/data:0:0
$ cat /tmp/d4m-mount-nfs.sh 
ln -nsf /tmp/d4m-apk-cache /etc/apk/cache
apk update
apk add nfs-utils sntpc
rpcbind -s > /dev/null 2>&1

DEFGW=$(ip route|awk '/default/{print $3}')
FSTAB="\n\n# d4m-nfs mounts\n"

if true && ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then
  mkdir -p /mnt

  FSTAB="${FSTAB}${DEFGW}:/Users/jwong /mnt nfs nolock,local_lock=all 0 0"
fi

if [ -e /tmp/d4m-nfs-mounts.txt ]; then
  while read MOUNT; do
    DSTDIR=$(echo "$MOUNT" | cut -d: -f2)
    mkdir -p ${DSTDIR}
    FSTAB="${FSTAB}\n${DEFGW}:$(echo "$MOUNT" | cut -d: -f1) ${DSTDIR} nfs nolock,local_lock=all 0 0"
  done < /tmp/d4m-nfs-mounts.txt
fi

if ! $(grep "d4m-nfs mounts" /etc/fstab > /dev/null 2>&1); then
    echo adding d4m nfs config to /etc/fstab:
    echo -e $FSTAB | tee /etc/fstab
else
    echo d4m nfs mounts already exist in /etc/fstab
fi

sntpc -i 10 ${DEFGW} &

sleep .5
mount -a
touch /tmp/d4m-done
$ cat /tmp/d4m-nfs-mounts.txt 
/Users/jwong/Documents/workspace/cloudflare/repos:/repos:0:0
/Users/jwong/dev-stack-data:/data:0:0
$ cat /etc/exports
# d4m-nfs exports

"/Users/jwong/Documents/workspace/cloudflare/repos" -alldirs -mapall=0:0 localhost
"/Users/jwong/dev-stack-data" -alldirs -mapall=0:0 localhost

I have to turn off AUTO_MOUNT_HOME to get rid of that permission error. I'm not sure if a better solution is to have $HOME mounted on somewhere else other than /mnt.

if-kenn commented 7 years ago

Since d4m-nfs and be setup in an unlimited number of ways, it is important for you to fully review https://github.com/IFSight/d4m-nfs/blob/master/README.md

If you are still having problems after that, since it is so complicated to provide help with limited information please provide all the information requested in the README. Without the requested information we will not consider further responses.

wyuenho commented 7 years ago

I've attached the missing info. Thank you for helping.

if-kenn commented 7 years ago

@wyuenho when d4m-nfs does not find exactly /Users/<USERNAME>, it tries to export it as /mnt so you are effectively trying to export things under /Users/jwong 3 times. I would suggest to simply export the top level /Users/jwong once and then use the subdirectories of it appropriately.

wyuenho commented 7 years ago

Both of the exports begin with my home dir, so the condition *"\"/Users/$USER"* will not be true, thats why you don't see "/Users/jwong" -alldirs -mapall=501:20 localhost in /etc/exports.

/mnt is created when AUTO_MOUNT_HOME is true and /mnt doesn't exist in /tmp/d4m-nfs-mounts.txt according to here.

That mkdir -p /mnt won't give you any errors when it already exists.

As you can see from the screen logs, both of my overlapping dirs are exported successfully, just $HOME isn't. The reason is because a non-empty /mnt already exists in MobyVM, so mounting it to somewhere else will solve this problem.

if-kenn commented 7 years ago

@wyuenho the files that you have give suggest that you have not turned off AUTO_MOUNT_HOME:

if true && ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then

The true in /tmp/d4m-mount-nfs.sh that you provided is reflective of that. It is not enough to simply have a ephemeral AUTO_MOUNT_HOME, you need to have it exported.

export AUTO_MOUNT_HOME=false; ./d4m-nfs.sh

We did not add the AUTO_MOUNT_HOME, it was from a PR, so it was not something we documented.

wyuenho commented 7 years ago

Of course it's not turned off, how else do I recreate that permission error by turning it off? :P

On 10 Mar 2017, at 3:40 am, Kenn Herman notifications@github.com wrote:

@wyuenho the files that you have give suggest that you have not turned off AUTO_MOUNT_HOME:

if true && ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then The true in /tmp/d4m-mount-nfs.sh that you provided is reflective of that. It is not enough to simply have a ephemeral AUTO_MOUNT_HOME, you need to have it exported.

export AUTO_MOUNT_HOME=false; ./d4m-nfs.sh

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

if-kenn commented 7 years ago

Sorry @wyuenho but I am at a loss of what you are asking for then.

wyuenho commented 7 years ago

Mount $HOME to somewhere else other than /mnt On Fri, 10 Mar 2017 at 2:43 pm, Kenn Herman notifications@github.com wrote:

Sorry @wyuenho https://github.com/wyuenho but I am at a loss of what you are asking for then.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/IFSight/d4m-nfs/issues/37#issuecomment-285686126, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJxHFQcixdi5zbUPMuh_tpShmaL3PB6ks5rkWGtgaJpZM4MWMcP .

if-kenn commented 7 years ago

I was trying to do the same thing, but it appears that you don't want to take my suggestion to make AUTO_MOUNT_HOME false and instead give conflicting information.

I don't know if you have realized this yet, but you are arguing with the person who wrote this, and who knows the, at least intended, business logic.

It doesn't seem like you understand how d4m-nfs works, /mnt is not on your Mac, it is in the MobyVM. If you don't want your HOME directory mounted how it already does it by default, then turn it off.

You having /Users/jwong entries in etc/d4m-nfs-mounts.txt and then refusing to turn off AUTO_MOUNT_HOME from what I can tell appears to be causing this. If you don't try what I suggested, then I will not try to help any further.

wyuenho commented 7 years ago

Allow me to quote myself from the issue description:

I have to turn off AUTO_MOUNT_HOME to get rid of that permission error. I'm not sure if a better solution is to have $HOME mounted on somewhere else other than /mnt.

I have gotten it to work by setting AUTO_MOUNT_HOME to false, just because I didn't show you, it doesn't mean I haven't done it.

/mnt is not on your Mac, it is in the MobyVM.

That's what I've been saying from the moment I filed this issue. /mnt is non-empty directory pre-created with root root on the latest MobyVM. You can't mount to it without changing the perm. Since it comes with MobyVM now, to prevent clobbering, you probably should mount $HOME to somewhere else other than /mnt.

screen shot 2017-03-10 at 15 50 37

Does it make sense now?

if-kenn commented 7 years ago

@wyuenho, yes it appears that the Docker changed the MobyVM again and has new directories /mnt and /mnt/db. However, you are conflating multiple issues that others are not experiencing since they are not using this the way you are.

In *NIX when you mount something over an existing directory if anything under that directory existed it is masked. For instance it still works just fine for on my system with the exact same build of Docker for Mac that you have, the location is not the issue, the fact you are trying to reexport something is.

What I think you are not mentioning is the initial NFS export error message that you got:

exports:4: /Users/jwong/Documents/workspace/cloudflare/repos conflicts with existing export /Users/jwong
exports:5: /Users/jwong/dev-stack-data conflicts with existing export /Users/jwong

So I think you attempted to fix that by turning off AUTO_MOUNT_HOME when actually what you are doing is simply not having a parent directory that conflicts with a child directory, that one of the reasons I suggested:

I would suggest to simply export the top level /Users/jwong once and then use the subdirectories of it appropriately.

Both your suggestion and the PR break backwards compatibility for everyone else besides you, who are not experiencing what you are, for that reason I cannot except it.

If you still insist on exporting multiple directories under you home directory, I think a better approach would be to be able to give an alternative auto home mount location variable, say AUTO_HOME_PATH, in your case you would be free to give it /host-home. If you want to do this please make a new PR.

wyuenho commented 7 years ago

Closing this as we aren't using this solution anymore.