Skip to content

Commit ae76503

Browse files
authored
Re-enable storage prefix update prevention
1 parent 52faa75 commit ae76503

10 files changed

+91
-48
lines changed

core/concurrent_core_test.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,25 +1895,24 @@ func Test_UpdateBackendConcurrentCore(t *testing.T) {
18951895
assert.ErrorContains(t, err, "unsupported config error; input is missing the credentials field")
18961896
},
18971897
},
1898-
// TODO: (victorir) to unblock updating a backend 25.02. Needs refactoring.
1899-
// {
1900-
// name: "UpdateStoragePrefixError",
1901-
// newBackendConfig: map[string]interface{}{
1902-
// "version": 1,
1903-
// "storageDriverName": "fake",
1904-
// "backendName": existingBackendName,
1905-
// "storagePrefix": "new-prefix",
1906-
// "protocol": config.File,
1907-
// "volumeAccess": "1.0.0.1",
1908-
// },
1909-
// setupMocks: func(o *ConcurrentTridentOrchestrator, mockStoreClient *mockpersistentstore.MockStoreClient) {
1910-
// fakeBackend := getFakeBackend(existingBackendName, existingBackendUuid)
1911-
// addBackendsToCache(t, fakeBackend)
1912-
// },
1913-
// verifyError: func(err error) {
1914-
// assert.ErrorContains(t, err, "updating the storage prefix isn't currently supported")
1915-
// },
1916-
// },
1898+
{
1899+
name: "UpdateStoragePrefixError",
1900+
newBackendConfig: map[string]interface{}{
1901+
"version": 1,
1902+
"storageDriverName": "fake",
1903+
"backendName": existingBackendName,
1904+
"storagePrefix": "new-prefix",
1905+
"protocol": config.File,
1906+
"volumeAccess": "1.0.0.1",
1907+
},
1908+
setupMocks: func(o *ConcurrentTridentOrchestrator, mockStoreClient *mockpersistentstore.MockStoreClient) {
1909+
fakeBackend := getFakeBackend(existingBackendName, existingBackendUuid, nil)
1910+
addBackendsToCache(t, fakeBackend)
1911+
},
1912+
verifyError: func(err error) {
1913+
assert.ErrorContains(t, err, "updating the storage prefix isn't currently supported")
1914+
},
1915+
},
19171916
{
19181917
name: "BackendRenameSuccess",
19191918
newBackendConfig: map[string]interface{}{

core/orchestrator_core.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,16 +1349,8 @@ func (o *TridentOrchestrator) updateBackendByBackendUUID(
13491349
return nil, err
13501350
case updateCode.Contains(storage.PrefixChange):
13511351
err := errors.UnsupportedConfigError("updating the storage prefix isn't currently supported")
1352-
// TODO: (victorir) to unblock updating a backend 25.02. Needs refactoring.
1353-
Logc(ctx).WithField("error", err).Error("Backend update continuing, " +
1354-
"if storage prefix has been changed there may be errors.")
1355-
// return nil, err
1356-
// Update backend information
1357-
if err = o.updateBackendOnPersistentStore(ctx, backend, false); err != nil {
1358-
Logc(ctx).WithField("error", err).Errorf("Could not persist renamed backend from %v to %v",
1359-
originalBackend.Name(), backend.Name())
1360-
return nil, err
1361-
}
1352+
Logc(ctx).WithField("error", err).Error("Backend update failed.")
1353+
return nil, err
13621354
case updateCode.Contains(storage.BackendRename):
13631355
checkingBackend, lookupErr := o.getBackendByBackendName(backend.Name())
13641356
if lookupErr == nil {

core/orchestrator_core_test.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7808,6 +7808,7 @@ func TestUpdateBackendByBackendUUID(t *testing.T) {
78087808
"storageDriverName": "fake",
78097809
"backendName": bName,
78107810
"protocol": config.File,
7811+
"autoExportPolicy": true,
78117812
}
78127813

78137814
tests := []struct {
@@ -7862,17 +7863,16 @@ func TestUpdateBackendByBackendUUID(t *testing.T) {
78627863
mocks: func(mockStoreClient *mockpersistentstore.MockStoreClient) {},
78637864
wantErr: assert.Error,
78647865
},
7865-
// TODO: (victorir) to unblock updating a backend 25.02. Needs refactoring.
7866-
// {
7867-
// name: "UpdateStoragePrefixError",
7868-
// backendName: bName,
7869-
// newBackendConfig: map[string]interface{}{
7870-
// "version": 1, "storageDriverName": "fake", "backendName": bName,
7871-
// "storagePrefix": "new", "protocol": config.File,
7872-
// },
7873-
// mocks: func(mockStoreClient *mockpersistentstore.MockStoreClient) {},
7874-
// wantErr: assert.Error,
7875-
// },
7866+
{
7867+
name: "UpdateStoragePrefixError",
7868+
backendName: bName,
7869+
newBackendConfig: map[string]interface{}{
7870+
"version": 1, "storageDriverName": "fake", "backendName": bName,
7871+
"storagePrefix": "new", "protocol": config.File,
7872+
},
7873+
mocks: func(mockStoreClient *mockpersistentstore.MockStoreClient) {},
7874+
wantErr: assert.Error,
7875+
},
78767876
{
78777877
name: "BackendRenameWithExistingNameError",
78787878
backendName: bName,
@@ -7946,6 +7946,21 @@ func TestUpdateBackendByBackendUUID(t *testing.T) {
79467946
},
79477947
wantErr: assert.NoError,
79487948
},
7949+
{
7950+
name: "UpdateAutoExportPolicyToFalse",
7951+
backendName: bName,
7952+
newBackendConfig: map[string]interface{}{
7953+
"version": 1,
7954+
"storageDriverName": "fake",
7955+
"backendName": bName,
7956+
"protocol": config.File,
7957+
"autoExportPolicy": false,
7958+
},
7959+
mocks: func(mockStoreClient *mockpersistentstore.MockStoreClient) {
7960+
mockStoreClient.EXPECT().UpdateBackend(gomock.Any(), gomock.Any()).Return(nil)
7961+
},
7962+
wantErr: assert.NoError,
7963+
},
79497964
}
79507965

79517966
for _, tt := range tests {

storage_drivers/ontap/ontap_common.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,11 @@ func InitializeOntapDriver(
13781378
defer Logd(ctx, config.StorageDriverName,
13791379
config.DebugTraceFlags["method"]).WithFields(fields).Trace("<<<< InitializeOntapDriver")
13801380

1381+
if config.StoragePrefix == nil {
1382+
prefix := drivers.GetDefaultStoragePrefix(config.DriverContext)
1383+
config.StoragePrefix = &prefix
1384+
}
1385+
13811386
// Splitting config.ManagementLIF with colon allows to provide managementLIF value as address:port format
13821387
mgmtLIF := ""
13831388
if network.IPv6Check(config.ManagementLIF) {
@@ -1743,11 +1748,6 @@ func PopulateConfigurationDefaults(ctx context.Context, config *drivers.OntapSto
17431748
}
17441749
}
17451750

1746-
if config.StoragePrefix == nil {
1747-
prefix := drivers.GetDefaultStoragePrefix(config.DriverContext)
1748-
config.StoragePrefix = &prefix
1749-
}
1750-
17511751
if config.SpaceAllocation == "" {
17521752
config.SpaceAllocation = DefaultSpaceAllocation
17531753
}
@@ -1901,8 +1901,7 @@ func PopulateConfigurationDefaults(ctx context.Context, config *drivers.OntapSto
19011901
config.NameTemplate = ensureUniquenessInNameTemplate(config.NameTemplate)
19021902
}
19031903

1904-
Logc(ctx).WithFields(LogFields{
1905-
"StoragePrefix": *config.StoragePrefix,
1904+
logFields := LogFields{
19061905
"SpaceAllocation": config.SpaceAllocation,
19071906
"SpaceReserve": config.SpaceReserve,
19081907
"SnapshotPolicy": config.SnapshotPolicy,
@@ -1929,7 +1928,13 @@ func PopulateConfigurationDefaults(ctx context.Context, config *drivers.OntapSto
19291928
"FlexgroupAggregateList": config.FlexGroupAggregateList,
19301929
"ADAdminUser": config.ADAdminUser,
19311930
"NameTemplate": config.NameTemplate,
1932-
}).Debugf("Configuration defaults")
1931+
}
1932+
1933+
if config.StoragePrefix != nil {
1934+
logFields["StoragePrefix"] = *config.StoragePrefix
1935+
}
1936+
1937+
Logc(ctx).WithFields(logFields).Debugf("Configuration defaults")
19331938

19341939
return nil
19351940
}

storage_drivers/ontap/ontap_common_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7892,6 +7892,7 @@ func TestPopulateConfigurationDefaults(t *testing.T) {
78927892

78937893
commonConfig := &drivers.CommonStorageDriverConfig{
78947894
DebugTraceFlags: map[string]bool{"method": true},
7895+
StoragePrefix: convert.ToPtr("storagePrefix_"),
78957896
}
78967897

78977898
config := &drivers.OntapStorageDriverConfig{

storage_drivers/ontap/ontap_nas_flexgroup_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize(t *testing.T) {
303303
BackendName: "myOntapNasFlexgroupBackend",
304304
DriverContext: tridentconfig.ContextCSI,
305305
DebugTraceFlags: debugTraceFlags,
306+
StoragePrefix: convert.ToPtr("storagePrefix_"),
306307
}
307308

308309
configJSON := `
@@ -356,6 +357,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_withNameTemplate(t *testing.T)
356357
BackendName: "myOntapNasFlexgroupBackend",
357358
DriverContext: tridentconfig.ContextCSI,
358359
DebugTraceFlags: debugTraceFlags,
360+
StoragePrefix: convert.ToPtr("storagePrefix_"),
359361
}
360362

361363
configJSON := `
@@ -402,6 +404,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_NameTemplateDefineInStoragePoo
402404
BackendName: "myOntapNasFlexgroupBackend",
403405
DriverContext: tridentconfig.ContextCSI,
404406
DebugTraceFlags: debugTraceFlags,
407+
StoragePrefix: convert.ToPtr("storagePrefix_"),
405408
}
406409

407410
configJSON := `
@@ -455,6 +458,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_NameTemplateDefineInBothPool(t
455458
BackendName: "myOntapNasFlexgroupBackend",
456459
DriverContext: tridentconfig.ContextCSI,
457460
DebugTraceFlags: debugTraceFlags,
461+
StoragePrefix: convert.ToPtr("storagePrefix_"),
458462
}
459463

460464
configJSON := `
@@ -507,6 +511,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_StoragePool(t *testing.T) {
507511
BackendName: "myOntapNasFlexgroupBackend",
508512
DriverContext: tridentconfig.ContextCSI,
509513
DebugTraceFlags: debugTraceFlags,
514+
StoragePrefix: convert.ToPtr("storagePrefix_"),
510515
}
511516

512517
secrets := map[string]string{
@@ -818,6 +823,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_ValidationFailed(t *testing.T)
818823
BackendName: "myOntapNasFlexgroupBackend",
819824
DriverContext: tridentconfig.ContextCSI,
820825
DebugTraceFlags: debugTraceFlags,
826+
StoragePrefix: convert.ToPtr("storagePrefix_"),
821827
}
822828

823829
secrets := map[string]string{
@@ -898,6 +904,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_GetSVMAggregateNamesFailed(t *
898904
BackendName: "myOntapNasFlexgroupBackend",
899905
DriverContext: tridentconfig.ContextCSI,
900906
DebugTraceFlags: debugTraceFlags,
907+
StoragePrefix: convert.ToPtr("storagePrefix_"),
901908
}
902909

903910
configJSON, _ := getOntapStorageDriverConfigJson("true", "volume", "", "none",
@@ -930,6 +937,7 @@ func TestOntapNasFlexgroupStorageDriverInitialize_GetSVMAggregateNameEmptyList(t
930937
BackendName: "myOntapNasFlexgroupBackend",
931938
DriverContext: tridentconfig.ContextCSI,
932939
DebugTraceFlags: debugTraceFlags,
940+
StoragePrefix: convert.ToPtr("storagePrefix_"),
933941
}
934942

935943
configJSON, _ := getOntapStorageDriverConfigJson("true", "volume", "", "none",

storage_drivers/ontap/ontap_nas_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func TestOntapNasStorageDriverInitialize(t *testing.T) {
386386
BackendName: "myOntapNasBackend",
387387
DriverContext: tridentconfig.ContextCSI,
388388
DebugTraceFlags: debugTraceFlags,
389+
StoragePrefix: convert.ToPtr("storagePrefix_"),
389390
}
390391

391392
configJSON := `
@@ -438,6 +439,7 @@ func TestOntapNasStorageDriverInitialize_NameTemplateDefineInBackendConfig(t *te
438439
BackendName: "myOntapNasBackend",
439440
DriverContext: tridentconfig.ContextCSI,
440441
DebugTraceFlags: debugTraceFlags,
442+
StoragePrefix: convert.ToPtr("storagePrefix_"),
441443
}
442444

443445
nameTemplate := "{{.config.StorageDriverName}}_{{.labels.Cluster}}_{{.volume.Namespace}}_{{.volume.RequestName}}_{{slice .volume.Name 4 9}}"
@@ -497,6 +499,7 @@ func TestOntapNasStorageDriverInitialize_NameTemplateDefineInStoragePool(t *test
497499
BackendName: "myOntapNasBackend",
498500
DriverContext: tridentconfig.ContextCSI,
499501
DebugTraceFlags: debugTraceFlags,
502+
StoragePrefix: convert.ToPtr("storagePrefix_"),
500503
}
501504

502505
expectedNameTemplate := "pool_{{.labels.Cluster}}_{{.volume.Namespace}}_{{.volume.RequestName}}_{{slice .volume.Name 4 9}}"
@@ -561,6 +564,7 @@ func TestOntapNasStorageDriverInitialize_NameTemplateDefineInBothPool(t *testing
561564
BackendName: "myOntapNasBackend",
562565
DriverContext: tridentconfig.ContextCSI,
563566
DebugTraceFlags: debugTraceFlags,
567+
StoragePrefix: convert.ToPtr("storagePrefix_"),
564568
}
565569

566570
expectedNameTemplate := "pool_{{.labels.Cluster}}_{{.volume.Namespace}}_{{.volume.RequestName}}_{{slice .volume.Name 4 9}}"
@@ -627,6 +631,7 @@ func TestOntapNasStorageDriverInitialize_Failure(t *testing.T) {
627631
BackendName: "myOntapNasBackend",
628632
DriverContext: tridentconfig.ContextCSI,
629633
DebugTraceFlags: debugTraceFlags,
634+
StoragePrefix: convert.ToPtr("storagePrefix_"),
630635
}
631636

632637
configJSON := `
@@ -659,6 +664,7 @@ func TestOntapNasStorageDriverInitialize_StoragePoolFailed(t *testing.T) {
659664
BackendName: "myOntapNasBackend",
660665
DriverContext: tridentconfig.ContextCSI,
661666
DebugTraceFlags: debugTraceFlags,
667+
StoragePrefix: convert.ToPtr("storagePrefix_"),
662668
}
663669

664670
configJSON := `
@@ -693,6 +699,7 @@ func TestOntapNasStorageDriverInitialize_ValidationFailed(t *testing.T) {
693699
BackendName: "myOntapNasBackend",
694700
DriverContext: tridentconfig.ContextCSI,
695701
DebugTraceFlags: debugTraceFlags,
702+
StoragePrefix: convert.ToPtr("storagePrefix_"),
696703
}
697704

698705
configJSON := `

storage_drivers/ontap/ontap_san_economy_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3916,6 +3916,7 @@ func TestOntapSanEconomyEnsureFlexvolForLUN_NewFlexvolNotPermitted(t *testing.T)
39163916
BackendName: "myOntapSanEcoBackend",
39173917
DriverContext: tridentconfig.ContextCSI,
39183918
DebugTraceFlags: debugTraceFlags,
3919+
StoragePrefix: convert.ToPtr("storagePrefix_"),
39193920
}
39203921
configJSON := fmt.Sprintf(`
39213922
{
@@ -4812,6 +4813,7 @@ func TestOntapSanEconomyInitialize(t *testing.T) {
48124813
BackendName: "myOntapSanEcoBackend",
48134814
DriverContext: tridentconfig.ContextCSI,
48144815
DebugTraceFlags: debugTraceFlags,
4816+
StoragePrefix: convert.ToPtr("storagePrefix_"),
48154817
}
48164818
commonConfigJSON := fmt.Sprintf(`
48174819
{
@@ -4876,6 +4878,7 @@ func TestOntapSanEconomyInitialize_WithNameTemplate(t *testing.T) {
48764878
BackendName: "myOntapSanEcoBackend",
48774879
DriverContext: tridentconfig.ContextCSI,
48784880
DebugTraceFlags: debugTraceFlags,
4881+
StoragePrefix: convert.ToPtr("storagePrefix_"),
48794882
}
48804883
commonConfigJSON := fmt.Sprintf(`
48814884
{
@@ -4935,6 +4938,7 @@ func TestOntapSanEconomyInitialize_NameTemplateDefineInStoragePool(t *testing.T)
49354938
BackendName: "myOntapSanEcoBackend",
49364939
DriverContext: tridentconfig.ContextCSI,
49374940
DebugTraceFlags: debugTraceFlags,
4941+
StoragePrefix: convert.ToPtr("storagePrefix_"),
49384942
}
49394943
commonConfigJSON := fmt.Sprintf(`
49404944
{
@@ -5002,6 +5006,7 @@ func TestOntapSanEconomyInitialize_NameTemplateDefineInBothPool(t *testing.T) {
50025006
BackendName: "myOntapSanEcoBackend",
50035007
DriverContext: tridentconfig.ContextCSI,
50045008
DebugTraceFlags: debugTraceFlags,
5009+
StoragePrefix: convert.ToPtr("storagePrefix_"),
50055010
}
50065011
commonConfigJSON := fmt.Sprintf(`
50075012
{
@@ -5065,6 +5070,7 @@ func TestOntapSanEconomyInitialize_InvalidConfig(t *testing.T) {
50655070
BackendName: "myOntapSanEcoBackend",
50665071
DriverContext: tridentconfig.ContextCSI,
50675072
DebugTraceFlags: debugTraceFlags,
5073+
StoragePrefix: convert.ToPtr("storagePrefix_"),
50685074
}
50695075
commonConfigJSON := fmt.Sprintf(`{invalid-json}`)
50705076
secrets := map[string]string{
@@ -5086,6 +5092,7 @@ func TestOntapSanEconomyInitialize_NoDataLIFs(t *testing.T) {
50865092
BackendName: "myOntapSanEcoBackend",
50875093
DriverContext: tridentconfig.ContextCSI,
50885094
DebugTraceFlags: debugTraceFlags,
5095+
StoragePrefix: convert.ToPtr("storagePrefix_"),
50895096
}
50905097
commonConfigJSON := fmt.Sprintf(`
50915098
{
@@ -5135,6 +5142,7 @@ func TestOntapSanEconomyInitialize_NumOfLUNs(t *testing.T) {
51355142
BackendName: "myOntapSanEcoBackend",
51365143
DriverContext: tridentconfig.ContextCSI,
51375144
DebugTraceFlags: debugTraceFlags,
5145+
StoragePrefix: convert.ToPtr("storagePrefix_"),
51385146
}
51395147
secrets := map[string]string{
51405148
"clientcertificate": "dummy-certificate",
@@ -5203,6 +5211,7 @@ func TestOntapSanEconomyInitialize_OtherContext(t *testing.T) {
52035211
BackendName: "myOntapSanEcoBackend",
52045212
DriverContext: tridentconfig.ContextCSI,
52055213
DebugTraceFlags: debugTraceFlags,
5214+
StoragePrefix: convert.ToPtr("storagePrefix_"),
52065215
}
52075216
commonConfigJSON := fmt.Sprintf(`
52085217
{
@@ -5255,6 +5264,7 @@ func TestOntapSanEconomyInitialize_NoSVMAggregates(t *testing.T) {
52555264
BackendName: "myOntapSanEcoBackend",
52565265
DriverContext: tridentconfig.ContextCSI,
52575266
DebugTraceFlags: debugTraceFlags,
5267+
StoragePrefix: convert.ToPtr("storagePrefix_"),
52585268
}
52595269
commonConfigJSON := fmt.Sprintf(`
52605270
{

0 commit comments

Comments
 (0)