self.exec_command_with_retries

in ebs/libraries/block_device.rb [255:269]


  def self.exec_command_with_retries(command, max_tries=3, exponential_sleep_time_factor=10)
    try_count = 1
    while try_count <= max_tries
      Chef::Log.info("Try #{try_count}/#{max_tries}: #{command}")
      break if exec_command(command)
      sleep_time = exponential_sleep_time_factor * (2 ** (try_count - 1))
      Chef::Log.info("Try #{try_count}/#{max_tries} for '#{command}' failed - retrying in #{sleep_time} seconds.")
      sleep sleep_time
      try_count += 1
    end
    success = try_count <= max_tries
    Chef::Log.info("'#{command}' successful after #{try_count}/#{max_tries} tries? #{success}")
    success
  end