Merge pull request #94735 from mikedanese/flake

test flake: fix data race in csi_test.go
This commit is contained in:
Kubernetes Prow Robot 2020-09-22 12:24:01 -07:00 committed by GitHub
commit 0b8c2bf1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)