rbd: resize the volume created from snapshot

If the requested volume size is greater than
the snapshot size, resize the cloned volume
after creating a clone from a snapshot.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-12-15 11:02:13 +05:30 committed by mergify[bot]
parent a28a4a4285
commit 69ae19e0cb

View File

@ -389,6 +389,14 @@ func (cs *ControllerServer) repairExistingVolume(ctx context.Context, req *csi.C
return nil, err
}
// expand the image if the requested size is greater than the current size
err = rbdVol.expand()
if err != nil {
log.ErrorLog(ctx, "failed to resize volume %s: %v", rbdVol, err)
return nil, err
}
// rbdVol is a clone from parentVol
case vcs.GetVolume() != nil:
// When cloning into a thick-provisioned volume was happening,
@ -590,6 +598,15 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
log.DebugLog(ctx, "create volume %s from snapshot %s", rbdVol.RequestName, rbdSnap.RbdSnapName)
// resize the volume if the size is different
// expand the image if the requested size is greater than the current size
err = rbdVol.expand()
if err != nil {
log.ErrorLog(ctx, "failed to resize volume %s: %v", rbdVol, err)
return err
}
return nil
}