-
Notifications
You must be signed in to change notification settings - Fork 25
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
[VC-36032] Set User-Agent header containing the agent version in all HTTP requests #631
Conversation
… with private key authentication Signed-off-by: Richard Wall <[email protected]>
This will make it easier to diagnose problems by allowing platform teams to parse HTTP server logs or intermediate HTTP proxy logs and know which version of the agent has made the request. Signed-off-by: Richard Wall <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@@ -265,13 +266,14 @@ func (c *VenafiCloudClient) Post(ctx context.Context, path string, body io.Reade | |||
return nil, err | |||
} | |||
|
|||
req, err := http.NewRequest(http.MethodPost, fullURL(c.baseURL, path), body) | |||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, fullURL(c.baseURL, path), body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a drive-by fix. I missed this in #627
@@ -178,7 +178,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) { | |||
|
|||
// The log line printed by pflag is not captured by the log recorder. | |||
assert.Equal(t, testutil.Undent(` | |||
INFO Using the Jetstack Secure OAuth auth mode since --credentials-file was specified without --venafi-cloud. | |||
INFO Authentication mode mode="Jetstack Secure OAuth" reason="--credentials-file was specified without --venafi-cloud" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are not being run on the master branch and the green badge on the README file does not reflect the status of the current branch:
- https://github.com/jetstack/jetstack-secure/actions/workflows/tests.yaml?query=branch%3Amaster
- https://github.com/jetstack/jetstack-secure/blob/master/README.md
Opened an issue about that: #632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, I wish we had done it sooner. I've realized the importance of the user agent header when responding to last weeks venctl/agent outage.
I haven't tested the PR, but I'm very confident that nothing will break. Nothing in the PR could break anything, I'd say.
In VC-36032 we aim to provide:
By adding user-agent headers to all HTTP requests, it will allow the Venafi platform team to know which version of the agent is making requests to the resource and auth APIs, by analysing the request headers among the server logs.
I tried writing tests for this, but the it would have required some significant refactoring of the client code,
for example there's no easy way to intercept the Auth0 client request made by the Jetstack-Secure client in client_oauth.go.
That's a bit of a lame excuse, but I would like to propose that we refactor the Venafi client code in a followup PR and at the same time add tests which verify that all the flavours of Venafi client do include user agent headers.