-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Add charset=utf-8 to Content-Type header for pod logs endpoint #135293
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
base: master
Are you sure you want to change the base?
Conversation
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
3e74d2f to
e9a471a
Compare
|
Since this is a bug, we should have a release note. |
Updated, thanks. |
pkg/registry/core/pod/rest/log.go
Outdated
| // the "produces" section for pods/{name}/log | ||
| return []string{ | ||
| "text/plain", | ||
| "text/plain; charset=utf-8", |
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 bit of an edgecase, but pod logs can produce output that is not encoded in utf-8, so we need to be careful with our assumptions.
In the OpenShift GUI we used a library to guess the most likely encoding: openshift/console#15436. Maybe we need something like that here?
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.
@logonoff good point, let's think about this more.
/hold
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.
@logonoff What do you think about this approach? https://github.com/kubernetes/kubernetes/compare/master...harche:fix-pod-logs-content-type-charset-1?expand=1
Instead of unconditionally setting charset=utf-8, the this approach checks what kubelet sends back and only adds charset=utf-8 if it's missing from the Content-Type header. If kubelet sends something like text/plain; charset=latin-1 or application/octet-stream, we preserve it as is. This way we fix the common UTF-8 case without making assumptions about edge cases.
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 makes more sense to me!
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 @logonoff
/hold cancel
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 have updated this PR with those changes.
Signed-off-by: Harshal Patil <[email protected]>
e9a471a to
0652eea
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: harche The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Add charset=utf-8 to Content-Type header for pod logs endpoint
Which issue(s) this PR is related to:
Fixes : #135292
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: