chef-shell --solo Chef::Exceptions::PrivateKeyMissing - ruby

I am building a recipe where I'm trying to debug how the attributes are being set, but when I execute chef-shell it gives me errors about missing /etc/chef/client.pem, from what I can tell those are generated by chef server, as I'm running in --solo mode shouldn't it skip the requirement for such things? Or am I using chef-shell improperly?
chef-shell --solo -c debug/solo.rb -j debug/nodes.json
loading configuration: debug/solo.rb
Session type: solo
Loading...done.
This is the chef-shell.
Chef Version: 11.14.6
http://www.opscode.com/chef
http://docs.opscode.com/
run `help' for help, `exit' or ^D to quit.
Ohai2u bob#MSIGS70stealth.thalhalla.net!
chef > roles.all
[2014-11-10T13:15:08-06:00] WARN: Failed to read the private key /etc/chef/client.pem: #<Errno::ENOENT: No such file or directory # rb_sysopen - /etc/chef/client.pem>
Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/client.pem, which you told me to use to sign requests!
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:78:in `rescue in load_signing_key'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:68:in `load_signing_key'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/http/authenticator.rb:38:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/rest.rb:66:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/rest.rb:66:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/search/query.rb:34:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/search/query.rb:34:in `initialize'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/role.rb:184:in `new'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/role.rb:184:in `list'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell/model_wrapper.rb:82:in `list_objects'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell/model_wrapper.rb:50:in `all'
from (irb):1
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:75:in `block in start'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:74:in `catch'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/lib/chef/shell.rb:74:in `start'
from /home/bob/.rvm/gems/ruby-2.1.0/gems/chef-11.14.6/bin/chef-shell:37:in `<top (required)>'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/chef-shell:23:in `load'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/chef-shell:23:in `<main>'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks2.1:15:in `eval'
from /home/bob/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks2.1:15:in `<main>'chef >

That method just isn't supported in solo mode. You can see in the code that is just calls either search or chef_server_rest directly.

Related

Ruby/Cucumber Error: Step definitions must always have a proc or symbol

My automation test suite for an application is written using Ruby/Cucumber. When I try to run the tests using the cucumber command, and I receive the following error: Step definitions must always have a proc or symbol. I can't find any references to this error online except for the source code itself.
Full stack trace:
Step definitions must always have a proc or symbol (Cucumber::Glue::StepDefinition::MissingProc)
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/step_definition.rb:29:in `new'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/registry_and_more.rb:83:in `register_rb_step_definition'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/dsl.rb:31:in `register_rb_step_definition'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/dsl.rb:133:in `register_rb_step_definition'
C:/Users/westoa1/dev/eclipse-workspace/rms-quality-manager/cucumber/features/step_definitions/data_steps.rb:75:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/registry_and_more.rb:107:in `load'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/registry_and_more.rb:107:in `load_code_file'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:144:in `load_file'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:85:in `block in load_files!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:84:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:84:in `load_files!' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:272:in `load_step_definitions'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:68:in `run!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
C:/Ruby25-x64/bin/cucumber:23:in `load'
C:/Ruby25-x64/bin/cucumber:23:in `<main>'
I searched through my step definition files and found an incomplete step definition with no block:
Given 'There is a user'
The block was removed while resolving merge conflicts, and completing the step definition solved the error:
Given 'There is a user' do
(do stuff)
end

How to run Prometheus Ruby Client

I want to run the Prometheus Ruby Client, to gather statistics values and to save in the Prometheus database.
I've followed the instructions here : Rack middleware
https://github.com/prometheus/client_ruby#rack-middleware
I've installed two gems, prometheus and prometheus-client.
The exporter.rb (https://github.com/prometheus/client_ruby/blob/master/lib/prometheus/middleware/exporter.rb) and the collector.rb (https://github.com/prometheus/client_ruby/blob/master/lib/prometheus/middleware/collector.rb) is saved in the location: prometheus/middleware
I've saved the config.ru (https://github.com/prometheus/client_ruby#rack-middleware) in the local folder.
Then I've started the rack web server with: rackup -d config.ru -I /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/prometheus-client-0.6.0/lib -I /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/quantile-0.2.0/lib
The -I include statement is necessary to let find the required files.
Then I got this error :
/home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/prometheus-client-0.6.0/lib -I /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/quantile-0.2.0/lib
nil
Exception `ArgumentError' at /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:86 - wrong number of arguments (given 2, expected 1)
Exception `ArgumentError' at /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:49 - wrong number of arguments (given 2, expected 1)
Exception `ArgumentError' at /home/sven/.rbenv/versions/2.3.3/bin/rackup:22 - wrong number of arguments (given 2, expected 1)
/home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/deflater.rb:20:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:86:in `new'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:86:in `block in use'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:134:in `block in to_app'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:134:in `each'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:134:in `inject'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:134:in `to_app'
from /home/sven/StarPerfMonitor_v2.0.0/config.ru:13:in `<main>'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:49:in `eval'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:49:in `new_from_string'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:40:in `parse_file'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/server.rb:199:in `app'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/server.rb:314:in `wrapped_app'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/server.rb:242:in `start'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/lib/rack/server.rb:141:in `start'
from /home/sven/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rack-1.5.5/bin/rackup:4:in `<top (required)>'
from /home/sven/.rbenv/versions/2.3.3/bin/rackup:22:in `load'
from /home/sven/.rbenv/versions/2.3.3/bin/rackup:22:in `<main>'
It seems you are using client_ruby 0.6.0 whereas Prometheus::Middleware is available only for client_ruby 0.7.0.
Check https://github.com/prometheus/client_ruby/tree/v0.6.0
This issue was too tricky, and I decided to switch over to InfluxDB.
And I was able to run the Ruby Client within minutes. It seems to be much more better for me, than Prometheus. Sorry.

Openshift rhc port forward exception

I am trying to open ports so i access my database remotely from my pc
I am running on Ruby200-x64 and when i try to access port forward
rhc port-forward -a appname
i get the following response/error:
Checking available ports ... C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:176:in `malloc': bignum too big to convert into `long' (RangeError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:176:in `malloc_ptr'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:240:in `get_token_information'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:213:in `get_current_user'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:189:in `get_security_attributes_for_user'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:332:in `send_query'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/pageant.rb:309:in `send'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:148:in `send_packet'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:165:in `send_and_wait'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:76:in `negotiate!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/agent/socket.rb:48:in `connect'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/key_manager.rb:179:in `agent'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/key_manager.rb:103:in `each_identity'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:79:in `block in authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh.rb:211:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands/port_forward.rb:86:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands.rb:294:in `execute'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/commands.rb:285:in `block (3 levels) in to_commander'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:155:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:421:in `run_active_command'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/command_runner.rb:72:in `run!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in `run!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/lib/rhc/cli.rb:37:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rhc-1.38.4/bin/rhc:20:in `<top (required)>'
from C:/Ruby200-x64/bin/rhc:23:in `load'
from C:/Ruby200-x64/bin/rhc:23:in `<main>'
It's a bit late but maybe it can help to newcomer.
The solution is, or better say- workaround, to exit the pageant while you port-forward the app. And when done turn it on again if you need to ssh to it.
I found a sort of workaround too, whenever i recieve this error i do the oldest trick in the books, a restart and it works all the times(for now)

Failures running rspec tests for the WebSphere Liberty Profile Buildpack

I am using the open source repo for the OSS Cloud Foundry Liberty Profile Buildpack and running into the following failures when executing bundle exec rspec
681 examples, 3 failures
Failed examples:
rspec ./spec/bin/compile_spec.rb:49 # compile script should work with the liberty WEB-INF case
rspec ./spec/bin/compile_spec.rb:65 # compile script should also work with the zipped up server case
rspec ./spec/bin/compile_spec.rb:82 # compile script pass environment variable directory
The 3 failures have a common stack ...
1) compile script should work with the liberty WEB-INF case
Failure/Error: expect(result).to be_success
expected `#<Process::Status: pid 84398 exit 1>.success?` to return true, got false
# ./vendor/bundle/ruby/1.9.1/gems/rspec-expectations-3.0.4/lib/rspec/expectations/fail_with.rb:30:in `fail_with'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-expectations-3.0.4/lib/rspec/expectations/handler.rb:37:in `handle_failure'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-expectations-3.0.4/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-expectations-3.0.4/lib/rspec/expectations/expectation_target.rb:54:in `to'
# ./spec/bin/compile_spec.rb:59:in `block (5 levels) in <top (required)>'
# /Users/kelapr/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/open3.rb:208:in `popen_run'
# /Users/kelapr/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/open3.rb:90:in `popen3'
# ./spec/bin/compile_spec.rb:53:in `block (4 levels) in <top (required)>'
# ./spec/bin/compile_spec.rb:124:in `with_memory_limit'
# ./spec/bin/compile_spec.rb:52:in `block (3 levels) in <top (required)>'
# /Users/kelapr/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
# ./spec/bin/compile_spec.rb:50:in `block (2 levels) in <top (required)>'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:148:in `instance_exec'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:148:in `block in run'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:301:in `with_around_example_hooks'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:145:in `run'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:494:in `block in run_examples'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `map'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `run_examples'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:457:in `run'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `map'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:54:in `report'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:108:in `run_specs'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:86:in `run'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
# ./vendor/bundle/ruby/1.9.1/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
# ./vendor/bundle/ruby/1.9.1/bin/rspec:23:in `load'
# ./vendor/bundle/ruby/1.9.1/bin/rspec:23:in `<main>'
Cans someone guide us on how to resolve these failures that seem to stem from an Open3.popen3 call from within a Dir.mktmpdir block. These results from the master branch of https://github.com/cloudfoundry/ibm-websphere-liberty-buildpack/
-Thanks.
I don't see such failures in the Travis CI system. Also, testing on a local machine didn't result in any failures. Do you see any other errors in the test output? In case of a failure, there should be messages starting with stdout: and stderr: in the output.
The issues with the long running tests with these failure is that stack traces are very poor at figuring out what actually happened. We determined the root cause of these failures as lack of network connectivty.

capistrano deploy error - newbie

I'm new to ruby and currently having issues deploying with capistrano. below the errors I am getting.
cap aborted!
Operation timed out - connect(2)
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `open'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `block in initialize'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh.rb:200:in `new'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh.rb:200:in `start'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:156:in `ssh'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:109:in `block in _execute'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:75:in `within'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.0/lib/capistrano/tasks/git.rake:44:in `block (3 levels) in <top (required)>'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/stefydu/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:create_release => git:update
(See full trace by running task with --trace)
Not a solution, but an explanation with workaround:
Capistrano 3, and with it sshkit, doesn't reuse existing SSH connections, but start a new one for every task (see https://github.com/capistrano/sshkit/issues/34).
Some servers, respectively their firewalls, seem to block new connection requests if they come to fast or if there are too many open connections.
Solutions:
Fix SSHKit/Capistrano to reuse connections
Configure your server/firewall to allow tons of parallel ssh sessions (for a simple rails app about 15)
use my hack below (Disclaimer: no, don't use it):
We're going to extend (monkeypatch) the execute method in gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb. That can be done via the Capfile:
# Overwrite execute method to avoid timeouts
class SSHKit::Backend::Netssh
def execute(*args)
_execute(*args).success?
rescue Errno::ETIMEDOUT
#tries ||= 0
raise "Nope, no way" if #tries > 5
puts "Timeout. yeah. Try it again (#{#tries})"
sleep 5
#tries += 1
execute(*args)
end
end
This gives the server a chance to breathe...
Capistrano uses a connection pool for SSH now:
https://github.com/capistrano/sshkit/pull/70

Resources