Merge pull request #12421 from soapy1/retry-networks-setup-debian
Retry network setup on debain
This commit is contained in:
commit
750c95272d
@ -8,6 +8,7 @@ module VagrantPlugins
|
||||
class ConfigureNetworks
|
||||
include Vagrant::Util
|
||||
extend Vagrant::Util::GuestInspection::Linux
|
||||
extend Vagrant::Util::Retryable
|
||||
|
||||
NETPLAN_DEFAULT_VERSION = 2
|
||||
NETPLAN_DIRECTORY = "/etc/netplan".freeze
|
||||
@ -166,11 +167,16 @@ module VagrantPlugins
|
||||
rm -f /tmp/vagrant-network-interfaces.post
|
||||
EOH
|
||||
|
||||
comm.sudo(commands.join("\n"))
|
||||
network_up_commands = []
|
||||
|
||||
# Bring back up each network interface, reconfigured.
|
||||
networks.each do |network|
|
||||
commands << "/sbin/ifup '#{network[:device]}'"
|
||||
network_up_commands << "/sbin/ifup '#{network[:device]}'"
|
||||
end
|
||||
retryable(on: Vagrant::Errors::VagrantError, sleep: 2, tries: 2) do
|
||||
comm.sudo(network_up_commands.join("\n"))
|
||||
end
|
||||
comm.sudo(commands.join("\n"))
|
||||
end
|
||||
|
||||
# Simple helper to upload content to guest temporary file
|
||||
|
||||
@ -79,8 +79,9 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
|
||||
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth1'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth2' || true")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth2'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth1'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth2'")
|
||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth1'")
|
||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth2'")
|
||||
|
||||
end
|
||||
|
||||
context "with systemd" do
|
||||
@ -96,8 +97,8 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
|
||||
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth1'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth2' || true")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth2'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth1'")
|
||||
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth2'")
|
||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth1'")
|
||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth2'")
|
||||
end
|
||||
|
||||
context "with systemd-networkd" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user