Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PUP-11899) Log which server we request a catalog from #9126

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/puppet/indirector/catalog/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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
mhashizume marked this conversation as resolved.
Show resolved Hide resolved
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