Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@harche
Copy link
Contributor

@harche harche commented Nov 13, 2025

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?

Fixed pod logs Content-Type header to properly display UTF-8 characters

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 13, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 13, 2025
@harche harche force-pushed the fix-pod-logs-content-type-charset branch from 3e74d2f to e9a471a Compare November 13, 2025 20:16
@kannon92
Copy link
Contributor

Since this is a bug, we should have a release note.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 13, 2025
@harche
Copy link
Contributor Author

harche commented Nov 13, 2025

Since this is a bug, we should have a release note.

Updated, thanks.

// the "produces" section for pods/{name}/log
return []string{
"text/plain",
"text/plain; charset=utf-8",
Copy link

@logonoff logonoff Nov 13, 2025

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @logonoff

/hold cancel

Copy link
Contributor Author

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.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 13, 2025
@harche harche force-pushed the fix-pod-logs-content-type-charset branch from e9a471a to 0652eea Compare November 14, 2025 03:01
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: harche
Once this PR has been reviewed and has the lgtm label, please assign deads2k, tallclair for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Development

Successfully merging this pull request may close these issues.

Pod logs does not send correct Content-Type

4 participants