Merge pull request #11900 from soapy1/catch-guest-not-ready-sync-folder

Catch error for when guest is not available
This commit is contained in:
Sophia Castellarin 2020-09-15 09:54:38 -05:00 committed by GitHub
commit 0ee630feb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -129,8 +129,14 @@ module Vagrant
save_synced_folders(env[:machine], original_folders, **save_opts)
end
# Persist the mounts by adding them to fstab
if env[:machine].guest.capability?(:persist_mount_shared_folder)
# Persist the mounts by adding them to fstab (only if the guest is available)
begin
persist_mount = env[:machine].guest.capability?(:persist_mount_shared_folder)
rescue Errors::MachineGuestNotReady
persist_mount = false
end
if persist_mount
# Persist the mounts by adding them to fstab
if env[:machine].config.vm.allow_fstab_modification
fstab_folders = original_folders
else

View File

@ -255,5 +255,13 @@ describe Vagrant::Action::Builtin::SyncedFolders do
subject.call(env)
end
end
context "when guest is not available" do
it "does not persist folders if guest is not available" do
allow(machine).to receive_message_chain(:guest, :capability?).and_raise(Vagrant::Errors::MachineGuestNotReady)
expect(vm_config).to_not receive(:allow_fstab_modification)
subject.call(env)
end
end
end
end