-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fix Audit-ID header key #48492
Fix Audit-ID header key #48492
Conversation
Hi @CaoShuFeng. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Before this change the following Audit-ID will not work: |
|
||
// golang canonicalizes the header name when adding values to the header map | ||
// see https://golang.org/src/net/http/request.go#L150 for reference | ||
ids = append(ids, req.Header[http.CanonicalHeaderKey(auditinternal.HeaderAuditID)]...) |
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.
ouch, I hate magic. Great finding!
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.
Can you link with a commit sha1? The referenced line will be invalid soon otherwise.
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.
I wonder, shouldn't we switch auditinternal.HeaderAuditID
to the canonical form?
7894ade
to
9a63af2
Compare
Done. |
/ok-to-test |
/test pull-kubernetes-e2e-gce-etcd3 |
I think a better approach would be to change the usage: ids := req.Header[auditinternal.HeaderAuditID] to ids := req.Header.Get(auditinternal.HeaderAuditID) I think this is more idiomatic, and makes the constant definition independent of the internal go implementation. |
Now http header key "Audit-ID" doesn't have effect, because golang automaticly transforms "Audit-ID" into "Audit-Id". This change use http.Header.Get() function to canonicalize "Audit-ID" to "Audit-Id".
9a63af2
to
f21bc7b
Compare
@timstclair |
/approve no-issue |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CaoShuFeng, sttts Associated issue requirement bypassed by: sttts The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test pull-kubernetes-unit |
Automatic merge from submit-queue |
I wrote a test for this pr: |
This change add a test for: kubernetes#48492
Automatic merge from submit-queue (batch tested with PRs 47948, 48631, 48693, 48549, 47593) add a regression test for Audit-ID http header This change add a test for: #48492 **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ``` NONE ```
This change add a test for: kubernetes/kubernetes#48492 Kubernetes-commit: a5df09ba89f4c010eed76ffd985895aa80de9845
This change add a test for: kubernetes/kubernetes#48492 Kubernetes-commit: a5df09ba89f4c010eed76ffd985895aa80de9845
Now http header key "Audit-ID" doesn't have effect, because golang
automaticly transforms "Audit-ID" into "Audit-Id". This change use
http.Header.Get() function to canonicalize "Audit-ID" to "Audit-Id".
Release note: