Skip to content

Commit

Permalink
Disable update volume option (#1461)
Browse files Browse the repository at this point in the history
Adding DisableExtraFeature check for update volume operation, added as part of dynamic updation of SnapshotDir.
  • Loading branch information
aparna0508 authored and shivangbhar committed Sep 25, 2023
1 parent b62610a commit bfcca96
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/rest/controller_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ func volumeUpdater(
return http.StatusBadRequest
} else if errors.IsNotFoundError(err) {
return http.StatusNotFound
} else if errors.IsUnsupportedError(err) {
return http.StatusForbidden
} else {
return http.StatusInternalServerError
}
Expand Down
4 changes: 4 additions & 0 deletions storage_drivers/ontap/ontap_nas_qtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@ func (d *NASQtreeStorageDriver) Update(
Logc(ctx).WithFields(fields).Debug(">>>> Update")
defer Logc(ctx).WithFields(fields).Debug("<<<< Update")

if tridentconfig.DisableExtraFeatures {
return nil, errors.UnsupportedError("update volume is not enabled")
}

updateGenericError := fmt.Sprintf("failed to update volume %v", volConfig.Name)

if updateInfo == nil {
Expand Down
27 changes: 27 additions & 0 deletions storage_drivers/ontap/ontap_nas_qtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4393,6 +4393,33 @@ func TestNASQtreeStorageDriver_UpdateVolume_Success(t *testing.T) {
}
}

func TestNASQtreeStorageDriver_UpdateVolume_Disabled(t *testing.T) {
_, driver := newMockOntapNasQtreeDriver(t)

internalID := "/svm/iscsi0/flexvol/trident_qtree_pool_trident_XHPULXSCYE/qtree/trident_pvc_99138d85_6259_4830_ada0_30e45e21f854"
mockVol := getMockVolume("pvc-99138d85-6259-4830-ada0-30e45e21f854", internalID)
mockVol.Config.SnapshotDir = "true"

allVolumes := map[string]*storage.Volume{
"pvc-99138d85-6259-4830-ada0-30e45e21f854": mockVol,
}

updateInfo := &utils.VolumeUpdateInfo{
SnapshotDirectory: "false",
PoolLevel: true,
}

original := tridentconfig.DisableExtraFeatures
defer func() { tridentconfig.DisableExtraFeatures = original }()
tridentconfig.DisableExtraFeatures = true

result, resultErr := driver.Update(ctx, mockVol.Config, updateInfo, allVolumes)

assert.Error(t, resultErr)
assert.Equal(t, errors.UnsupportedError("update volume is not enabled"), resultErr)
assert.Nil(t, result)
}

func TestNASQtreeStorageDriver_UpdateVolume_Failure(t *testing.T) {
mockAPI, driver := newMockOntapNasQtreeDriver(t)
fakeErr := errors.New("fake error")
Expand Down

0 comments on commit bfcca96

Please sign in to comment.