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
Fix leaking goroutines in multiple integration tests #110362
Conversation
[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 |
|
} else { | ||
klog.Infof("No api server defined - no events will be sent to API server.") | ||
} | ||
defer dc.broadcaster.Shutdown() |
There was a problem hiding this comment.
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" ?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
// Send events to the apiserver | ||
eventBroadcaster := record.NewBroadcaster() | ||
eventBroadcaster.StartStructuredLogging(0) | ||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
looks like need to |
6ba56e2
to
006ff45
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
/lgtm |
/triage accepted |
Ref #108483
Note to reviewer: I recommend reviewing commits one by one - they are all independent.
/kind cleanup
/priority important-longterm
/sig testing