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

Fix leaking goroutines in multiple integration tests #110362

Merged
merged 6 commits into from Jun 7, 2022

Conversation

wojtek-t
Copy link
Member

@wojtek-t wojtek-t commented Jun 2, 2022

Ref #108483

Note to reviewer: I recommend reviewing commits one by one - they are all independent.

NONE

/kind cleanup
/priority important-longterm
/sig testing

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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. labels Jun 2, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wojtek-t

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 k8s-ci-robot requested review from aojea and kow3ns June 2, 2022 19:07
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. labels Jun 2, 2022
@aojea
Copy link
Member

aojea commented Jun 2, 2022



1/43 Tests Failed. | expand_less
-- | --
verify: gofmt expand_less6s{Script Error ScriptError diff -u ./test/integration/network/services_test.go.orig ./test/integration/network/services_test.go --- ./test/integration/network/services_test.go.orig	2022-06-02 19:27:57.762267425 +0000 +++ ./test/integration/network/services_test.go	2022-06-02 19:27:57.762267425 +0000 @@ -48,7 +48,6 @@  		ModifyServerConfig: func(cfg *controlplane.Config) {  			cfg.ExtraConfig.RepairServicesInterval = interval  		}, -  	})  	defer tearDownFn()    Run ./hack/update-gofmt.sh} | verify: gofmt expand_less | 6s | {Script Error ScriptError diff -u ./test/integration/network/services_test.go.orig ./test/integration/network/services_test.go --- ./test/integration/network/services_test.go.orig	2022-06-02 19:27:57.762267425 +0000 +++ ./test/integration/network/services_test.go	2022-06-02 19:27:57.762267425 +0000 @@ -48,7 +48,6 @@  		ModifyServerConfig: func(cfg *controlplane.Config) {  			cfg.ExtraConfig.RepairServicesInterval = interval  		}, -  	})  	defer tearDownFn()    Run ./hack/update-gofmt.sh}
verify: gofmt expand_less | 6s
{Script Error ScriptError diff -u ./test/integration/network/services_test.go.orig ./test/integration/network/services_test.go --- ./test/integration/network/services_test.go.orig	2022-06-02 19:27:57.762267425 +0000 +++ ./test/integration/network/services_test.go	2022-06-02 19:27:57.762267425 +0000 @@ -48,7 +48,6 @@  		ModifyServerConfig: func(cfg *controlplane.Config) {  			cfg.ExtraConfig.RepairServicesInterval = interval  		}, -  	})  	defer tearDownFn()    Run ./hack/update-gofmt.sh}


} else {
klog.Infof("No api server defined - no events will be sent to API server.")
}
defer dc.broadcaster.Shutdown()
Copy link
Member

Choose a reason for hiding this comment

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

do you defer dc.broadcaster.Shutdown() always or only if it "startedRecordingToSink" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

we defer it always (it's unrelated to whether we record to sink or not)

@@ -498,9 +502,15 @@ func waitToObservePods(t *testing.T, podInformer cache.SharedIndexInformer, podN
}

func TestPatchCompatibility(t *testing.T) {
s, _, _, clientSet, _, _ := setup(t)
s, pdbc, _, clientSet, _, _ := setup(t)
Copy link
Member

Choose a reason for hiding this comment

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

don't you need to start the informers too?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't - just creating informers doesn't start any goroutines - so we don't need to touch them

Comment on lines -63 to -66
// Send events to the apiserver
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartStructuredLogging(0)
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

This just wasn't used anywhere :D

s := kubeapiservertesting.StartTestServerOrDie(t, nil, nil, framework.SharedEtcd())
t.Cleanup(s.TearDownFn)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
t.Cleanup(cancel)
Copy link
Member

Choose a reason for hiding this comment

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

so many t.Cleanup() functions is not complex to follow?

Copy link
Member Author

Choose a reason for hiding this comment

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

somewhat - I was just trying to do minimal changes...

@dims
Copy link
Member

dims commented Jun 3, 2022

looks like need to Run ./hack/update-gofmt.sh @wojtek-t

@enj enj added this to Needs Triage in SIG Auth Old Jun 6, 2022
Copy link
Member Author

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

@aojea - thanks for comments - PTAL

s := kubeapiservertesting.StartTestServerOrDie(t, nil, nil, framework.SharedEtcd())
t.Cleanup(s.TearDownFn)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
t.Cleanup(cancel)
Copy link
Member Author

Choose a reason for hiding this comment

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

somewhat - I was just trying to do minimal changes...

@@ -498,9 +502,15 @@ func waitToObservePods(t *testing.T, podInformer cache.SharedIndexInformer, podN
}

func TestPatchCompatibility(t *testing.T) {
s, _, _, clientSet, _, _ := setup(t)
s, pdbc, _, clientSet, _, _ := setup(t)
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't - just creating informers doesn't start any goroutines - so we don't need to touch them

@aojea
Copy link
Member

aojea commented Jun 7, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 7, 2022
@k8s-ci-robot k8s-ci-robot merged commit 39b6e6c into kubernetes:master Jun 7, 2022
SIG Auth Old automation moved this from Needs Triage to Closed / Done Jun 7, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Jun 7, 2022
@fedebongio
Copy link
Contributor

/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 Jun 7, 2022
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
SIG Auth Old
Closed / Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants