mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #94735 from mikedanese/flake
test flake: fix data race in csi_test.go
This commit is contained in:
commit
0b8c2bf1a1
@ -305,19 +305,22 @@ func TestCSI_VolumeAll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// creates VolumeAttachment and blocks until it is marked attached (done by external attacher)
|
// creates VolumeAttachment and blocks until it is marked attached (done by external attacher)
|
||||||
go func(spec *volume.Spec, nodeName types.NodeName) {
|
attachDone := make(chan struct{})
|
||||||
attachID, err := volAttacher.Attach(spec, nodeName)
|
go func() {
|
||||||
|
defer close(attachDone)
|
||||||
|
attachID, err := volAttacher.Attach(volSpec, host.GetNodeName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("csiTest.VolumeAll attacher.Attach failed: %s", err)
|
t.Errorf("csiTest.VolumeAll attacher.Attach failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Logf("csiTest.VolumeAll got attachID %s", attachID)
|
t.Logf("csiTest.VolumeAll got attachID %s", attachID)
|
||||||
|
}()
|
||||||
}(volSpec, host.GetNodeName())
|
|
||||||
|
|
||||||
// Simulates external-attacher and marks VolumeAttachment.Status.Attached = true
|
// Simulates external-attacher and marks VolumeAttachment.Status.Attached = true
|
||||||
markVolumeAttached(t, host.GetKubeClient(), fakeWatcher, attachName, storage.VolumeAttachmentStatus{Attached: true})
|
markVolumeAttached(t, host.GetKubeClient(), fakeWatcher, attachName, storage.VolumeAttachmentStatus{Attached: true})
|
||||||
|
<-attachDone
|
||||||
|
|
||||||
|
// Observe attach on this node.
|
||||||
devicePath, err = volAttacher.WaitForAttach(volSpec, "", pod, 500*time.Millisecond)
|
devicePath, err = volAttacher.WaitForAttach(volSpec, "", pod, 500*time.Millisecond)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("csiTest.VolumeAll attacher.WaitForAttach failed:", err)
|
t.Fatal("csiTest.VolumeAll attacher.WaitForAttach failed:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user