Retry on TypeError for NFS cleanup, which seems to happen during Kernel#system

This commit is contained in:
Mitchell Hashimoto 2010-09-30 01:39:05 -07:00
parent bad251a20d
commit 11e775b03b
1 changed files with 8 additions and 5 deletions

View File

@ -35,12 +35,15 @@ module Vagrant
def nfs_cleanup def nfs_cleanup
return if !File.exist?("/etc/exports") return if !File.exist?("/etc/exports")
system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1")
if $?.to_i == 0 retryable(:tries => 10, :on => TypeError) do
# Use sed to just strip out the block of code which was inserted system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1")
# by Vagrant
system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports") if $?.to_i == 0
# Use sed to just strip out the block of code which was inserted
# by Vagrant
system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports")
end
end end
end end
end end