Resize RBD CSI volumes on demand of CO resize request

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2019-11-27 17:44:31 +05:30
committed by mergify[bot]
parent aa32e8b43b
commit 2f2585dc3c
5 changed files with 130 additions and 0 deletions

View File

@ -813,3 +813,22 @@ func cleanupRBDImageMetadataStash(path string) error {
return nil
}
// resizeRBDImage resizes the given volume to new size
func resizeRBDImage(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials) error {
var output []byte
mon := rbdVol.Monitors
image := rbdVol.RbdImageName
volSzMiB := fmt.Sprintf("%dM", rbdVol.VolSize)
klog.V(4).Infof(util.Log(ctx, "rbd: resize %s size %s using mon %s, pool %s "), image, volSzMiB, mon, rbdVol.Pool)
args := []string{"resize", image, "--size", volSzMiB, "--pool", rbdVol.Pool, "--id", cr.ID, "-m", mon, "--keyfile=" + cr.KeyFile}
output, err := execCommand("rbd", args)
if err != nil {
return errors.Wrapf(err, "failed to resize rbd image, command output: %s", string(output))
}
return nil
}