From 2c67ba1ec4832defb3f07f4fe47f4ebaf773c1d5 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 14 Jul 2020 12:56:55 +0530 Subject: [PATCH] rbd: Return current depth if the image is not found If the image in the chain is moved to trash, we cannot get the image details. We need to return the found depth to the caller. Signed-off-by: Madhu Rajanna --- internal/rbd/rbd_util.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 4c8892ad3..a18c401c5 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -408,6 +408,13 @@ func (rv *rbdVolume) getCloneDepth(ctx context.Context) (uint, error) { } err = vol.getImageInfo() if err != nil { + // if the parent image is moved to trash the name will be present + // in rbd image info but the image will be in trash, in that case + // return the found depth + var einf ErrImageNotFound + if errors.As(err, &einf) { + return depth, nil + } klog.Errorf(util.Log(ctx, "failed to check depth on image %s: %s"), vol, err) return depth, err }