Skip to content

Conversation

@lxuan94-pp
Copy link

@lxuan94-pp lxuan94-pp commented Oct 8, 2025

What this PR does / why we need it:
This PR fixes an issue introduced in kubernetes/autoscaler#7842
where the Cluster Autoscaler --log-file argument stopped working. After the referenced commit, if the logger is not nil, klog.go bypasses the log file creation logic, so no log file is created. This PR modifies klog.go to ensure that the log file is always written when configured, regardless of the logger state.
Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes kubernetes/autoscaler#7842

Special notes for your reviewer:
This has been tested and used in production of OCI provider clusters
Screenshot 2025-10-08 at 4 32 37 PM
Screenshot 2025-10-08 at 4 34 14 PM

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Cluster Autoscaler now respects the --log-file argument again and will always write logs to the configured file.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 8, 2025
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lxuan94-pp
Once this PR has been reviewed and has the lgtm label, please assign dims 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 requested a review from pohly October 8, 2025 20:23
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 8, 2025
@k8s-ci-robot
Copy link

This issue is currently awaiting triage.

If klog contributors determine 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
Copy link

Welcome @lxuan94-pp!

It looks like this is your first PR to kubernetes/klog 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/klog has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 8, 2025
@pohly
Copy link

pohly commented Oct 9, 2025

Why did this stop working? You justify this change by saying that it fixes autoscaler, but this repo isn't autoscaler - it's klog.

This needs to be explained as either a bug (used to work, no longer does) or as an improvement.

Either way this could be a problematic change because other users of klog might depend on the current behavior. I haven't looked into this because I expect the description of the PR to explain this too me and other potentially affected users of klog.

@lxuan94-pp
Copy link
Author

@pohly Thanks for the comment.
After this commit
, klog was integrated with the structured logging setup from component-base, where a global logr-based logger is always initialized. As a result, logger is no longer nil, and all logs go through the structured logging path, bypassing klog’s native file handling.

This introduced a regression, even when --log-file is specified, no file is actually created. From a user’s perspective, if a log file is explicitly specified, shouldn’t it always be written to? My understanding here may be limited, so I’d appreciate your insight.

@pohly
Copy link

pohly commented Oct 9, 2025

As you pointed out, that change was in component-base, not in klog. component-base does not have the same strict "no changes" rule as klog, so users of it (like apparently autoscaler) occasionally have to adapt. Instead of modifying klog, it sounds to me like it is the autoscaler which needs to be updated.

@lxuan94-pp
Copy link
Author

@pohly Thanks for the insights, I will dig further and get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster autoscaler argument --log-file is no longer working after v1.30.x

3 participants