Skip to content

Commit

Permalink
(maint) Merge up 19c3f93 to main
Browse files Browse the repository at this point in the history
Generated by CI

* commit '19c3f936f5656ca5ea7166f15cc9d906e331f95d':
  (PUP-11899) Log which server we request a catalog from
  • Loading branch information
puppetlabs-jenkins committed Oct 25, 2023
2 parents 945beb6 + 19c3f93 commit 7f41466
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/puppet/indirector/catalog/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def find(request)

session = Puppet.lookup(:http_session)
api = session.route_to(:puppet)

ip_address = begin
" (#{Resolv.getaddress(api.url.host)})"
rescue Resolv::ResolvError
nil
end
Puppet.notice("Requesting catalog from #{api.url.host}:#{api.url.port}#{ip_address}")

_, catalog = api.post_catalog(
request.key,
facts: request.options[:facts_for_catalog],
Expand Down
17 changes: 17 additions & 0 deletions spec/unit/indirector/catalog/rest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ def catalog_response(catalog)
expect(described_class.indirection.find(certname)).to be_a(Puppet::Resource::Catalog)
end

it 'logs a notice when requesting a catalog' do
expect(Puppet).to receive(:notice).with("Requesting catalog from compiler.example.com:8140")

stub_request(:post, uri).to_return(**catalog_response(catalog))

described_class.indirection.find(certname)
end

it 'logs a notice when the IP address is resolvable when requesting a catalog' do
allow(Resolv).to receive_message_chain(:getaddress).and_return('192.0.2.0')
expect(Puppet).to receive(:notice).with("Requesting catalog from compiler.example.com:8140 (192.0.2.0)")

stub_request(:post, uri).to_return(**catalog_response(catalog))

described_class.indirection.find(certname)
end

it "serializes the environment" do
stub_request(:post, uri)
.with(query: hash_including('environment' => 'outerspace'))
Expand Down

0 comments on commit 7f41466

Please sign in to comment.