rbd: update per volume metadata stash-file with devicePath

As part of stage transaction if the mounter is of type nbd, then capture
device path after a successful rbd-nbd map.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever
2021-05-31 16:39:36 +05:30
committed by mergify[bot]
parent 70998571aa
commit 6d24080851
2 changed files with 39 additions and 0 deletions

View File

@ -220,6 +220,7 @@ func (ns *NodeServer) NodeStageVolume(
volOptions.MapOptions = req.GetVolumeContext()["mapOptions"]
volOptions.UnmapOptions = req.GetVolumeContext()["unmapOptions"]
volOptions.Mounter = req.GetVolumeContext()["mounter"]
// Stash image details prior to mapping the image (useful during Unstage as it has no
// voloptions passed to the RPC as per the CSI spec)
@ -315,6 +316,17 @@ func (ns *NodeServer) stageTransaction(
util.DebugLog(ctx, "rbd image: %s/%s was successfully mapped at %s\n",
req.GetVolumeId(), volOptions.Pool, devicePath)
// userspace mounters like nbd need the device path as a reference while
// restarting the userspace processes on a nodeplugin restart. For kernel
// mounter(krbd) we don't need it as there won't be any process running
// in userspace, hence we don't store the device path for krbd devices.
if volOptions.Mounter == rbdNbdMounter {
err = updateRBDImageMetadataStash(req.GetStagingTargetPath(), devicePath)
if err != nil {
return transaction, err
}
}
if volOptions.isEncrypted() {
devicePath, err = ns.processEncryptedDevice(ctx, volOptions, devicePath)
if err != nil {