Skip to content

Commit 924d8c6

Browse files
authored
Handled the FlexVol resize when the optimal FlexVol size couldn't be calculated
Signed-off-by: Sudha Kumari <[email protected]>
1 parent 2a34653 commit 924d8c6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

storage_drivers/ontap/ontap_nas_qtree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,7 @@ func (d *NASQtreeStorageDriver) resizeFlexvol(ctx context.Context, flexvol strin
24472447
if err = d.API.VolumeSetSize(ctx, flexvol, "+"+size); err != nil {
24482448
return fmt.Errorf("flexvol resize failed: %v", err)
24492449
}
2450+
return nil
24502451
}
24512452

24522453
// Got optimal size, so just set the Flexvol to that value

storage_drivers/ontap/ontap_nas_qtree_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3781,6 +3781,22 @@ func TestResizeFlexvol_Success_WithoutOptimalSize(t *testing.T) {
37813781
assert.NoError(t, result, "Flexvol resize failed")
37823782
}
37833783

3784+
func TestResizeFlexvol_FallbackPath_VolumeSetSizeSuccess(t *testing.T) {
3785+
volName := "vol1"
3786+
ctx := context.Background()
3787+
resizeToInBytes := uint64(10737418240) // 10g
3788+
3789+
mockAPI, driver := newMockOntapNasQtreeDriver(t)
3790+
3791+
// Simulate getOptimalSizeForFlexvol returning an error (simulate error in VolumeInfo)
3792+
mockAPI.EXPECT().VolumeInfo(ctx, volName).Return(nil, fmt.Errorf("mock error"))
3793+
// Expect VolumeSetSize to be called with "+" and the requested size, and succeed
3794+
mockAPI.EXPECT().VolumeSetSize(ctx, volName, "+"+strconv.FormatUint(resizeToInBytes, 10)).Return(nil).Times(1)
3795+
3796+
err := driver.resizeFlexvol(ctx, volName, resizeToInBytes)
3797+
assert.NoError(t, err, "Expected resizeFlexvol to return nil when VolumeSetSize succeeds in fallback path")
3798+
}
3799+
37843800
func TestResizeFlexvol_WithErrorInApiOperation(t *testing.T) {
37853801
volName := "vol1"
37863802
volInfo, _ := MockGetVolumeInfo(ctx, volName)

0 commit comments

Comments
 (0)