Skip to content

Commit c1b1262

Browse files
authored
Adding limitVolumeSize check in resize operation for ASAr2 iSCSI
1 parent f74ce88 commit c1b1262

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

storage_drivers/ontap/ontap_asa.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,13 @@ func (d *ASAStorageDriver) Resize(
11331133
return tridenterrors.NotFoundError("LUN %s does not exist", name)
11341134
}
11351135

1136+
// Check if the requested size falls within limitVolumeSize config
1137+
if _, _, checkVolumeSizeLimitsError := drivers.CheckVolumeSizeLimits(
1138+
ctx, requestedSizeBytes, d.Config.CommonStorageDriverConfig,
1139+
); checkVolumeSizeLimitsError != nil {
1140+
return checkVolumeSizeLimitsError
1141+
}
1142+
11361143
// Get current size
11371144
currentLunSize, err := d.API.LunSize(ctx, name)
11381145
if err != nil {

storage_drivers/ontap/ontap_asa_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,32 @@ func TestOntapASAStorageDriver_Resize_LesserSizeThanCurrent(t *testing.T) {
26472647
assert.Error(t, err, "Expected error when resizing to lesser size than current")
26482648
}
26492649

2650+
func TestOntapASANVMeStorageDriver_Resize_DriverVolumeLimitError(t *testing.T) {
2651+
mockAPI, driver := newMockOntapASADriver(t)
2652+
2653+
volConfig := getASAVolumeConfig()
2654+
2655+
// Case: Invalid limitVolumeSize on driver
2656+
driver.Config.LimitVolumeSize = "1000.1000"
2657+
2658+
mockAPI.EXPECT().LunExists(ctx, "trident-pvc-1234").Return(true, nil)
2659+
2660+
err := driver.Resize(ctx, &volConfig, 2147483648) // 1GB
2661+
2662+
assert.ErrorContains(t, err, "error parsing limitVolumeSize")
2663+
2664+
// Case: requestedSize is more than limitVolumeSize
2665+
driver.Config.LimitVolumeSize = "2147483648" // 2 GB
2666+
2667+
mockAPI.EXPECT().LunExists(ctx, "trident-pvc-1234").Return(true, nil)
2668+
2669+
err = driver.Resize(ctx, &volConfig, 3221225472) // 3 GB
2670+
2671+
capacityErr, _ := errors.HasUnsupportedCapacityRangeError(err)
2672+
2673+
assert.True(t, capacityErr, "expected unsupported capacity error")
2674+
}
2675+
26502676
func TestOntapASAStorageDriver_Resize_APIErrors(t *testing.T) {
26512677
mockAPI, driver := newMockOntapASADriver(t)
26522678

0 commit comments

Comments
 (0)