mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
fix data race for Test_Run_Positive_VolumeMountControllerAttachEnabledRace
This commit is contained in:
parent
ebcb4a2d88
commit
1555877cc5
@ -36,6 +36,7 @@ import (
|
|||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
|
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
@ -1834,10 +1835,11 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
|
|||||||
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
|
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
|
||||||
// Act:
|
// Act:
|
||||||
// 3. While a volume is being unmounted, add it back to the desired state of world
|
// 3. While a volume is being unmounted, add it back to the desired state of world
|
||||||
t.Logf("UnmountDevice called")
|
klog.InfoS("UnmountDevice called")
|
||||||
generatedVolumeName, err = dsw.AddPodToVolume(
|
var generatedVolumeNameCopy v1.UniqueVolumeName
|
||||||
|
generatedVolumeNameCopy, err = dsw.AddPodToVolume(
|
||||||
podName, pod, volumeSpecCopy, volumeSpec.Name(), "" /* volumeGidValue */)
|
podName, pod, volumeSpecCopy, volumeSpec.Name(), "" /* volumeGidValue */)
|
||||||
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName})
|
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeNameCopy})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1845,7 +1847,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
|
|||||||
// Assert
|
// Assert
|
||||||
// 4. When the volume is mounted again, expect that UnmountDevice operation did not clear devicePath
|
// 4. When the volume is mounted again, expect that UnmountDevice operation did not clear devicePath
|
||||||
if devicePath == "" {
|
if devicePath == "" {
|
||||||
t.Errorf("Expected WaitForAttach called with devicePath from Node.Status")
|
klog.ErrorS(nil, "Expected WaitForAttach called with devicePath from Node.Status")
|
||||||
close(finished)
|
close(finished)
|
||||||
return "", fmt.Errorf("Expected devicePath from Node.Status")
|
return "", fmt.Errorf("Expected devicePath from Node.Status")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user