Skip to content

Commit

Permalink
(PUP-11900) Notify when X-Puppet-Compiler-Name header found
Browse files Browse the repository at this point in the history
This change will emit a notice when http traffic from a puppetserver
sends the `X-Puppet-Compiler-Name` header; this should help for
debugging purposes when troubleshooting compilation issues and
several compilers are behind a load balancer.
  • Loading branch information
tvpartytonight committed Nov 14, 2023
1 parent 03b3df3 commit e255644
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/puppet/http/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def process_response(response)
site = Puppet::HTTP::Site.from_uri(response.url)
@server_versions[site] = version
end
if compiler = response['X-Puppet-Compiler-Name']
Puppet.notice("Catalog compiled by #{compiler}")
end
end

# Determine if a session supports a capability. Depending on the server version
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/application/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def copy_fixtures(sources, dest)
end
end

context 'server identification' do
it 'emits a notice if the server sends the X-Puppet-Compiler-Name header' do
server.start_server do |port|
Puppet[:serverport] = port
expect {
agent.command_line.args << '--test'
agent.run
}.to exit_with(0)
.and output(%r{Notice: Catalog compiled by test-compiler-hostname}).to_stdout
end
end
end

context 'server_list' do
it "uses the first server in the list" do
Puppet[:server_list] = '127.0.0.1'
Expand Down
1 change: 1 addition & 0 deletions spec/lib/puppet_spec/puppetserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def do_GET request, response
class CatalogServlet < WEBrick::HTTPServlet::AbstractServlet
def do_POST request, response
response['Content-Type'] = 'application/json'
response['X-Puppet-Compiler-Name'] = 'test-compiler-hostname'
catalog = Puppet::Resource::Catalog.new(Puppet[:certname], 'production')
response.body = catalog.render(:json)
end
Expand Down

0 comments on commit e255644

Please sign in to comment.