Skip to content

Instantly share code, notes, and snippets.

@damm
Created March 10, 2013 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damm/5130887 to your computer and use it in GitHub Desktop.
Save damm/5130887 to your computer and use it in GitHub Desktop.
test-kitchen failing due to github rate limiting
-----> Setting up <carbontest-precise>
Could not access https://api.github.com/repos/opscode/kb/git/refs/tags (403 "Forbidden")
sudo: /opt/kb/bin/kb: command not found
>>>>>> Kitchen::Instance crashed!
Kitchen::ActionFailed: SSH exited (1) for command: [sudo /opt/chef/embedded/bin/ruby -e "$(cat <<"EOF"
# -*- encoding: utf-8 -*-
require "chef/rest"
require "chef/platform"
require "fileutils"
require "tempfile"
EXCEPTIONS = [ SocketError, Errno::ECONNREFUSED, Timeout::Error,
Net::HTTPFatalError, Net::HTTPServerException ]
class KbInstaller
def initialize(opts = {})
@url = opts[:url] || calculate_url(opts[:tag])
@root = opts[:root] || "/opt/kb"
@tarfile = Tempfile.new("kitchen.tar.gz")
end
def run!
if File.exists?(File.join(@root, "bin/kb"))
log "Detected previous kb installation, skipping install"
else
download
install
log "kb installed!"
end
end
private
def log(msg)
puts " #{msg}"
end
def download
log "Downloading kb from #{@url}"
rest = Chef::REST.new(@url, nil, nil, {})
raw_file = rest.streaming_request(rest.create_url(@url), {})
FileUtils.cp raw_file.path, @tarfile.path
raw_file.close!
rescue *EXCEPTIONS => e
abort "Could not download from #{@url} (#{e.message})"
end
def install
log "Installing kb to #{@root}"
FileUtils.mkdir_p @root
`cd #{@root} && gunzip -c #{@tarfile.path} | tar xf - --strip-components=1`
@tarfile.unlink
end
def calculate_url(tag)
"https://github.com/opscode/kb/archive/#{tag || latest_tag}.tar.gz"
end
def latest_tag
t_url = "https://api.github.com/repos/opscode/kb/git/refs/tags"
rest = Chef::REST.new(t_url, nil, nil, {})
tags = rest.get_rest(t_url, false, {}).map { |t| t["ref"].split("/").last }
tags.sort.select { |t| t =~ /^v[0-9]/ }.last
rescue *EXCEPTIONS => e
return "master" if e.message == %{404 "Not Found"}
abort "Could not access #{t_url} (#{e.message})"
end
end
if __FILE__ == $0
KbInstaller.new({
:url => ENV["KB_URL"], :tag => ENV["KB_TAG"], :root => ENV["KB_INSTALL_ROOT"]
}).run!
end
EOF
)"
sudo /opt/kb/bin/kb install minitest]
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/driver/ssh_base.rb:141:in `block in ssh'
/tmp/fdjsklfdsjkl/ruby/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh.rb:193:in `start'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/driver/ssh_base.rb:136:in `ssh'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/driver/ssh_base.rb:51:in `setup'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:248:in `public_send'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:248:in `block in perform_action'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:278:in `call'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:278:in `synchronize_or_call'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:258:in `block in action'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:257:in `action'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:248:in `perform_action'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:235:in `setup_action'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:221:in `block in transition_to'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:220:in `each'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:220:in `transition_to'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:145:in `verify'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:174:in `block in test'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/instance.rb:170:in `test'
/tmp/fdjsklfdsjkl/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `public_send'
/tmp/fdjsklfdsjkl/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in `dispatch'
/tmp/fdjsklfdsjkl/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/actor.rb:327:in `block in handle_message'
/tmp/fdjsklfdsjkl/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/tasks/task_fiber.rb:24:in `block in initialize'
/tmp/fdjsklfdsjkl/ruby/1.9.1/bundler/gems/test-kitchen-75d80dee38de/lib/kitchen/driver/ssh_base.rb:141:in `block in ssh': SSH exited (1) for command: [sudo /opt/chef/embedded/bin/ruby -e "$(cat <<"EOF" (Kitchen::ActionFailed)
# -*- encoding: utf-8 -*-
require "chef/rest"
require "chef/platform"
require "fileutils"
require "tempfile"
EXCEPTIONS = [ SocketError, Errno::ECONNREFUSED, Timeout::Error,
Net::HTTPFatalError, Net::HTTPServerException ]
class KbInstaller
def initialize(opts = {})
@url = opts[:url] || calculate_url(opts[:tag])
@root = opts[:root] || "/opt/kb"
@tarfile = Tempfile.new("kitchen.tar.gz")
end
def run!
if File.exists?(File.join(@root, "bin/kb"))
log "Detected previous kb installation, skipping install"
else
download
install
log "kb installed!"
end
end
private
def log(msg)
puts " #{msg}"
end
def download
log "Downloading kb from #{@url}"
rest = Chef::REST.new(@url, nil, nil, {})
raw_file = rest.streaming_request(rest.create_url(@url), {})
FileUtils.cp raw_file.path, @tarfile.path
raw_file.close!
rescue *EXCEPTIONS => e
abort "Could not download from #{@url} (#{e.message})"
end
def install
log "Installing kb to #{@root}"
FileUtils.mkdir_p @root
`cd #{@root} && gunzip -c #{@tarfile.path} | tar xf - --strip-components=1`
@tarfile.unlink
end
def calculate_url(tag)
"https://github.com/opscode/kb/archive/#{tag || latest_tag}.tar.gz"
end
def latest_tag
t_url = "https://api.github.com/repos/opscode/kb/git/refs/tags"
rest = Chef::REST.new(t_url, nil, nil, {})
tags = rest.get_rest(t_url, false, {}).map { |t| t["ref"].split("/").last }
tags.sort.select { |t| t =~ /^v[0-9]/ }.last
rescue *EXCEPTIONS => e
return "master" if e.message == %{404 "Not Found"}
abort "Could not access #{t_url} (#{e.message})"
end
end
if __FILE__ == $0
KbInstaller.new({
:url => ENV["KB_URL"], :tag => ENV["KB_TAG"], :root => ENV["KB_INSTALL_ROOT"]
}).run!
end
EOF
)"
sudo /opt/kb/bin/kb install minitest]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment