chef 16.3.38-universal-mingw32 → 16.3.45-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chef/handler.rb +2 -0
- data/lib/chef/http.rb +9 -10
- data/lib/chef/http/authenticator.rb +2 -0
- data/lib/chef/resource/hostname.rb +18 -18
- data/lib/chef/server_api_versions.rb +4 -0
- data/lib/chef/version.rb +1 -1
- data/spec/unit/http/api_versions_spec.rb +19 -1
- data/spec/unit/server_api_spec.rb +43 -16
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6729febd434b9728dea685c0d05d36143e1ee0ccd03e9142cf03ce08ea9eef
|
4
|
+
data.tar.gz: 81380fee7ddf96c867e00acb9d83703fd9f9200561bd816eeaae56a0c2a72770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab132c6f2ecb0d419170246976dedbdffba7679acc50ce4b9eeaf25313cd576b64bacaa6bbd324a73fa035dbd83e066d575d3d5d351f11a82b5a479a20fc148
|
7
|
+
data.tar.gz: 89f5a714181003a970cf70a114534075cd8fcbb8e96636ec62313d09ccba16d1790d81a798ebd725278a88b9768e7fb1507738e663404d6573de48eda03c6c4f
|
data/lib/chef/handler.rb
CHANGED
@@ -240,6 +240,8 @@ class Chef
|
|
240
240
|
# This ensures that all handlers get a chance to run even if one fails.
|
241
241
|
# This method should not be overridden by subclasses unless you know what
|
242
242
|
# you're doing.
|
243
|
+
#
|
244
|
+
# @api private
|
243
245
|
def run_report_safely(run_status)
|
244
246
|
run_report_unsafe(run_status)
|
245
247
|
rescue Exception => e
|
data/lib/chef/http.rb
CHANGED
@@ -58,7 +58,6 @@ class Chef
|
|
58
58
|
handler.handle_chunk(chunk)
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
61
|
end
|
63
62
|
|
64
63
|
def self.middlewares
|
@@ -155,7 +154,7 @@ class Chef
|
|
155
154
|
rescue Net::HTTPClientException => e
|
156
155
|
http_attempts += 1
|
157
156
|
response = e.response
|
158
|
-
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts
|
157
|
+
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts >= 0
|
159
158
|
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
160
159
|
retry
|
161
160
|
else
|
@@ -194,7 +193,7 @@ class Chef
|
|
194
193
|
rescue Net::HTTPClientException => e
|
195
194
|
http_attempts += 1
|
196
195
|
response = e.response
|
197
|
-
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts
|
196
|
+
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts >= 0
|
198
197
|
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
199
198
|
retry
|
200
199
|
else
|
@@ -250,7 +249,7 @@ class Chef
|
|
250
249
|
rescue Net::HTTPClientException => e
|
251
250
|
http_attempts += 1
|
252
251
|
response = e.response
|
253
|
-
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts
|
252
|
+
if response.is_a?(Net::HTTPNotAcceptable) && version_retries - http_attempts >= 0
|
254
253
|
Chef::Log.trace("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
255
254
|
retry
|
256
255
|
else
|
@@ -429,7 +428,7 @@ class Chef
|
|
429
428
|
response, request, return_value = yield
|
430
429
|
# handle HTTP 50X Error
|
431
430
|
if response.is_a?(Net::HTTPServerError) && !Chef::Config.local_mode
|
432
|
-
if http_retry_count - http_attempts
|
431
|
+
if http_retry_count - http_attempts >= 0
|
433
432
|
sleep_time = 1 + (2**http_attempts) + rand(2**http_attempts)
|
434
433
|
Chef::Log.error("Server returned error #{response.code} for #{url}, retrying #{http_attempts}/#{http_retry_count} in #{sleep_time}s")
|
435
434
|
sleep(sleep_time)
|
@@ -439,7 +438,7 @@ class Chef
|
|
439
438
|
return [response, request, return_value]
|
440
439
|
end
|
441
440
|
rescue SocketError, Errno::ETIMEDOUT, Errno::ECONNRESET => e
|
442
|
-
if http_retry_count - http_attempts
|
441
|
+
if http_retry_count - http_attempts >= 0
|
443
442
|
Chef::Log.error("Error connecting to #{url}, retry #{http_attempts}/#{http_retry_count}")
|
444
443
|
sleep(http_retry_delay)
|
445
444
|
retry
|
@@ -447,21 +446,21 @@ class Chef
|
|
447
446
|
e.message.replace "Error connecting to #{url} - #{e.message}"
|
448
447
|
raise e
|
449
448
|
rescue Errno::ECONNREFUSED
|
450
|
-
if http_retry_count - http_attempts
|
449
|
+
if http_retry_count - http_attempts >= 0
|
451
450
|
Chef::Log.error("Connection refused connecting to #{url}, retry #{http_attempts}/#{http_retry_count}")
|
452
451
|
sleep(http_retry_delay)
|
453
452
|
retry
|
454
453
|
end
|
455
454
|
raise Errno::ECONNREFUSED, "Connection refused connecting to #{url}, giving up"
|
456
455
|
rescue Timeout::Error
|
457
|
-
if http_retry_count - http_attempts
|
456
|
+
if http_retry_count - http_attempts >= 0
|
458
457
|
Chef::Log.error("Timeout connecting to #{url}, retry #{http_attempts}/#{http_retry_count}")
|
459
458
|
sleep(http_retry_delay)
|
460
459
|
retry
|
461
460
|
end
|
462
461
|
raise Timeout::Error, "Timeout connecting to #{url}, giving up"
|
463
462
|
rescue OpenSSL::SSL::SSLError => e
|
464
|
-
if (http_retry_count - http_attempts
|
463
|
+
if (http_retry_count - http_attempts >= 0) && !e.message.include?("certificate verify failed")
|
465
464
|
Chef::Log.error("SSL Error connecting to #{url}, retry #{http_attempts}/#{http_retry_count}")
|
466
465
|
sleep(http_retry_delay)
|
467
466
|
retry
|
@@ -471,7 +470,7 @@ class Chef
|
|
471
470
|
end
|
472
471
|
|
473
472
|
def version_retries
|
474
|
-
@version_retries ||= options[:version_class]
|
473
|
+
@version_retries ||= options[:version_class]&.possible_requests || 1
|
475
474
|
end
|
476
475
|
|
477
476
|
# @api private
|
@@ -87,8 +87,7 @@ class Chef
|
|
87
87
|
def updated_ec2_config_xml
|
88
88
|
begin
|
89
89
|
require "rexml/document" unless defined?(REXML::Document)
|
90
|
-
|
91
|
-
config = REXML::Document.new(::File.read(config_file))
|
90
|
+
config = REXML::Document.new(::File.read(WINDOWS_EC2_CONFIG))
|
92
91
|
# find an element named State with a sibling element whose value is Ec2SetComputerName
|
93
92
|
REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element|
|
94
93
|
element.text = "Disabled"
|
@@ -223,35 +222,36 @@ class Chef
|
|
223
222
|
end
|
224
223
|
|
225
224
|
else # windows
|
225
|
+
WINDOWS_EC2_CONFIG = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'.freeze
|
226
|
+
|
226
227
|
raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/\./)
|
227
228
|
|
228
229
|
# suppress EC2 config service from setting our hostname
|
229
|
-
if ::File.exist?(
|
230
|
+
if ::File.exist?(WINDOWS_EC2_CONFIG)
|
230
231
|
xml_contents = updated_ec2_config_xml
|
231
232
|
if xml_contents.empty?
|
232
233
|
Chef::Log.warn('Unable to properly parse and update C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml contents. Skipping file update.')
|
233
234
|
else
|
234
|
-
|
235
|
+
file WINDOWS_EC2_CONFIG do
|
235
236
|
content xml_contents
|
236
237
|
end
|
237
238
|
end
|
238
239
|
end
|
239
240
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
not_if { Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname }
|
248
|
-
end
|
241
|
+
unless Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname
|
242
|
+
converge_by "set hostname to #{new_resource.hostname}" do
|
243
|
+
powershell_out! <<~EOH
|
244
|
+
$sysInfo = Get-WmiObject -Class Win32_ComputerSystem
|
245
|
+
$sysInfo.Rename("#{new_resource.hostname}")
|
246
|
+
EOH
|
247
|
+
end
|
249
248
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
249
|
+
# reboot because $windows
|
250
|
+
reboot "setting hostname" do
|
251
|
+
reason "#{Chef::Dist::PRODUCT} updated system hostname"
|
252
|
+
only_if { new_resource.windows_reboot }
|
253
|
+
action :request_reboot
|
254
|
+
end
|
255
255
|
end
|
256
256
|
end
|
257
257
|
end
|
data/lib/chef/version.rb
CHANGED
@@ -53,8 +53,26 @@ describe Chef::HTTP::APIVersions do
|
|
53
53
|
m
|
54
54
|
end
|
55
55
|
|
56
|
+
let(:version_class) do
|
57
|
+
Class.new do
|
58
|
+
extend Chef::Mixin::VersionedAPIFactory
|
59
|
+
|
60
|
+
version_class_v0 = Class.new do
|
61
|
+
extend Chef::Mixin::VersionedAPI
|
62
|
+
minimum_api_version 0
|
63
|
+
end
|
64
|
+
add_versioned_api_class version_class_v0
|
65
|
+
|
66
|
+
version_class_v2 = Class.new do
|
67
|
+
extend Chef::Mixin::VersionedAPI
|
68
|
+
minimum_api_version 2
|
69
|
+
end
|
70
|
+
add_versioned_api_class version_class_v2
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
56
74
|
let(:client) do
|
57
|
-
TestVersionClient.new(url, { version_class:
|
75
|
+
TestVersionClient.new(url, { version_class: version_class })
|
58
76
|
end
|
59
77
|
|
60
78
|
let(:middleware) do
|
@@ -59,20 +59,22 @@ describe Chef::ServerAPI do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context "versioned apis" do
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
let(:version_class) do
|
63
|
+
Class.new do
|
64
|
+
extend Chef::Mixin::VersionedAPIFactory
|
65
|
+
|
66
|
+
version_class_v0 = Class.new do
|
67
|
+
extend Chef::Mixin::VersionedAPI
|
68
|
+
minimum_api_version 0
|
69
|
+
end
|
70
|
+
add_versioned_api_class version_class_v0
|
71
|
+
|
72
|
+
version_class_v2 = Class.new do
|
73
|
+
extend Chef::Mixin::VersionedAPI
|
74
|
+
minimum_api_version 2
|
75
|
+
end
|
76
|
+
add_versioned_api_class version_class_v2
|
77
|
+
end
|
76
78
|
end
|
77
79
|
|
78
80
|
before do
|
@@ -80,7 +82,7 @@ describe Chef::ServerAPI do
|
|
80
82
|
end
|
81
83
|
|
82
84
|
let(:versioned_client) do
|
83
|
-
Chef::ServerAPI.new(url, version_class:
|
85
|
+
Chef::ServerAPI.new(url, version_class: version_class)
|
84
86
|
end
|
85
87
|
|
86
88
|
it "on protocol negotiation it posts the same message body without doubly-encoding the json string" do
|
@@ -114,11 +116,36 @@ describe Chef::ServerAPI do
|
|
114
116
|
|
115
117
|
it "500 on a get retries and gets correctly " do
|
116
118
|
WebMock.disable_net_connect!
|
117
|
-
get_body = { bar: "baz" }
|
118
119
|
headers = { "Accept" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Host" => "chef.example.com:4000", "X-Chef-Version" => Chef::VERSION, "X-Ops-Sign" => "algorithm=sha1;version=1.1;", "X-Ops-Userid" => "silent-bob" }
|
119
120
|
stub_request(:get, "http://chef.example.com:4000/foo").with(headers: headers).to_return(status: [500, "Internal Server Error"])
|
120
121
|
stub_request(:get, "http://chef.example.com:4000/foo").with(headers: headers).to_return(status: 200, body: "", headers: {})
|
121
122
|
client.get("foo")
|
122
123
|
end
|
124
|
+
|
125
|
+
it "406 on a post does protocol negotiation" do
|
126
|
+
WebMock.disable_net_connect!
|
127
|
+
post_body = { bar: "baz" }
|
128
|
+
body_406 = '{"error":"invalid-x-ops-server-api-version","message":"Specified version 2 not supported","min_version":0,"max_version":1}'
|
129
|
+
stub_request(:post, "http://chef.example.com:4000/foo").with(body: post_body.to_json, headers: { "X-Ops-Server-Api-Version" => "2" }).to_return(status: [406, "Not Acceptable"], body: body_406 )
|
130
|
+
stub_request(:post, "http://chef.example.com:4000/foo").with(body: post_body.to_json, headers: { "X-Ops-Server-Api-Version" => "0" }).to_return(status: 200, body: "", headers: {})
|
131
|
+
client.post("foo", post_body)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "406 on a put does protocol negotiation" do
|
135
|
+
WebMock.disable_net_connect!
|
136
|
+
put_body = { bar: "baz" }
|
137
|
+
body_406 = '{"error":"invalid-x-ops-server-api-version","message":"Specified version 2 not supported","min_version":0,"max_version":1}'
|
138
|
+
stub_request(:put, "http://chef.example.com:4000/foo").with(body: put_body.to_json, headers: { "X-Ops-Server-Api-Version" => "2" }).to_return(status: [406, "Not Acceptable"], body: body_406 )
|
139
|
+
stub_request(:put, "http://chef.example.com:4000/foo").with(body: put_body.to_json, headers: { "X-Ops-Server-Api-Version" => "0" }).to_return(status: 200, body: "", headers: {})
|
140
|
+
client.put("foo", put_body)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "406 on a get does protocol negotiation" do
|
144
|
+
WebMock.disable_net_connect!
|
145
|
+
body_406 = '{"error":"invalid-x-ops-server-api-version","message":"Specified version 2 not supported","min_version":0,"max_version":1}'
|
146
|
+
stub_request(:get, "http://chef.example.com:4000/foo").with(headers: { "X-Ops-Server-Api-Version" => "2" }).to_return(status: [406, "Not Acceptable"], body: body_406 )
|
147
|
+
stub_request(:get, "http://chef.example.com:4000/foo").with(headers: { "X-Ops-Server-Api-Version" => "0" }).to_return(status: 200, body: "", headers: {})
|
148
|
+
client.get("foo")
|
149
|
+
end
|
123
150
|
end
|
124
151
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.3.
|
4
|
+
version: 16.3.45
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 16.3.
|
19
|
+
version: 16.3.45
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 16.3.
|
26
|
+
version: 16.3.45
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chef-utils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 16.3.
|
33
|
+
version: 16.3.45
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 16.3.
|
40
|
+
version: 16.3.45
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: train-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|