Skip to content

Commit a4fc3fa

Browse files
publish enforcement for FCP
1 parent ba4cd44 commit a4fc3fa

File tree

2 files changed

+92
-6
lines changed

2 files changed

+92
-6
lines changed

storage_drivers/ontap/ontap_common.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3548,10 +3548,10 @@ func EnableSANPublishEnforcement(
35483548
return fmt.Errorf(msg)
35493549
}
35503550

3551-
// TODO: Check if it needs to handled for FCP
3552-
3553-
volumeConfig.AccessInfo.IscsiLunNumber = -1
35543551
volumeConfig.AccessInfo.PublishEnforcement = true
3552+
volumeConfig.AccessInfo.FCPLunNumber = -1
3553+
volumeConfig.AccessInfo.FCPIgroup = ""
3554+
volumeConfig.AccessInfo.IscsiLunNumber = -1
35553555
volumeConfig.AccessInfo.IscsiIgroup = ""
35563556

35573557
return nil

storage_drivers/ontap/ontap_common_test.go

+89-3
Original file line numberDiff line numberDiff line change
@@ -5913,7 +5913,7 @@ func TestDestroyUnmappedIgroup_Succeeds(t *testing.T) {
59135913
assert.NoError(t, err)
59145914
}
59155915

5916-
func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport(t *testing.T) {
5916+
func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport_ISCSI(t *testing.T) {
59175917
ctx := context.Background()
59185918
mockCtrl := gomock.NewController(t)
59195919
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
@@ -5941,7 +5941,7 @@ func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport(t *testing.T
59415941
assert.NotEqual(t, -1, volume.Config.AccessInfo.IscsiAccessInfo.IscsiLunNumber)
59425942
}
59435943

5944-
func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups(t *testing.T) {
5944+
func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups_ISCSI(t *testing.T) {
59455945
ctx := context.Background()
59465946
mockCtrl := gomock.NewController(t)
59475947
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
@@ -5970,7 +5970,7 @@ func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups(t *testing.T)
59705970
assert.NotEqual(t, -1, volume.Config.AccessInfo.IscsiAccessInfo.IscsiLunNumber)
59715971
}
59725972

5973-
func TestEnableSANPublishEnforcement_Succeeds(t *testing.T) {
5973+
func TestEnableSANPublishEnforcement_Succeeds_ISCSI(t *testing.T) {
59745974
ctx := context.Background()
59755975
mockCtrl := gomock.NewController(t)
59765976
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
@@ -5999,6 +5999,92 @@ func TestEnableSANPublishEnforcement_Succeeds(t *testing.T) {
59995999
assert.Equal(t, int32(-1), volume.Config.AccessInfo.IscsiAccessInfo.IscsiLunNumber)
60006000
}
60016001

6002+
func TestEnableSANPublishEnforcement_DoesNotEnableForUnmangedImport_FCP(t *testing.T) {
6003+
ctx := context.Background()
6004+
mockCtrl := gomock.NewController(t)
6005+
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
6006+
6007+
volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6008+
internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6009+
lunPath := fmt.Sprintf("/vol/myBucket/storagePrefix_vol1_%s", internalVolName)
6010+
volume := &storage.Volume{
6011+
Config: &storage.VolumeConfig{
6012+
Name: volName,
6013+
InternalName: internalVolName,
6014+
AccessInfo: tridentmodels.VolumeAccessInfo{
6015+
PublishEnforcement: false,
6016+
FCPAccessInfo: tridentmodels.FCPAccessInfo{
6017+
FCPLunNumber: 1,
6018+
},
6019+
},
6020+
ImportNotManaged: true,
6021+
},
6022+
}
6023+
6024+
err := EnableSANPublishEnforcement(ctx, mockAPI, volume.Config, lunPath)
6025+
assert.NoError(t, err)
6026+
assert.False(t, volume.Config.AccessInfo.PublishEnforcement)
6027+
assert.NotEqual(t, -1, volume.Config.AccessInfo.FCPAccessInfo.FCPLunNumber)
6028+
}
6029+
6030+
func TestEnableSANPublishEnforcement_FailsToUnmapLunFromAllIgroups_FCP(t *testing.T) {
6031+
ctx := context.Background()
6032+
mockCtrl := gomock.NewController(t)
6033+
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
6034+
6035+
volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6036+
internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6037+
lunPath := fmt.Sprintf("/vol/myBucket/storagePrefix_vol1_%s", internalVolName)
6038+
volume := &storage.Volume{
6039+
Config: &storage.VolumeConfig{
6040+
Name: volName,
6041+
InternalName: internalVolName,
6042+
AccessInfo: tridentmodels.VolumeAccessInfo{
6043+
PublishEnforcement: false,
6044+
FCPAccessInfo: tridentmodels.FCPAccessInfo{
6045+
FCPLunNumber: 1,
6046+
},
6047+
},
6048+
ImportNotManaged: false,
6049+
},
6050+
}
6051+
mockAPI.EXPECT().LunListIgroupsMapped(ctx, gomock.Any()).Return(nil, fmt.Errorf("ontap api error"))
6052+
6053+
err := EnableSANPublishEnforcement(ctx, mockAPI, volume.Config, lunPath)
6054+
assert.Error(t, err)
6055+
assert.False(t, volume.Config.AccessInfo.PublishEnforcement)
6056+
assert.NotEqual(t, -1, volume.Config.AccessInfo.FCPAccessInfo.FCPLunNumber)
6057+
}
6058+
6059+
func TestEnableSANPublishEnforcement_Succeeds_FCP(t *testing.T) {
6060+
ctx := context.Background()
6061+
mockCtrl := gomock.NewController(t)
6062+
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
6063+
6064+
volName := "trident_pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6065+
internalVolName := "pvc_63a8ea3d_4213_4753_8b38_2da69c178ed0"
6066+
lunPath := fmt.Sprintf("/vol/myBucket/storagePrefix_vol1_%s", internalVolName)
6067+
volume := &storage.Volume{
6068+
Config: &storage.VolumeConfig{
6069+
Name: volName,
6070+
InternalName: internalVolName,
6071+
AccessInfo: tridentmodels.VolumeAccessInfo{
6072+
PublishEnforcement: false,
6073+
FCPAccessInfo: tridentmodels.FCPAccessInfo{
6074+
FCPLunNumber: 1,
6075+
},
6076+
},
6077+
ImportNotManaged: false,
6078+
},
6079+
}
6080+
mockAPI.EXPECT().LunListIgroupsMapped(ctx, gomock.Any()).Return(nil, nil)
6081+
6082+
err := EnableSANPublishEnforcement(ctx, mockAPI, volume.Config, lunPath)
6083+
assert.NoError(t, err)
6084+
assert.True(t, volume.Config.AccessInfo.PublishEnforcement)
6085+
assert.Equal(t, int32(-1), volume.Config.AccessInfo.FCPAccessInfo.FCPLunNumber)
6086+
}
6087+
60026088
func TestGetNodeSpecificIgroup(t *testing.T) {
60036089
tests := map[string]struct {
60046090
node, uuid string

0 commit comments

Comments
 (0)