From 6e3d68ee7bb699898806df29c67a78b61106cab3 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Mon, 19 Oct 2020 13:45:57 +0530 Subject: [PATCH] cephfs: fix wrong error check in CreateVolume rollback action Previously the purgeVolume error was ignored due to wrong error variable check in the createVolume. With this change it checks on the proper error. Signed-off-by: Humble Chirammal (cherry picked from commit 9dee064b77377c7b78fd89b5f6df2ff49e53bc0b) --- internal/cephfs/controllerserver.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cephfs/controllerserver.go b/internal/cephfs/controllerserver.go index 3c2dfacdd..e1d4935d1 100644 --- a/internal/cephfs/controllerserver.go +++ b/internal/cephfs/controllerserver.go @@ -183,11 +183,13 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // explictly err = resizeVolume(ctx, volOptions, cr, volumeID(vID.FsSubvolName), volOptions.Size) if err != nil { - if purgeErr := purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, volOptions, false); err != nil { + purgeErr := purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, volOptions, false) + if purgeErr != nil { util.ErrorLog(ctx, "failed to delete volume %s: %v", requestName, purgeErr) // All errors other than ErrVolumeNotFound should return an error back to the caller if !errors.Is(purgeErr, ErrVolumeNotFound) { return nil, status.Error(codes.Internal, purgeErr.Error()) + } } errUndo := undoVolReservation(ctx, volOptions, *vID, secret)