Skip to content

Commit f6fc735

Browse files
committed
Call NodeUnpublish after NodePublish timeout
When NodePublish times out and user deletes corresponding pod, the driver may continue publishing the volume. In order to "cancel" this operation, Kubernetes must issue NodeUnpublish and wait until it finishes. Therefore, NodeUnpublish should be called even if the target directory (created by the driver) does not exist yet.
1 parent 86a5bd9 commit f6fc735

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

pkg/volume/csi/csi_block.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -503,19 +503,8 @@ func (m *csiBlockMapper) UnmapPodDevice() error {
503503
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
504504
defer cancel()
505505

506-
// Call NodeUnpublishVolume
507-
if _, err := os.Stat(publishPath); err != nil {
508-
if os.IsNotExist(err) {
509-
klog.V(4).Infof(log("blockMapper.UnmapPodDevice publishPath(%s) has already been deleted, skip calling NodeUnpublishVolume", publishPath))
510-
} else {
511-
return err
512-
}
513-
} else {
514-
err := m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
515-
if err != nil {
516-
return err
517-
}
518-
}
519-
520-
return nil
506+
// Call NodeUnpublishVolume.
507+
// Even if publishPath does not exist - previous NodePublish may have timed out
508+
// and Kubernetes makes sure that the operation is finished.
509+
return m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
521510
}

0 commit comments

Comments
 (0)