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

Details 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 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

@dgrisonnet
Copy link
Member

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 12, 2025
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ktesting: -vmodule not working

4 participants