Skip to content

Commit 76b4973

Browse files
committed
Wait for mock CSI Driver bringup to perform e2e test
In our current mock CSI driver e2e test, we are not waiting for the CSI driver register successfully to perform test including provision PVC. This can lead to timeout when the csi driver takes longer to register the socket. This change adds the waiting part so that the system will wait for up to 10 minutes for the driver to be ready. This normally won't take this long. However, under a resource constraint environment it can take longer than expected time. kubernetes#93358
1 parent c0a4d4b commit 76b4973

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

test/e2e/storage/csi_mock_volume.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,16 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
151151

152152
if tp.registerDriver {
153153
err = waitForCSIDriver(cs, m.config.GetUniqueDriverName())
154-
framework.ExpectNoError(err, "Failed to get CSIDriver : %v", err)
154+
framework.ExpectNoError(err, "Failed to get CSIDriver %v", m.config.GetUniqueDriverName())
155155
m.testCleanups = append(m.testCleanups, func() {
156156
destroyCSIDriver(cs, m.config.GetUniqueDriverName())
157157
})
158158
}
159+
160+
// Wait for the CSIDriver actually get deployed and CSINode object to be generated.
161+
// This indicates the mock CSI driver pod is up and running healthy.
162+
err = drivers.WaitForCSIDriverRegistrationOnNode(m.config.ClientNodeSelection.Name, m.config.GetUniqueDriverName(), cs)
163+
framework.ExpectNoError(err, "Failed to register CSIDriver %v", m.config.GetUniqueDriverName())
159164
}
160165

161166
createPod := func(ephemeral bool) (class *storagev1.StorageClass, claim *v1.PersistentVolumeClaim, pod *v1.Pod) {

test/e2e/storage/drivers/csi.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,17 +608,25 @@ func waitForCSIDriverRegistrationOnAllNodes(driverName string, cs clientset.Inte
608608
return err
609609
}
610610
for _, node := range nodes.Items {
611-
if err := waitForCSIDriverRegistrationOnNode(node.Name, driverName, cs); err != nil {
611+
if err := WaitForCSIDriverRegistrationOnNode(node.Name, driverName, cs); err != nil {
612612
return err
613613
}
614614
}
615615
return nil
616616
}
617617

618-
func waitForCSIDriverRegistrationOnNode(nodeName string, driverName string, cs clientset.Interface) error {
619-
const csiNodeRegisterTimeout = 5 * time.Minute
618+
// WaitForCSIDriverRegistrationOnNode waits for the CSINode object generated by the node-registrar on a certain node
619+
func WaitForCSIDriverRegistrationOnNode(nodeName string, driverName string, cs clientset.Interface) error {
620+
framework.Logf("waiting for CSIDriver %v to register on node %v", driverName, nodeName)
620621

621-
waitErr := wait.PollImmediate(10*time.Second, csiNodeRegisterTimeout, func() (bool, error) {
622+
// About 8.6 minutes timeout
623+
backoff := wait.Backoff{
624+
Duration: 2 * time.Second,
625+
Factor: 1.5,
626+
Steps: 12,
627+
}
628+
629+
waitErr := wait.ExponentialBackoff(backoff, func() (bool, error) {
622630
csiNode, err := cs.StorageV1().CSINodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
623631
if err != nil && !apierrors.IsNotFound(err) {
624632
return false, err

0 commit comments

Comments
 (0)