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-11900) Notify when X-Puppet-Compiler-Name header found #9155

Merged
merged 1 commit into from
Nov 15, 2023
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
4 changes: 4 additions & 0 deletions lib/puppet/http/service/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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 @@ -15,6 +15,19 @@
let(:node) { Puppet::Node.new(Puppet[:certname], environment: 'production')}
let(:formatter) { Puppet::Network::FormatHandler.format(:rich_data_json) }

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