mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rbd: pass context.Context to rbdVolume.resize()
While adding the context.Context to the resizeRBDimage() function, it became a little ugly. So renaming the function to resize() and making it a method of the rbdVolume type. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
36469b87e2
commit
be9e7cf956
@ -1092,7 +1092,7 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
|
|||||||
util.DebugLog(ctx, "rbd volume %s size is %v,resizing to %v", rbdVol, rbdVol.VolSize, volSize)
|
util.DebugLog(ctx, "rbd volume %s size is %v,resizing to %v", rbdVol, rbdVol.VolSize, volSize)
|
||||||
rbdVol.VolSize = volSize
|
rbdVol.VolSize = volSize
|
||||||
nodeExpansion = true
|
nodeExpansion = true
|
||||||
err = resizeRBDImage(rbdVol, cr)
|
err = rbdVol.resize(ctx, cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf(util.Log(ctx, "failed to resize rbd image: %s with error: %v"), rbdVol, err)
|
klog.Errorf(util.Log(ctx, "failed to resize rbd image: %s with error: %v"), rbdVol, err)
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
@ -1042,13 +1042,13 @@ func cleanupRBDImageMetadataStash(path string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resizeRBDImage resizes the given volume to new size.
|
// resize the given volume to new size.
|
||||||
func resizeRBDImage(rbdVol *rbdVolume, cr *util.Credentials) error {
|
func (rv *rbdVolume) resize(ctx context.Context, cr *util.Credentials) error {
|
||||||
mon := rbdVol.Monitors
|
mon := rv.Monitors
|
||||||
volSzMiB := fmt.Sprintf("%dM", util.RoundOffVolSize(rbdVol.VolSize))
|
volSzMiB := fmt.Sprintf("%dM", util.RoundOffVolSize(rv.VolSize))
|
||||||
|
|
||||||
args := []string{"resize", rbdVol.String(), "--size", volSzMiB, "--id", cr.ID, "-m", mon, "--keyfile=" + cr.KeyFile}
|
args := []string{"resize", rv.String(), "--size", volSzMiB, "--id", cr.ID, "-m", mon, "--keyfile=" + cr.KeyFile}
|
||||||
_, stderr, err := util.ExecCommand(context.TODO(), "rbd", args...)
|
_, stderr, err := util.ExecCommand(ctx, "rbd", args...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to resize rbd image (%w), command output: %s", err, stderr)
|
return fmt.Errorf("failed to resize rbd image (%w), command output: %s", err, stderr)
|
||||||
|
Loading…
Reference in New Issue
Block a user