From 31c7c95fdbabb4e43bcf7551cd0b8a596d94b606 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 18 Aug 2020 07:55:10 +0530 Subject: [PATCH] cephfs: check error output contains Error: ENOENT execCommandErr returns both error and stderror message. checking strings.HasPrefix is not helpful as the stderr will be the first string. its good to do string comparison and find out that error is volume not found error. Signed-off-by: Madhu Rajanna --- internal/cephfs/volume.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index 4a102264b..efc2a557b 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -252,7 +252,7 @@ func purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, volO err := execCommandErr(ctx, "ceph", arg...) if err != nil { util.ErrorLog(ctx, "failed to purge subvolume %s(%s) in fs %s", string(volID), err, volOptions.FsName) - if strings.HasPrefix(err.Error(), ErrVolumeNotFound.Error()) { + if strings.Contains(err.Error(), ErrVolumeNotFound.Error()) { return util.JoinErrors(ErrVolumeNotFound, err) } return err