From a7d3458abc57959e482c8a5177b542e55521f9f7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Oct 2014 22:48:48 -0700 Subject: [PATCH] provisioners/shell: retry getting SSH info a few times [GH-3924] --- CHANGELOG.md | 1 + plugins/provisioners/shell/provisioner.rb | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9cb0662..e68e3fd68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ BUG FIXES: - provisioners/docker: Get GPG key over SSL. [GH-4597] - provisioners/docker: Search for docker binary in multiple places. [GH-4580] - provisioners/salt: Highstate works properly with a master. [GH-4471] + - provisioners/shell: Retry getting SSH info a few times. [GH-3924] - provisioners/shell: PowerShell scripts can have args. [GH-4548] - synced\_folders/nfs: Don't modify NFS exports file if no exports. [GH-4619] diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index 3e91fd891..58359befc 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -2,10 +2,13 @@ require "pathname" require "tempfile" require "vagrant/util/downloader" +require "vagrant/util/retryable" module VagrantPlugins module Shell class Provisioner < Vagrant.plugin("2", :provisioner) + extend Vagrant::Util::Retryable + def provision args = "" if config.args.is_a?(String) @@ -50,7 +53,13 @@ module VagrantPlugins # Upload the script to the machine @machine.communicate.tap do |comm| # Reset upload path permissions for the current ssh user - user = @machine.ssh_info[:username] + info = nil + retryable(on: Vagrant::Errors::SSHNotReady, tries: 3, sleep: 2) do + info = @machine.ssh_info + raise Vagrant::Errors::SSHNotReady if info.nil? + end + + user = info[:username] comm.sudo("chown -R #{user} #{config.upload_path}", error_check: false)