synced_folders/rsync: don't crash if comm error during rsync-auto [GH-3419]

This commit is contained in:
Mitchell Hashimoto 2014-04-09 08:58:56 -07:00
parent 7ade8f8ad4
commit 800cf7539b
4 changed files with 39 additions and 1 deletions

View File

@ -6,6 +6,8 @@ BUG FIXES:
of Vagrant. [GH-3386]
- core: Don't error if network problems cause box update check to
fail [GH-3391]
- commands/rsync-auto: Don't crash if the machine can't be communicated
to. [GH-3419]
- guests/fedora: Fix hostname setting. [GH-3382]
- guests/fedora: Support predictable network interface names for
public/private networks. [GH-3207]

View File

@ -112,7 +112,14 @@ module VagrantPlugins
tosync.each do |folders|
folders.each do |opts|
ssh_info = opts[:machine].ssh_info
RsyncHelper.rsync_single(opts[:machine], ssh_info, opts[:opts])
begin
RsyncHelper.rsync_single(opts[:machine], ssh_info, opts[:opts])
rescue Vagrant::Errors::MachineGuestNotReady
# Error communicating to the machine, probably a reload or
# halt is happening. Just notify the user but don't fail out.
opts[:machine].ui.error(I18n.t(
"vagrant.rsync_communicator_not_ready_callback"))
end
end
end
end

View File

@ -159,6 +159,10 @@ en:
rsync_communicator_not_ready: |-
The machine is reporting that it is not ready for rsync to
communiate with it. Verify that this machine is properly running.
rsync_communicator_not_ready_callback: |-
Failed to connect to remote machine. This is usually caused by the
machine rebooting or being halted. Please make sure the machine is
running, and modify a file to try again.
rsync_folder: |-
Rsyncing folder: %{hostpath} => %{guestpath}
rsync_folder_excludes: " - Exclude: %{excludes}"

View File

@ -30,6 +30,9 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
def machine_stub(name)
double(name).tap do |m|
m.stub(ssh_info: ssh_info)
m.stub(ui: double("ui"))
m.ui.stub(error: nil)
end
end
@ -95,5 +98,27 @@ describe VagrantPlugins::SyncedFolderRSync::Command::RsyncAuto do
r = ["/foo/bar"]
subject.callback(paths, m, a, r)
end
it "doesn't fail if guest error occurs" do
paths["/foo"] = [
{ machine: machine_stub("m1"), opts: double("opts_m1") },
{ machine: machine_stub("m2"), opts: double("opts_m2") },
]
paths["/bar"] = [
{ machine: machine_stub("m3"), opts: double("opts_m3") },
]
paths["/foo"].each do |data|
expect(helper_class).to receive(:rsync_single).
with(data[:machine], data[:machine].ssh_info, data[:opts]).
and_raise(Vagrant::Errors::MachineGuestNotReady)
end
m = []
a = []
r = ["/foo/bar"]
expect { subject.callback(paths, m, a, r) }.
to_not raise_error
end
end
end