Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consolidate_go_stacktrace.py: Add support for replacing Cilium source directory inline #21518

Merged

Conversation

joestringer
Copy link
Member

@joestringer joestringer commented Sep 30, 2022

Add an option to allow the user to specify a cilium source directory,
and substitute all stack traces to Cilium paths with this path.

This way, when using an IDE that allows Ctrl+click navigation in order
to browse to the location, it is easier to just run this script with the
extra dir from the cilium source directory and directly click on the
paths into the codebase for easy stack trace browsing:

$ contrib/scripts/consolidate_go_stacktrace.py stacktrace.txt -s . | head -n 20
114 unique stack traces
18 occurences. Sample stack trace:
sync.runtime_SemacquireMutex(0x30?, 0x0?, 0xc0033a3620?)
        /usr/local/go/src/runtime/sema.go:77 +0x25
sync.(*RWMutex).RLock(...)
        /usr/local/go/src/sync/rwmutex.go:71
github.com/cilium/cilium/pkg/endpoint.(*Endpoint).unconditionalRLock(...)
        ./pkg/endpoint/lock.go:53
github.com/cilium/cilium/pkg/endpoint.(*Endpoint).HasLabels(0xc000ee2000?, 0x2807b69?)
        ./pkg/endpoint/endpoint.go:1028 +0x59
github.com/cilium/cilium/daemon/cmd.(*Daemon).getEndpointList.func1(0xc0006f9e60?, 0xc0030ff590?, 0xc0030ff5a0?)
        ./daemon/cmd/endpoint.go:96 +0x71
created by github.com/cilium/cilium/daemon/cmd.(*Daemon).getEndpointList
        ./daemon/cmd/endpoint.go:94 +0x16f
...

This is a nice shorthand instead of having to pass the output to sed something like this:

$ consolidate_go_stacktrace.py /path/to/my/stacktrace | sed 's;/go/src/github.com/cilium/cilium;/my/custom/path;g`

The first couple of commits are just tidying up to allow the above in
the third commit.

Use autopep8 to format this code to opinionated Python format.

Signed-off-by: Joe Stringer <joe@cilium.io>
Use the standard argparse library to accept arguments to the script.

Signed-off-by: Joe Stringer <joe@cilium.io>
Add an option to allow the user to specify a cilium source directory,
and substitute all stack traces to Cilium paths with this path.

This way, when using an IDE that allows Ctrl+click navigation in order
to browse to the location, it is easier to just run this script with the
extra dir from the cilium source directory and directly click on the
paths into the codebase for easy stack trace browsing:

    $ contrib/scripts/consolidate_go_stacktrace.py foo -s $PWD
    ...

Signed-off-by: Joe Stringer <joe@cilium.io>
@joestringer joestringer requested a review from a team as a code owner September 30, 2022 01:57
@joestringer joestringer added the release-note/misc This PR makes changes that have no direct user impact. label Sep 30, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Sep 30, 2022
Copy link
Member

@aditighag aditighag left a comment

Choose a reason for hiding this comment

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

Looks handy! Left a couple of comments.

contrib/scripts/consolidate_go_stacktrace.py Show resolved Hide resolved
contrib/scripts/consolidate_go_stacktrace.py Show resolved Hide resolved
@joestringer
Copy link
Member Author

I have another idea, autoreplace the go paths with $GOROOT 😈 ... I'll send a separate PR for that.

@aditighag aditighag added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Sep 30, 2022
@joestringer joestringer merged commit 1994f53 into cilium:master Oct 3, 2022
@joestringer joestringer deleted the submit/consolidate-stacktrace-opts branch October 3, 2022 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants