summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-02-11 11:50:15 -0800
committerGitHub <noreply@github.com>2017-02-11 11:50:15 -0800
commit4bb7346b9d3f5468b9f0dcee093da50169fc70d6 (patch)
treeb5878aff8c33ba37df84b487a2fee291f6f54381
parent937b44872269fd00e30cf15f4094d1d8004fe774 (diff)
parent45f199aaa758b5af2aa26205ad1d551131d932d5 (diff)
downloadchef-4bb7346b9d3f5468b9f0dcee093da50169fc70d6.tar.gz
Merge pull request #5807 from chef/multissh
Require net-ssh-multi 1.2.1 and remove our monkeypatch
-rw-r--r--Gemfile.lock22
-rw-r--r--chef.gemspec2
-rw-r--r--lib/chef/knife/ssh.rb1
-rw-r--r--lib/chef/monkey_patches/net-ssh-multi.rb141
4 files changed, 12 insertions, 154 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index 454c7360dc..318e6114b0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -63,7 +63,7 @@ PATH
mixlib-shellout (~> 2.0)
net-sftp (~> 2.1, >= 2.1.2)
net-ssh (>= 2.9, < 5.0)
- net-ssh-multi (~> 1.1)
+ net-ssh-multi (~> 1.2, >= 1.2.1)
ohai (>= 8.6.0.alpha.1, < 13)
plist (~> 3.2)
proxifier (~> 1.0)
@@ -93,7 +93,7 @@ PATH
mixlib-shellout (~> 2.0)
net-sftp (~> 2.1, >= 2.1.2)
net-ssh (>= 2.9, < 5.0)
- net-ssh-multi (~> 1.1)
+ net-ssh-multi (~> 1.2, >= 1.2.1)
ohai (>= 8.6.0.alpha.1, < 13)
plist (~> 3.2)
proxifier (~> 1.0)
@@ -138,13 +138,13 @@ GEM
mixlib-cli (~> 1.4)
artifactory (2.6.0)
ast (2.3.0)
- aws-sdk (2.7.5)
- aws-sdk-resources (= 2.7.5)
- aws-sdk-core (2.7.5)
+ aws-sdk (2.7.7)
+ aws-sdk-resources (= 2.7.7)
+ aws-sdk-core (2.7.7)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.7.5)
- aws-sdk-core (= 2.7.5)
+ aws-sdk-resources (2.7.7)
+ aws-sdk-core (= 2.7.7)
aws-sigv4 (1.0.0)
backports (3.6.8)
binding_of_caller (0.7.2)
@@ -172,7 +172,7 @@ GEM
cheffish (4.1.1)
chef-zero (~> 5.0)
net-ssh
- chefspec (5.3.0)
+ chefspec (5.4.0)
chef (>= 12.0)
fauxhai (~> 3.6)
rspec (~> 3.0)
@@ -248,7 +248,7 @@ GEM
chef (~> 12.0)
stove (~> 4.0)
thor
- hashie (3.5.1)
+ hashie (3.5.3)
highline (1.7.8)
http-cookie (1.0.3)
domain_name (~> 0.5)
@@ -261,7 +261,7 @@ GEM
json (2.0.3)
kitchen-docker (2.6.0)
test-kitchen (>= 1.0.0)
- kitchen-ec2 (1.2.0)
+ kitchen-ec2 (1.3.0)
aws-sdk (~> 2)
excon
multi_json
@@ -270,7 +270,7 @@ GEM
kitchen-sync (2.1.2)
net-sftp
test-kitchen (>= 1.0.0)
- kitchen-vagrant (1.0.0)
+ kitchen-vagrant (1.0.1)
test-kitchen (~> 1.4)
knife-windows (1.9.0)
winrm (~> 2.1)
diff --git a/chef.gemspec b/chef.gemspec
index 402b8fbec5..57d160541b 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_dependency "ffi-yajl", "~> 2.2"
s.add_dependency "net-ssh", ">= 2.9", "< 5.0"
- s.add_dependency "net-ssh-multi", "~> 1.1"
+ s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
s.add_dependency "net-sftp", "~> 2.1", ">= 2.1.2"
s.add_dependency "highline", "~> 1.6", ">= 1.6.9"
s.add_dependency "erubis", "~> 2.7"
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index 6797f6cab2..e206f72630 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -26,7 +26,6 @@ class Chef
deps do
require "net/ssh"
require "net/ssh/multi"
- require "chef/monkey_patches/net-ssh-multi"
require "readline"
require "chef/exceptions"
require "chef/search/query"
diff --git a/lib/chef/monkey_patches/net-ssh-multi.rb b/lib/chef/monkey_patches/net-ssh-multi.rb
deleted file mode 100644
index 7b7b1bbf7f..0000000000
--- a/lib/chef/monkey_patches/net-ssh-multi.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# Author:: Serdar Sutay (<serdar@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# == net-ssh-multi gem patch for concurrency
-# net-ssh-multi gem has 2 bugs associated with the use of
-# :concurrent_connections option.
-# 1-) There is a race condition while fetching the next_session when
-# :concurrent_connections are set. @open_connections is being
-# incremented by the connection thread and sometimes
-# realize_pending_connections!() method can create more than required
-# connection threads before the @open_connections is set by the
-# previously created threads.
-# 2-) When :concurrent_connections is set, server classes are setup
-# with PendingConnection objects that always return true to busy?
-# calls. If a connection fails when :concurrent_connections is set,
-# server ends up returning true to all busy? calls since the session
-# object is not replaced. Due to this, main event loop (process()
-# function) never gets terminated.
-#
-# See: https://github.com/net-ssh/net-ssh-multi/pull/4
-
-require "net/ssh/multi/version"
-
-if Net::SSH::Multi::Version::STRING == "1.1.0" || Net::SSH::Multi::Version::STRING == "1.2.0"
-
- require "net/ssh/multi"
-
- module Net
- module SSH
- module Multi
- class Server
-
- # Make sure that server returns false if the ssh connection
- # has failed.
- def busy?(include_invisible = false)
- !failed? && session && session.busy?(include_invisible)
- end
-
- end
-
- class Session
- def next_session(server, force = false) #:nodoc:
- # don't retry a failed attempt
- return nil if server.failed?
-
- @session_mutex.synchronize do
- if !force && concurrent_connections && concurrent_connections <= open_connections
- connection = PendingConnection.new(server)
- @pending_sessions << connection
- return connection
- end
-
- # ===== PATCH START
- # Only increment the open_connections count if the connection
- # is not being forced. Incase of a force, it will already be
- # incremented.
- if !force
- @open_connections += 1
- end
- # ===== PATCH END
- end
-
- begin
- server.new_session
-
- # I don't understand why this should be necessary--StandardError is a
- # subclass of Exception, after all--but without explicitly rescuing
- # StandardError, things like Errno::* and SocketError don't get caught
- # here!
- rescue Exception, StandardError => e
- server.fail!
- @session_mutex.synchronize { @open_connections -= 1 }
-
- case on_error
- when :ignore then
- # do nothing
- when :warn then
- warn("error connecting to #{server}: #{e.class} (#{e.message})")
- when Proc then
- go = catch(:go) { on_error.call(server); nil }
- case go
- when nil, :ignore then # nothing
- when :retry then retry
- when :raise then raise
- else warn "unknown 'go' command: #{go.inspect}"
- end
- else
- raise
- end
-
- return nil
- end
- end
-
- def realize_pending_connections! #:nodoc:
- return unless concurrent_connections
-
- server_list.each do |server|
- server.close if !server.busy?(true)
- server.update_session!
- end
-
- @connect_threads.delete_if { |t| !t.alive? }
-
- count = concurrent_connections ? (concurrent_connections - open_connections) : @pending_sessions.length
- count.times do
- session = @pending_sessions.pop
- break unless session
- # ===== PATCH START
- # Increment the open_connections count here to prevent
- # creation of connection thread again before that is
- # incremented by the thread.
- @session_mutex.synchronize { @open_connections += 1 }
- # ===== PATCH END
- @connect_threads << Thread.new do
- session.replace_with(next_session(session.server, true))
- end
- end
- end
-
- end
- end
- end
- end
-
-end