From 128f3fc2cf410209d63966a25b6ffc7f1e1331a3 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 24 Feb 2020 10:59:08 +0530 Subject: [PATCH] check subvolume present in backend If a CreateVolume call is interrupted, post creating the required CSI journal entries, but prior to creating the backing CephFS subvolume, then a subsequent CreateVolume call will return a valid response with a VolumeID that has it's backing image missing. This PR adds a check for backend image, if image notfound it deletes the reserved keys in omap. fixes #839 Signed-off-by: Madhu Rajanna --- pkg/cephfs/fsjournal.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/cephfs/fsjournal.go b/pkg/cephfs/fsjournal.go index 8ff1327af..c8fd4340e 100644 --- a/pkg/cephfs/fsjournal.go +++ b/pkg/cephfs/fsjournal.go @@ -74,6 +74,14 @@ func checkVolExists(ctx context.Context, volOptions *volumeOptions, secret map[s return nil, err } + _, err = getVolumeRootPathCeph(ctx, volOptions, cr, volumeID(vid.FsSubvolName)) + if err != nil { + if _, ok := err.(ErrVolumeNotFound); ok { + err = volJournal.UndoReservation(ctx, volOptions.Monitors, cr, volOptions.MetadataPool, vid.FsSubvolName, volOptions.RequestName) + return nil, err + } + return nil, err + } // TODO: size checks // found a volume already available, process and return it!