client: report caller line for OpenStack debug logs#3108
client: report caller line for OpenStack debug logs#3108SAY-5 wants to merge 1 commit intokubernetes:masterfrom
Conversation
The Logger.Printf wrapper used a hard-coded stack-frame window [10..20] and matched only /github.com/gophercloud/gophercloud, which fails to span gophercloud/utils where the RoundTripper now lives. With modern net/http the real caller is outside that window, so klog falls back to the wrapper's own line and every debug entry is shown as client.go:128. Walk the full stack and pick the frame above the deepest gophercloud frame (matching both gophercloud/gophercloud and gophercloud/utils) so klog attributes the log to the originating call site. Fixes kubernetes#2300 Signed-off-by: SAY-5 <say.apm35@gmail.com>
|
Invalid commit message issues detected Invalid commit messagesKeywords which can automatically close issues and hashtag(#) mentions are not allowed.
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. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @SAY-5. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
What this PR does / why we need it:
The OpenStack API debugger logs every line as
client.go:128regardless of the caller. The wrapper walks the stack with a hard-coded window[10..20]and a substring of/github.com/gophercloud/gophercloud, which no longer spansgophercloud/utils(where the RoundTripper now lives) and fails to reach the real caller through modern net/http frames, soskipstays at 0 andklog.InfoDepthreports its own line.This walks the whole stack and picks the frame above the deepest
/github.com/gophercloud/frame so klog attributes the entry to the originating call site (e.g.openstack_volumes.go:82).Which issue this PR fixes(if applicable):
fixes #2300
Special notes for reviewers:
The added test reproduces the bug: it captures klog output via
SetOutputwhile issuing a request through the wrapper and asserts the source location is the test file, notclient.go. The test fails on master and passes with this change.Release note: