Skip to content

Commit 7d0cc29

Browse files
(PUP-11900) Notify when X-Puppet-Compiler-Name header found
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.
1 parent 03b3df3 commit 7d0cc29

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/puppet/http/service/compiler.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def post_catalog(name, facts:, environment:, configured_environment: nil, check_
120120
params: { environment: environment },
121121
)
122122

123+
if (compiler = response['X-Puppet-Compiler-Name'])
124+
Puppet.notice("Catalog compiled by #{compiler}")
125+
end
126+
123127
process_response(response)
124128

125129
[response, deserialize(response, Puppet::Resource::Catalog)]

spec/integration/application/agent_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ def copy_fixtures(sources, dest)
3333
end
3434
end
3535

36+
context 'server identification' do
37+
it 'emits a notice if the server sends the X-Puppet-Compiler-Name header' do
38+
server.start_server do |port|
39+
Puppet[:serverport] = port
40+
expect {
41+
agent.command_line.args << '--test'
42+
agent.run
43+
}.to exit_with(0)
44+
.and output(%r{Notice: Catalog compiled by test-compiler-hostname}).to_stdout
45+
end
46+
end
47+
end
48+
3649
context 'server_list' do
3750
it "uses the first server in the list" do
3851
Puppet[:server_list] = '127.0.0.1'

spec/lib/puppet_spec/puppetserver.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def do_GET request, response
1919
class CatalogServlet < WEBrick::HTTPServlet::AbstractServlet
2020
def do_POST request, response
2121
response['Content-Type'] = 'application/json'
22+
response['X-Puppet-Compiler-Name'] = 'test-compiler-hostname'
2223
catalog = Puppet::Resource::Catalog.new(Puppet[:certname], 'production')
2324
response.body = catalog.render(:json)
2425
end

0 commit comments

Comments
 (0)