Skip to content

Commit

Permalink
Revert train to 1.4.6, update sudo error checks
Browse files Browse the repository at this point in the history
This reverts train to 1.4.6.  Later versions introduce a gcp
dependency that does not cleanly pass omnibus health checks.  While that
is being resolved, we'll continue to stick to 1.4.6.

We were using the Train::Error#reason field added in 1.4.12; this PR
updates error handling to do string-based matching of the messages
provided by train instead.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
  • Loading branch information
marcparadise committed May 21, 2018
1 parent e847ada commit 8f41bce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 178 deletions.
2 changes: 1 addition & 1 deletion components/chef-run/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gemspec
# TODO when chef-dk 3.0 is released to Rubygems as 3.0 we can get rid of this
gem "chef-dk", git: "https://github.com/chef/chef-dk.git", branch: "master"

gem "train", git: "https://github.com/chef/train.git", branch: "v1.4.12"
gem "train", git: "https://github.com/chef/train.git", branch: "v1.4.6"

group :localdev do
gem "irbtools-more", require: "irbtools/binding"
Expand Down
171 changes: 4 additions & 167 deletions components/chef-run/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ GIT

GIT
remote: https://github.com/chef/train.git
revision: a3db8fc61cd1d8fae772d7bae98de6c1527c5129
branch: v1.4.12
revision: daefae3357bdaa903ec75da9ab6b222073f6fa07
branch: v1.4.6
specs:
train (1.4.12)
train (1.4.6)
aws-sdk (~> 2)
azure_mgmt_resources (~> 0.15)
docker-api (~> 1.26)
google-api-client (~> 0.19.8)
google-cloud (~> 0.51.1)
googleauth (~> 0.6.2)
inifile
json (>= 1.8, < 3.0)
mixlib-shellout (~> 2.0)
Expand Down Expand Up @@ -154,11 +151,8 @@ GEM
debugging (1.1.1)
binding.repl (~> 3.0)
paint (>= 0.9, < 3.0)
declarative (0.0.10)
declarative-option (0.1.0)
did_you_mean (1.2.1)
diff-lcs (1.3)
digest-crc (0.4.1)
docile (1.3.0)
docker-api (1.34.2)
excon (>= 0.47.0)
Expand All @@ -182,143 +176,6 @@ GEM
ffi-yajl (2.3.1)
libyajl2 (~> 1.2)
fuzzyurl (0.9.0)
google-api-client (0.19.8)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.5, < 0.7.0)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
google-cloud (0.51.1)
google-cloud-bigquery (~> 1.1)
google-cloud-bigquery-data_transfer (~> 0.1)
google-cloud-container (~> 0.1)
google-cloud-dataproc (~> 0.1)
google-cloud-datastore (~> 1.4)
google-cloud-dlp (~> 0.1)
google-cloud-dns (~> 0.28)
google-cloud-error_reporting (~> 0.30)
google-cloud-firestore (~> 0.21)
google-cloud-language (~> 0.30)
google-cloud-logging (~> 1.5)
google-cloud-monitoring (~> 0.27)
google-cloud-os_login (~> 0.1)
google-cloud-pubsub (~> 0.30)
google-cloud-resource_manager (~> 0.29)
google-cloud-spanner (~> 1.3)
google-cloud-speech (~> 0.29)
google-cloud-storage (~> 1.10)
google-cloud-trace (~> 0.31)
google-cloud-translate (~> 1.2)
google-cloud-video_intelligence (~> 1.0)
google-cloud-vision (~> 0.28)
google-cloud-bigquery (1.4.0)
concurrent-ruby (~> 1.0)
google-api-client (~> 0.19.8)
google-cloud-core (~> 1.2)
googleauth (~> 0.6.2)
google-cloud-bigquery-data_transfer (0.1.0)
google-gax (~> 1.0)
google-cloud-container (0.1.0)
google-gax (~> 1.0.1)
google-cloud-core (1.2.0)
google-cloud-env (~> 1.0)
google-cloud-dataproc (0.1.0)
google-gax (~> 1.0.0)
google-cloud-datastore (1.4.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
google-protobuf (~> 3.3)
google-cloud-dlp (0.4.0)
google-gax (~> 1.0)
google-cloud-dns (0.28.0)
google-api-client (~> 0.19.0)
google-cloud-core (~> 1.2)
googleauth (~> 0.6.2)
zonefile (~> 1.04)
google-cloud-env (1.0.1)
faraday (~> 0.11)
google-cloud-error_reporting (0.30.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
stackdriver-core (~> 1.3)
google-cloud-firestore (0.21.0)
concurrent-ruby (~> 1.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
google-cloud-language (0.30.0)
google-gax (~> 1.0)
google-cloud-logging (1.5.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
stackdriver-core (~> 1.3)
google-cloud-monitoring (0.28.0)
google-gax (~> 1.0)
google-cloud-os_login (0.1.0)
google-gax (~> 1.0.0)
google-cloud-pubsub (0.30.2)
concurrent-ruby (~> 1.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
grpc-google-iam-v1 (~> 0.6.9)
google-cloud-resource_manager (0.29.0)
google-api-client (~> 0.19.8)
google-cloud-core (~> 1.2)
googleauth (~> 0.6.2)
google-cloud-spanner (1.4.0)
concurrent-ruby (~> 1.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
grpc-google-iam-v1 (~> 0.6.9)
google-cloud-speech (0.29.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
google-cloud-storage (1.12.0)
digest-crc (~> 0.4)
google-api-client (~> 0.19.0)
google-cloud-core (~> 1.2)
googleauth (~> 0.6.2)
google-cloud-trace (0.33.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
stackdriver-core (~> 1.3)
google-cloud-translate (1.2.0)
faraday (~> 0.13)
google-cloud-core (~> 1.2)
googleauth (~> 0.6.2)
google-cloud-video_intelligence (1.0.0)
google-gax (~> 1.0)
google-cloud-vision (0.28.0)
google-cloud-core (~> 1.2)
google-gax (~> 1.0)
google-gax (1.0.1)
google-protobuf (~> 3.2)
googleapis-common-protos (>= 1.3.5, < 2.0)
googleauth (~> 0.6.2)
grpc (>= 1.7.2, < 2.0)
rly (~> 0.2.3)
google-protobuf (3.5.1.2)
googleapis-common-protos (1.3.7)
google-protobuf (~> 3.0)
googleapis-common-protos-types (~> 1.0)
grpc (~> 1.0)
googleapis-common-protos-types (1.0.1)
google-protobuf (~> 3.0)
googleauth (0.6.2)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
logging (~> 2.0)
memoist (~> 0.12)
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
grpc (1.12.0)
google-protobuf (~> 3.1)
googleapis-common-protos-types (~> 1.0.0)
googleauth (>= 0.5.1, < 0.7)
grpc-google-iam-v1 (0.6.9)
googleapis-common-protos (>= 1.3.1, < 2.0)
grpc (~> 1.0)
gssapi (1.2.0)
ffi (>= 1.0.1)
gyoku (1.3.1)
Expand Down Expand Up @@ -372,20 +229,15 @@ GEM
iso8601 (0.9.1)
jmespath (1.4.0)
json (2.1.0)
jwt (2.1.0)
libyajl2 (1.2.0)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
looksee (4.0.0)
memoist (0.16.0)
method_locator (0.0.4)
method_source (0.9.0)
methodfinder (2.2.1)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
minitar (0.6.1)
mixlib-archive (0.4.6)
mixlib-log
Expand Down Expand Up @@ -437,7 +289,7 @@ GEM
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
ori (0.1.0)
os (0.9.6)
os (1.0.0)
paint (1.0.1)
parallel (1.12.1)
parser (2.5.1.0)
Expand All @@ -464,12 +316,6 @@ GEM
rack (2.0.5)
rainbow (3.0.0)
rake (12.3.1)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
rly (0.2.3)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
Expand Down Expand Up @@ -509,11 +355,6 @@ GEM
rspec-its
specinfra (~> 2.72)
sfl (2.3)
signet (0.8.1)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand All @@ -529,8 +370,6 @@ GEM
sfl
spoon (0.0.6)
ffi
stackdriver-core (1.3.0)
google-cloud-core (~> 1.2)
syslog-logger (1.6.8)
systemu (2.6.5)
thor (0.20.0)
Expand All @@ -542,7 +381,6 @@ GEM
tty-cursor (0.5.0)
tty-spinner (0.8.0)
tty-cursor (>= 0.5.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
Expand All @@ -569,7 +407,6 @@ GEM
paint (>= 0.9, < 3.0)
wmi-lite (1.0.0)
yard (0.9.12)
zonefile (1.06)

PLATFORMS
ruby
Expand Down
25 changes: 15 additions & 10 deletions components/chef-run/lib/chef-run/target_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TargetHost
attr_reader :config, :reporter, :backend, :transport_type, :opts

def self.instance_for_url(target, opts = {})
opts = { target: @url }
target_host = new(target, opts)
target_host.connect!
target_host
Expand Down Expand Up @@ -159,17 +160,21 @@ class ConnectionFailure < ChefRun::ErrorNoLogs
def initialize(original_exception, connection_opts)
sudo_command = connection_opts[:sudo_command]
init_params =
case original_exception.reason
when :sudo_password_required then "CHEFTRN003"
when :bad_sudo_password then "CHEFTRN004"
when :sudo_command_not_found then ["CHEFTRN005", sudo_command]
when :sudo_no_tty then "CHEFTRN006"
# Comments below show the original_exception.reason values ot check for instead of strings,
# after train 1.4.12 is consumable.
case original_exception.message # original_exception.reason
when /Sudo requires a password/ # :sudo_password_required
"CHEFTRN003"
when /Wrong sudo password/ #:bad_sudo_password
"CHEFTRN004"
when /Can't find sudo command/, /No such file/, /command not found/ # :sudo_command_not_found
# NOTE: In the /No such file/ case, reason will be nil - we still have
# to check message text. (Or PR to train to handle this case)
["CHEFTRN005", sudo_command] # :sudo_command_not_found
when /Sudo requires a TTY.*/ # :sudo_no_tty
"CHEFTRN006"
else
case original_exception.message
when /No such file/ then ["CHEFTRN005", sudo_command]
else
["CHEFTRN999", original_exception.message]
end
["CHEFTRN999", original_exception.message]
end
super(*(Array(init_params).flatten))
end
Expand Down

0 comments on commit 8f41bce

Please sign in to comment.