Skip to content

Conversation

@pohly
Copy link

@pohly pohly commented Dec 1, 2025

What this PR does / why we need it:

Stack unwinding to determine the caller must consider the number of call levels to skip over in logr itself. This only affected the Enabled check and thus usage of the vmodule parameter, the actual caller then gets printed by testing.T.

This also leads to a small inconsistency: the enabled check is unaware of the testing.T.Helper calls and can only check the direct caller, without skipping helpers, while the actual log output then skips the helper. There's no good fix for this, testing.T would need an API for delegating the stack unwinding to the caller (would also be useful to log a PC supplied via slog...).

Which issue(s) this PR fixes:

Fixes #420

Special notes for your reviewer:

One line change, multi-line unit test...

Release note:

ktesting: -testing.vmodule was off by one in the call stack when checking whether log ouput should be printed.

Stack unwinding to determine the caller must consider the number of call levels
to skip over in logr itself. This only affected the `Enabled` check and thus
usage of the vmodule parameter, the actual caller then gets printed by
testing.T.

This also leads to a small inconsistency: the enabled check is unaware of the
testing.T.Helper calls and can only check the direct caller, without skipping
helpers, while the actual log output then skips the helper. There's no good fix
for this, testing.T would need an API for delegating the stack unwinding to the
caller (would also be useful to log a PC supplied via slog...).
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pohly

The full list of commands accepted by this bot can be found here.

The pull request process is described 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
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 k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 1, 2025
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 1, 2025
@pohly
Copy link
Author

pohly commented Dec 1, 2025

/assign @harshanarayana

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

ktesting: -vmodule not working

3 participants