Skip to content

Commit 9ff2a72

Browse files
YashasG98YashwantGohokar
authored andcommitted
Fix response when no size change in ControllerExpandVolume
1 parent fe8522d commit 9ff2a72

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkg/csi/driver/bv_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ func (d *BlockVolumeControllerDriver) ControllerExpandVolume(ctx context.Context
12291229
if newSizeInGB <= oldSize {
12301230
log.Infof("Existing volume size: %v Requested volume size: %v No action needed.", *volume.SizeInGBs, newSizeInGB)
12311231
return &csi.ControllerExpandVolumeResponse{
1232-
CapacityBytes: oldSize,
1232+
CapacityBytes: oldSize * client.GiB,
12331233
NodeExpansionRequired: true,
12341234
}, nil
12351235
}

pkg/csi/driver/bv_controller_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,24 @@ func TestControllerDriver_ControllerExpandVolume(t *testing.T) {
12351235
want: nil,
12361236
wantErr: errors.New("Update volume failed"),
12371237
},
1238+
{
1239+
name: "If no changes then do nothing in ControllerExpandVolume",
1240+
fields: fields{},
1241+
args: args{
1242+
ctx: nil,
1243+
req: &csi.ControllerExpandVolumeRequest{
1244+
VolumeId: "valid_volume_id",
1245+
CapacityRange: &csi.CapacityRange{
1246+
RequiredBytes: int64(csi_util.MaximumVolumeSizeInBytes),
1247+
},
1248+
},
1249+
},
1250+
want: &csi.ControllerExpandVolumeResponse{
1251+
CapacityBytes: int64(csi_util.MaximumVolumeSizeInBytes),
1252+
NodeExpansionRequired: true,
1253+
},
1254+
wantErr: nil,
1255+
},
12381256
{
12391257
name: "Uhp volume expand success in ControllerExpandVolume",
12401258
fields: fields{},

0 commit comments

Comments
 (0)