close channel to prevent memory leak

- wait.JitterUntil goroutine is never cleaned up when used with wait.NeverStop - fixup comment
parent c0579af6
...@@ -126,7 +126,7 @@ func (rc *reconciler) reconciliationLoopFunc() func() { ...@@ -126,7 +126,7 @@ func (rc *reconciler) reconciliationLoopFunc() func() {
err) err)
} }
} else { } else {
// If volume is not safe to detach (is mounted) wait a max amount of time before detaching any way. // If volume is not safe to detach (is mounted) wait a max amount of time before detaching anyway.
if timeElapsed > rc.maxWaitForUnmountDuration { if timeElapsed > rc.maxWaitForUnmountDuration {
glog.V(5).Infof("Attempting to start DetachVolume for volume %q from node %q. Volume is not safe to detach, but maxWaitForUnmountDuration expired.", attachedVolume.VolumeName, attachedVolume.NodeName) glog.V(5).Infof("Attempting to start DetachVolume for volume %q from node %q. Volume is not safe to detach, but maxWaitForUnmountDuration expired.", attachedVolume.VolumeName, attachedVolume.NodeName)
err := rc.attacherDetacher.DetachVolume(attachedVolume.AttachedVolume, false /* verifySafeToDetach */, rc.actualStateOfWorld) err := rc.attacherDetacher.DetachVolume(attachedVolume.AttachedVolume, false /* verifySafeToDetach */, rc.actualStateOfWorld)
......
...@@ -55,7 +55,9 @@ func Test_Run_Positive_DoNothing(t *testing.T) { ...@@ -55,7 +55,9 @@ func Test_Run_Positive_DoNothing(t *testing.T) {
reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad, nsu) reconcilerLoopPeriod, maxWaitForUnmountDuration, dsw, asw, ad, nsu)
// Act // Act
go reconciler.Run(wait.NeverStop) ch := make(chan struct{})
go reconciler.Run(ch)
defer close(ch)
// Assert // Assert
waitForNewAttacherCallCount(t, 0 /* expectedCallCount */, fakePlugin) waitForNewAttacherCallCount(t, 0 /* expectedCallCount */, fakePlugin)
...@@ -97,7 +99,9 @@ func Test_Run_Positive_OneDesiredVolumeAttach(t *testing.T) { ...@@ -97,7 +99,9 @@ func Test_Run_Positive_OneDesiredVolumeAttach(t *testing.T) {
} }
// Act // Act
go reconciler.Run(wait.NeverStop) ch := make(chan struct{})
go reconciler.Run(ch)
defer close(ch)
// Assert // Assert
waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin) waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin)
...@@ -140,7 +144,9 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithUnmountedVolume(t *te ...@@ -140,7 +144,9 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithUnmountedVolume(t *te
} }
// Act // Act
go reconciler.Run(wait.NeverStop) ch := make(chan struct{})
go reconciler.Run(ch)
defer close(ch)
// Assert // Assert
waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin) waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin)
...@@ -204,7 +210,9 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithMountedVolume(t *test ...@@ -204,7 +210,9 @@ func Test_Run_Positive_OneDesiredVolumeAttachThenDetachWithMountedVolume(t *test
} }
// Act // Act
go reconciler.Run(wait.NeverStop) ch := make(chan struct{})
go reconciler.Run(ch)
defer close(ch)
// Assert // Assert
waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin) waitForNewAttacherCallCount(t, 1 /* expectedCallCount */, fakePlugin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment