diff --git a/frontend/rest/controller_handlers.go b/frontend/rest/controller_handlers.go index 8c7eb3b1f..6ccd1e2e1 100644 --- a/frontend/rest/controller_handlers.go +++ b/frontend/rest/controller_handlers.go @@ -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 } diff --git a/storage_drivers/ontap/ontap_nas_qtree.go b/storage_drivers/ontap/ontap_nas_qtree.go index a7426f323..5f5eb7859 100644 --- a/storage_drivers/ontap/ontap_nas_qtree.go +++ b/storage_drivers/ontap/ontap_nas_qtree.go @@ -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 { diff --git a/storage_drivers/ontap/ontap_nas_qtree_test.go b/storage_drivers/ontap/ontap_nas_qtree_test.go index 1b7caff65..f7a5d429f 100644 --- a/storage_drivers/ontap/ontap_nas_qtree_test.go +++ b/storage_drivers/ontap/ontap_nas_qtree_test.go @@ -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")