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 <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-07-14 12:56:55 +05:30 committed by mergify[bot]
parent 76c2f3c109
commit 2c67ba1ec4

View File

@ -408,6 +408,13 @@ func (rv *rbdVolume) getCloneDepth(ctx context.Context) (uint, error) {
} }
err = vol.getImageInfo() err = vol.getImageInfo()
if err != nil { 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) klog.Errorf(util.Log(ctx, "failed to check depth on image %s: %s"), vol, err)
return depth, err return depth, err
} }