Skip to content

Commit a9e9cab

Browse files
authored
Merge pull request kubernetes#94676 from JornShen/fix_Test_Run_Positive_VolumeMountControllerAttachEnabledRace_data_trace
Fix flaky unit test Test_Run_Positive_VolumeMountControllerAttachEnabledRace data race
2 parents 34ae231 + b6b462b commit a9e9cab

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/kubelet/volumemanager/reconciler/reconciler_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ import (
4848
const (
4949
// reconcilerLoopSleepDuration is the amount of time the reconciler loop
5050
// waits between successive executions
51-
reconcilerLoopSleepDuration time.Duration = 1 * time.Nanosecond
51+
reconcilerLoopSleepDuration = 1 * time.Nanosecond
5252
// waitForAttachTimeout is the maximum amount of time a
5353
// operationexecutor.Mount call will wait for a volume to be attached.
54-
waitForAttachTimeout time.Duration = 1 * time.Second
55-
nodeName k8stypes.NodeName = k8stypes.NodeName("mynodename")
56-
kubeletPodsDir string = "fake-dir"
57-
testOperationBackOffDuration time.Duration = 100 * time.Millisecond
58-
reconcilerSyncWaitDuration time.Duration = 10 * time.Second
54+
waitForAttachTimeout = 1 * time.Second
55+
nodeName = k8stypes.NodeName("mynodename")
56+
kubeletPodsDir = "fake-dir"
57+
testOperationBackOffDuration = 100 * time.Millisecond
58+
reconcilerSyncWaitDuration = 10 * time.Second
5959
)
6060

6161
func hasAddedPods() bool { return true }
@@ -1791,6 +1791,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
17911791
<-stoppedChan
17921792

17931793
finished := make(chan interface{})
1794+
fakePlugin.Lock()
17941795
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
17951796
// Act:
17961797
// 3. While a volume is being unmounted, add it back to the desired state of world
@@ -1812,6 +1813,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
18121813
close(finished)
18131814
return devicePath, nil
18141815
}
1816+
fakePlugin.Unlock()
18151817

18161818
// Start the reconciler again.
18171819
go reconciler.Run(wait.NeverStop)

0 commit comments

Comments
 (0)