mitchellh/vagrant — Issue #577: failing "vagrant up" will clear nfs exports through "recover"
Author: phorsuedzie
Created: 2011-11-30 17:10:51+00:00
State: open

It seems when a "vagrant up" fails at the provisioning stage, it still calls "recover" on nfs which will remove the nfs export configuration from /etc/exports.

That's not fair, as the vagrant box is still running and "relying" on the nfs export (you can e.g. have a "good" box later using a successful "vagrant provision").

This will continue to work, until someone restarts the nfsd (e.g. by starting a different vagrant box with a shared nfs). From that time one, you only get stale NFS handles, because your box' exports had been removed.

Summary:
- Don't remove nfs exports on the host (via nfs.recover) as long as the system is running.
- Don't "recover" nfs when the system has been successfully bootet and is just failing at the provisioning stage.

# Merged Logs

[default] Mounting NFS shared folders...
...
20111130174146: /usr/sbin/vagrant-support add # VAGRANT-BEGIN: 6902584e-bcc4-4677-bbd1-f1d855c5ab60
20111130174146: /usr/sbin/vagrant-support add "/my/nfs/to/export"
20111130174146: /usr/sbin/vagrant-support add # VAGRANT-END: 6902584e-bcc4-4677-bbd1-f1d855c5ab60
20111130174146: /usr/sbin/vagrant-support restart
...
[default] [Wed, 30 Nov 2011 08:42:11 -0800] INFO: *** Chef 0.10.2 ***
...
# I had reconfigured the system time zone meanwhile, it's only 95 seconds later ...
...
[default] [Wed, 30 Nov 2011 17:43:49 +0100] INFO: execute[sanity-check and replace sudoers file]
[Wed, 30 Nov 2011 17:43:49 +0100] INFO: execute[sync GCC from minion] sh(rsync ...
[default] [Wed, 30 Nov 2011 17:43:56 +0100] ERROR: execute[sync GCC from minion]
[default] [Wed, 30 Nov 2011 17:43:56 +0100] FATAL: Chef::Exceptions::ShellCommandFailed: execute[sync GCC from minion]
# which always fails the first time only (some ssh-agent issue ...)

# looks like "recover" has been called unfortunately :-(
20111130174356: /usr/sbin/vagrant-support remove 6902584e-bcc4-4677-bbd1-f1d855c5ab60

# Final state of the host: no more nfs exports
$ ls -l /etc/exports
-rw-r--r-- 1 root wheel 0 30 Nov 17:43 /etc/exports

# Final state of the failed guest
$ ssh vagrant mount | grep nfs
:/my/nfs/to/export on /home/vagrant/nfs type nfs (rw,addr=...)