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)
defer cancel()
// Call NodeUnpublishVolume
if _, err := os.Stat(publishPath); err != nil {
if os.IsNotExist(err) {
klog.V(4).Infof(log("blockMapper.UnmapPodDevice publishPath(%s) has already been deleted, skip calling NodeUnpublishVolume", publishPath))
} else {
return err
}
} else {
err := m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
if err != nil {
return err
}
}
return nil
// Call NodeUnpublishVolume.
// Even if publishPath does not exist - previous NodePublish may have timed out
// and Kubernetes makes sure that the operation is finished.
return m.unpublishVolumeForBlock(ctx, csiClient, publishPath)
}