Skip to content

Commit

Permalink
Return capacity in bytes for resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
bertinatto committed Apr 5, 2019
1 parent 6c4c173 commit 2257cf9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ func (c *cloud) ResizeDisk(ctx context.Context, volumeID string, reqSizeBytes in

if oldSizeGiB >= reqSizeGiB {
err := fmt.Errorf("could not expand volume %q: current size (%d GiB) is greater or equal to requested size (%d GiB)", volumeID, oldSizeGiB, reqSizeGiB)
return oldSizeBytes, err
return oldSizeGiB, err
}

// Modify volume
Expand All @@ -754,7 +754,7 @@ func (c *cloud) ResizeDisk(ctx context.Context, volumeID string, reqSizeBytes in
return aws.Int64Value(m.TargetSize), nil
}
}
return oldSizeBytes, fmt.Errorf("could not modify AWS volume %q: %v", volumeID, err)
return oldSizeGiB, fmt.Errorf("could not modify AWS volume %q: %v", volumeID, err)
}

m := output.VolumeModification
Expand All @@ -771,14 +771,14 @@ func (c *cloud) ResizeDisk(ctx context.Context, volumeID string, reqSizeBytes in
Steps: 20,
}

var modVolSize int64
var modVolSizeGiB int64
waitErr := wait.ExponentialBackoff(backoff, func() (bool, error) {
m, err := c.getVolumeModification(ctx, volumeID)
if err != nil {
return false, err
}
if aws.StringValue(m.ModificationState) == ec2.VolumeModificationStateCompleted || aws.StringValue(m.ModificationState) == ec2.VolumeModificationStateOptimizing {
modVolSize = aws.Int64Value(m.TargetSize)
modVolSizeGiB = aws.Int64Value(m.TargetSize)
return true, nil
}
return true, nil
Expand All @@ -789,7 +789,7 @@ func (c *cloud) ResizeDisk(ctx context.Context, volumeID string, reqSizeBytes in
return -1, waitErr
}

return modVolSize, nil
return modVolSizeGiB, nil
}

func (c *cloud) getVolumeModification(ctx context.Context, volumeID string) (*ec2.VolumeModification, error) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi
return nil, status.Error(codes.InvalidArgument, "After round-up, volume size exceeds the limit specified")
}

actualSize, err := d.cloud.ResizeDisk(ctx, volumeID, newSize)
if err != nil || actualSize < 0 {
actualSizeGiB, err := d.cloud.ResizeDisk(ctx, volumeID, newSize)
if err != nil || actualSizeGiB < 0 {
return nil, status.Errorf(codes.Internal, "Could not resize volume %q: %v", volumeID, err)
}

return &csi.ControllerExpandVolumeResponse{
CapacityBytes: actualSize,
CapacityBytes: util.GiBToBytes(actualSizeGiB),
NodeExpansionRequired: true,
}, nil
}
Expand Down

0 comments on commit 2257cf9

Please sign in to comment.