Skip crypto device cleanup for RWX volumes
Since the RWX volumes are owned and controlled by the share-manager, the
responsibility relies on the share-manager to clean up the devices.
Longhorn
@@ -396,7 +396,12 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
return nil, status.Error(codes.Internal, fmt.Sprintf("failed to unmount volume %s mount point %v error %v", volumeID, targetPath, err))
}
- // close any matching crypto device for this volume
+ // optionally try to retrieve the volume and check if it's an RWX volume
+ // if it is we let the share-manager clean up the crypto device
+ volume, _ := ns.apiClient.Volume.ById(volumeID)
+ cleanupCryptoDevice := !requiresSharedAccess(volume, nil)
+
+ if cleanupCryptoDevice {
cryptoDevice := crypto.VolumeMapper(volumeID)
if isOpen, err := crypto.IsDeviceOpen(cryptoDevice); err != nil {
return nil, status.Error(codes.Internal, err.Error())
@@ -407,6 +412,7 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
}
logrus.Infof("NodeUnstageVolume: volume %s closed active crypto device %s", volumeID, cryptoDevice)
}
+ }
logrus.Infof("NodeUnstageVolume: volume %s unmounted from node path %s", volumeID, targetPath)
return &csi.NodeUnstageVolumeResponse{}, nil
