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

test/integration: goroutine leak check #115456

Merged
merged 1 commit into from Feb 14, 2023

Commits on Feb 14, 2023

  1. test: use go-uber/goleak for strict leak checking

    It provides more readable output and has additional APIs for using it inside a
    unit test. goleak.IgnoreCurrent is needed to filter out the goroutine that gets
    started when importing go.opencensus.io/stats/view.
    
    In order to handle background goroutines that get created on demand and cannot
    be stopped (like the one for LogzHealth), a helper function ensures that those
    are running before calling goleak.IgnoreCurrent. Keeping those goroutines
    running is not a problem and thus not worth the effort of adding new APIs to
    stop them.
    
    Other goroutines are genuine leaks for which no fix is available. Those get
    suppressed via IgnoreTopFunction, which works as long as that function
    is unique enough.
    
    Example output for the leak fixed in kubernetes#115423:
    
        E0202 09:30:51.641841   74789 etcd.go:205] "EtcdMain goroutine check" err=<
            found unexpected goroutines:
            [Goroutine 4889 in state chan receive, with k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop on top of the stack:
            goroutine 4889 [chan receive]:
            k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop(0xc0076183c0)
            	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:268 +0x65
            created by k8s.io/apimachinery/pkg/watch.NewBroadcaster
            	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:77 +0x116
        >
    pohly committed Feb 14, 2023
    Configuration menu
    Copy the full SHA
    f131cab View commit details
    Browse the repository at this point in the history