core: network issues don't halt Vagrant during box update check [GH-3391]

This commit is contained in:
Mitchell Hashimoto 2014-04-05 09:25:03 -07:00
parent 0e46c5d9de
commit 5f12126d32
4 changed files with 27 additions and 0 deletions

View File

@ -2,6 +2,8 @@
BUG FIXES:
- core: Don't error if network problems cause box update check to
fail [GH-3391]
- guests/fedora: Fix hostname setting. [GH-3382]
- guests/fedora: Support predictable network interface names for
public/private networks. [GH-3207]

View File

@ -41,6 +41,10 @@ module Vagrant
update = nil
begin
update = box.has_update?(constraints)
rescue Errors::BoxMetadataDownloadError => e
env[:ui].warn(I18n.t(
"vagrant.box_outdated_metadata_download_error",
message: e.extra_data[:message]))
rescue Errors::VagrantError => e
raise if !env[:box_outdated_ignore_errors]
env[:ui].detail(I18n.t(

View File

@ -37,6 +37,16 @@ en:
installed, but your Vagrant machine is running against
version '%{old}'. To update to version '%{new}',
destroy and recreate your machine.
box_outdated_metadata_download_error: |-
There was a problem while downloading the metadata for your box
to check for updates. This is not an error, since it is usually due
to temporary network problems. This is just a warning. The problem
encountered was:
%{message}
If you want to check for box updates, verify your network connection
is valid and try again.
box_outdated_metadata_error_single: |-
Error loading box metadata while attempting to check for
updates: %{message}

View File

@ -153,6 +153,17 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
expect(env[:box_outdated]).to be_false
end
it "does nothing if metadata download fails" do
expect(box).to receive(:has_update?).and_raise(
Vagrant::Errors::BoxMetadataDownloadError.new(message: "foo"))
expect(app).to receive(:call).once
subject.call(env)
expect(env[:box_outdated]).to be_false
end
it "raises error if has_update? errors" do
expect(box).to receive(:has_update?).and_raise(Vagrant::Errors::VagrantError)