Skip to content

Commit

Permalink
Merge pull request #9151 from tvpartytonight/PUP-11900
Browse files Browse the repository at this point in the history
(PUP-11900) Notify when `X-Puppet-Compiler-Name` header found
  • Loading branch information
tvpartytonight committed Nov 14, 2023
2 parents 03b3df3 + 7d0cc29 commit 60ff477
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/puppet/http/service/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def post_catalog(name, facts:, environment:, configured_environment: nil, check_
params: { environment: environment },
)

if (compiler = response['X-Puppet-Compiler-Name'])
Puppet.notice("Catalog compiled by #{compiler}")
end

process_response(response)

[response, deserialize(response, Puppet::Resource::Catalog)]
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 60ff477

Please sign in to comment.