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 #9151

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

tvpartytonight
Copy link
Contributor

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.

@tvpartytonight tvpartytonight requested a review from a team as a code owner November 14, 2023 00:38
@@ -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
Copy link
Contributor

@joshcooper joshcooper Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we'd only emit this in notice the post_catalog method, otherwise, we could end up emitting this notice for requests unrelated to catalogs

response = @client.post(
with_base_url("/catalog/#{name}"),
body,
headers: headers,
# for legacy reasons we always send environment as a query parameter too
params: { environment: environment },
)
process_response(response)

And possibly the post_catalog4 method if it makes sense to do so?

def post_catalog4(certname, persistence:, environment:, facts: nil, trusted_facts: nil, transaction_uuid: nil, job_id: nil, options: nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in puppetserver only affects the v3 endpoint, so the v4 POST is not necessary yet. It makes sense to me that we would just emit the notice anytime we received the header, so any endpoint the agent uses that the puppetserver deems necessary to include that header would "just work". For example, if we did start using the v4 catalog endpoint for agent runs we would just have to make changes on the server side and not the agent.

Is it possible that someone adds that header in a response that is not the puppetserver? It seems the same level of vulnerability as the X-Puppet-Version header. I'm not sure if process_response is used for non-puppetserver requests...

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.
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, lgtm

@tvpartytonight tvpartytonight merged commit 60ff477 into puppetlabs:main Nov 14, 2023
9 checks passed
@joshcooper
Copy link
Contributor

Could you backport to 7.x too?

@joshcooper joshcooper added the enhancement New feature or request label Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants