Merge pull request #102021 from huffmanca/add-sleep-to-snapshotting-tests

Update snapshotting tests to use volumeHandle for CSI volumes when waiting for NodeUnpublish
This commit is contained in:
Kubernetes Prow Robot 2021-05-24 21:49:21 -07:00 committed by GitHub
commit ae381b6107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,20 +184,25 @@ func (s *snapshottableTestSuite) DefineTests(driver storageframework.TestDriver,
nodeName := pod.Spec.NodeName
gomega.Expect(nodeName).NotTo(gomega.BeEmpty(), "pod.Spec.NodeName must not be empty")
ginkgo.By(fmt.Sprintf("[init] waiting until the node=%s is not using the volume=%s", nodeName, pv.Name))
// Snapshot tests are only executed for CSI drivers. When CSI drivers
// are attached to the node they use VolumeHandle instead of the pv.Name.
volumeName := pv.Spec.PersistentVolumeSource.CSI.VolumeHandle
ginkgo.By(fmt.Sprintf("[init] waiting until the node=%s is not using the volume=%s", nodeName, volumeName))
success := storageutils.WaitUntil(framework.Poll, f.Timeouts.PVDelete, func() bool {
node, err := cs.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
framework.ExpectNoError(err)
volumesInUse := node.Status.VolumesInUse
framework.Logf("current volumes in use: %+v", volumesInUse)
for i := 0; i < len(volumesInUse); i++ {
if strings.HasSuffix(string(volumesInUse[i]), pv.Name) {
if strings.HasSuffix(string(volumesInUse[i]), volumeName) {
return false
}
}
return true
})
framework.ExpectEqual(success, true)
}
cleanup := func() {