Skip to content

Commit 7f41466

Browse files
(maint) Merge up 19c3f93 to main
Generated by CI * commit '19c3f936f5656ca5ea7166f15cc9d906e331f95d': (PUP-11899) Log which server we request a catalog from
2 parents 945beb6 + 19c3f93 commit 7f41466

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/puppet/indirector/catalog/rest.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ def find(request)
1414

1515
session = Puppet.lookup(:http_session)
1616
api = session.route_to(:puppet)
17+
18+
ip_address = begin
19+
" (#{Resolv.getaddress(api.url.host)})"
20+
rescue Resolv::ResolvError
21+
nil
22+
end
23+
Puppet.notice("Requesting catalog from #{api.url.host}:#{api.url.port}#{ip_address}")
24+
1725
_, catalog = api.post_catalog(
1826
request.key,
1927
facts: request.options[:facts_for_catalog],

spec/unit/indirector/catalog/rest_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ def catalog_response(catalog)
2525
expect(described_class.indirection.find(certname)).to be_a(Puppet::Resource::Catalog)
2626
end
2727

28+
it 'logs a notice when requesting a catalog' do
29+
expect(Puppet).to receive(:notice).with("Requesting catalog from compiler.example.com:8140")
30+
31+
stub_request(:post, uri).to_return(**catalog_response(catalog))
32+
33+
described_class.indirection.find(certname)
34+
end
35+
36+
it 'logs a notice when the IP address is resolvable when requesting a catalog' do
37+
allow(Resolv).to receive_message_chain(:getaddress).and_return('192.0.2.0')
38+
expect(Puppet).to receive(:notice).with("Requesting catalog from compiler.example.com:8140 (192.0.2.0)")
39+
40+
stub_request(:post, uri).to_return(**catalog_response(catalog))
41+
42+
described_class.indirection.find(certname)
43+
end
44+
2845
it "serializes the environment" do
2946
stub_request(:post, uri)
3047
.with(query: hash_including('environment' => 'outerspace'))

0 commit comments

Comments
 (0)