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.
This commit is contained in:
Jan Safranek 2020-03-02 12:54:02 +01:00
parent 86a5bd98b6
commit f6fc73573c

View File

@ -503,19 +503,8 @@ func (m *csiBlockMapper) UnmapPodDevice() error {
ctx, cancel := context.WithTimeout(context.Background(), csiTimeout) ctx, cancel := context.WithTimeout(context.Background(), csiTimeout)
defer cancel() defer cancel()
// Call NodeUnpublishVolume // Call NodeUnpublishVolume.
if _, err := os.Stat(publishPath); err != nil { // Even if publishPath does not exist - previous NodePublish may have timed out
if os.IsNotExist(err) { // and Kubernetes makes sure that the operation is finished.
klog.V(4).Infof(log("blockMapper.UnmapPodDevice publishPath(%s) has already been deleted, skip calling NodeUnpublishVolume", publishPath)) return m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
} else {
return err
}
} else {
err := m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
if err != nil {
return err
}
}
return nil
} }