Skip to content

Commit f8cb9f5

Browse files
authored
Use volume config fstype during publish
and format options
1 parent 3ccc6c8 commit f8cb9f5

8 files changed

Lines changed: 166 additions & 67 deletions

File tree

storage_drivers/ontap/ontap_asa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2026 NetApp, Inc. All Rights Reserved.
22

33
package ontap
44

@@ -790,7 +790,7 @@ func (d *ASAStorageDriver) Publish(
790790
}
791791
nodeName = iSCSINodeName
792792
}
793-
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, nodeName)
793+
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, nodeName, volConfig)
794794
if err != nil {
795795
return fmt.Errorf("error publishing %s driver: %v", d.Name(), err)
796796
}

storage_drivers/ontap/ontap_asa_test.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2026 NetApp, Inc. All Rights Reserved.
22

33
package ontap
44

@@ -748,6 +748,7 @@ func TestCreateASA(t *testing.T) {
748748
assert.Equal(t, storagePool.InternalAttributes()[QosPolicy], volConfig.QosPolicy)
749749
assert.Equal(t, storagePool.InternalAttributes()[LUKSEncryption], volConfig.LUKSEncryption)
750750
assert.Equal(t, storagePool.InternalAttributes()[FileSystemType], volConfig.FileSystem)
751+
assert.Equal(t, storagePool.InternalAttributes()[FormatOptions], volConfig.FormatOptions)
751752
assert.Equal(t, "true", volConfig.SkipRecoveryQueue, "SkipRecoveryQueue does not match")
752753
},
753754
},
@@ -1496,6 +1497,8 @@ func TestPublishASA(t *testing.T) {
14961497
initializeFunction := func() {
14971498
volConfig = getASAVolumeConfig()
14981499
volConfig.InternalName = "testVol"
1500+
// Set on Create; PublishLUN uses volConfig.FormatOptions and skips LunGetAttribute when non-empty.
1501+
volConfig.FormatOptions = "formatOptions"
14991502

15001503
driver.Config.IgroupName = "testIgroup"
15011504

@@ -1528,8 +1531,6 @@ func TestPublishASA(t *testing.T) {
15281531
mockAPI.EXPECT().VolumeInfo(ctx, volConfig.InternalName).Return(flexVol, nil).Times(1)
15291532
mockAPI.EXPECT().IscsiNodeGetNameRequest(ctx).Return("nodeName", nil).Times(1)
15301533
mockAPI.EXPECT().IscsiInterfaceGet(ctx, driver.Config.SVM).Return([]string{"iscsiInterfaces"}, nil).Times(1)
1531-
mockAPI.EXPECT().LunGetFSType(ctx, volConfig.InternalName).Return("ext4", nil).Times(1)
1532-
mockAPI.EXPECT().LunGetAttribute(ctx, volConfig.InternalName, "formatOptions").Return("formatOptions", nil).Times(1)
15331534
mockAPI.EXPECT().LunGetByName(ctx, volConfig.InternalName).Return(lun, nil).Times(1)
15341535
mockAPI.EXPECT().EnsureLunMapped(ctx, driver.Config.IgroupName, volConfig.InternalName).Return(1123, nil).Times(1)
15351536
},
@@ -1550,8 +1551,6 @@ func TestPublishASA(t *testing.T) {
15501551
}).Times(1)
15511552
mockAPI.EXPECT().IscsiNodeGetNameRequest(ctx).Return("nodeName", nil).Times(1)
15521553
mockAPI.EXPECT().IscsiInterfaceGet(ctx, driver.Config.SVM).Return([]string{"iscsiInterfaces"}, nil).Times(1)
1553-
mockAPI.EXPECT().LunGetFSType(ctx, volConfig.InternalName).Return("lunFSType", nil).Times(1)
1554-
mockAPI.EXPECT().LunGetAttribute(ctx, volConfig.InternalName, "formatOptions").Return("formatOptions", nil).Times(1)
15551554
mockAPI.EXPECT().LunGetByName(ctx, volConfig.InternalName).Return(lun, nil).Times(1)
15561555
mockAPI.EXPECT().EnsureLunMapped(ctx, getNodeSpecificIgroupName(publishInfo.HostName, publishInfo.TridentUUID), volConfig.InternalName).Return(1123, nil).Times(1)
15571556
},
@@ -1595,8 +1594,6 @@ func TestPublishASA(t *testing.T) {
15951594
mockAPI.EXPECT().VolumeInfo(ctx, volConfig.InternalName).Return(flexVol, nil).Times(1)
15961595
mockAPI.EXPECT().IscsiNodeGetNameRequest(ctx).Return("nodeName", nil).Times(1)
15971596
mockAPI.EXPECT().IscsiInterfaceGet(ctx, driver.Config.SVM).Return([]string{"iscsiInterfaces"}, nil).Times(1)
1598-
mockAPI.EXPECT().LunGetFSType(ctx, volConfig.InternalName).Return("lunFSType", nil).Times(1)
1599-
mockAPI.EXPECT().LunGetAttribute(ctx, volConfig.InternalName, "formatOptions").Return("formatOptions", nil).Times(1)
16001597
mockAPI.EXPECT().LunGetByName(ctx, volConfig.InternalName).Return(nil, errors.New("error")).Times(1)
16011598
},
16021599
verify: func(t *testing.T, err error) {
@@ -1618,8 +1615,6 @@ func TestPublishASA(t *testing.T) {
16181615
mockAPI.EXPECT().VolumeInfo(ctx, volConfig.InternalName).Return(flexVol, nil).Times(1)
16191616
mockAPI.EXPECT().FcpNodeGetNameRequest(ctx).Return("10:00:00:00:00:00:00:01", nil).Times(1)
16201617
mockAPI.EXPECT().FcpInterfaceGet(ctx, driver.Config.SVM).Return([]string{"10:00:00:00:00:00:00:01"}, nil).Times(1)
1621-
mockAPI.EXPECT().LunGetFSType(ctx, volConfig.InternalName).Return("ext4", nil).Times(1)
1622-
mockAPI.EXPECT().LunGetAttribute(ctx, volConfig.InternalName, "formatOptions").Return("formatOptions", nil).Times(1)
16231618
mockAPI.EXPECT().LunGetByName(ctx, volConfig.InternalName).Return(lun, nil).Times(1)
16241619
mockAPI.EXPECT().EnsureIgroupAdded(ctx, driver.Config.IgroupName, "10:00:00:00:00:00:00:01").Return(nil).AnyTimes()
16251620
mockAPI.EXPECT().EnsureLunMapped(ctx, driver.Config.IgroupName, volConfig.InternalName).Return(1123, nil).AnyTimes()
@@ -1690,8 +1685,6 @@ func TestPublishASA(t *testing.T) {
16901685
mockAPI.EXPECT().VolumeInfo(ctx, volConfig.InternalName).Return(flexVol, nil).Times(1)
16911686
mockAPI.EXPECT().FcpNodeGetNameRequest(ctx).Return("10:00:00:00:00:00:00:01", nil).Times(1)
16921687
mockAPI.EXPECT().FcpInterfaceGet(ctx, driver.Config.SVM).Return([]string{"10:00:00:00:00:00:00:01"}, nil).Times(1)
1693-
mockAPI.EXPECT().LunGetFSType(ctx, volConfig.InternalName).Return("ext4", nil).Times(1)
1694-
mockAPI.EXPECT().LunGetAttribute(ctx, volConfig.InternalName, "formatOptions").Return("formatOptions", nil).Times(1)
16951688
mockAPI.EXPECT().LunGetByName(ctx, volConfig.InternalName).Return(lun, nil).Times(1)
16961689
mockAPI.EXPECT().EnsureLunMapped(ctx, driver.Config.IgroupName, volConfig.InternalName).Return(1123, nil).AnyTimes()
16971690
},

storage_drivers/ontap/ontap_common.go

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2026 NetApp, Inc. All Rights Reserved.
22

33
package ontap
44

@@ -1063,10 +1063,14 @@ func getNodeSpecificFCPIgroupName(nodeName, tridentUUID string) string {
10631063
// mounted, so it should limit itself to updating access rules, initiator groups, etc. that require
10641064
// some host identity (but not locality) as well as storage controller API access.
10651065
// This function assumes that the list of data LIF IP addresses does not change between driver initialization
1066-
// and publish
1066+
// and publish.
1067+
// volConfig supplies per-volume settings from create (or import): FileSystem and FormatOptions. When FileSystem is
1068+
// non-empty it is used as-is; when empty, fstype is read from the LUN via LunGetFSType, or drivers.DefaultFileSystemType
1069+
// if that fails or returns empty. When FormatOptions is non-empty it is used as-is; when empty, format options are
1070+
// read from the LUN attribute "formatOptions" (config.FileSystemType is not consulted for fstype here).
10671071
func PublishLUN(
10681072
ctx context.Context, clientAPI api.OntapAPI, config *drivers.OntapStorageDriverConfig, ips []string,
1069-
publishInfo *tridentmodels.VolumePublishInfo, lunPath, igroupName, nodeName string,
1073+
publishInfo *tridentmodels.VolumePublishInfo, lunPath, igroupName, nodeName string, volConfig *storage.VolumeConfig,
10701074
) error {
10711075
lunMutex.Lock(lunPath)
10721076
defer lunMutex.Unlock(lunPath)
@@ -1109,27 +1113,31 @@ func PublishLUN(
11091113
}
11101114
}
11111115

1112-
// Get the fstype
1113-
fstype := drivers.DefaultFileSystemType
1114-
lunFSType, err := clientAPI.LunGetFSType(ctx, lunPath)
1115-
if err != nil || lunFSType == "" {
1116-
if err != nil {
1117-
Logc(ctx).Warnf("failed to get fstype for LUN: %v", err)
1116+
// Resolve fstype: prefer volume config (orchestrator), then LUN attribute, then driver default.
1117+
fstype := volConfig.FileSystem
1118+
if fstype == "" {
1119+
fstype, err = clientAPI.LunGetFSType(ctx, lunPath)
1120+
if err != nil || fstype == "" {
1121+
if err != nil {
1122+
Logc(ctx).WithError(err).Error("failed to get fstype for LUN")
1123+
}
1124+
Logc(ctx).WithFields(LogFields{
1125+
"LUN": lunPath,
1126+
"fstype": fstype,
1127+
}).Error("LUN attribute fstype not found, using default.")
1128+
fstype = drivers.DefaultFileSystemType
11181129
}
1119-
Logc(ctx).WithFields(LogFields{
1120-
"LUN": lunPath,
1121-
"fstype": fstype,
1122-
}).Warn("LUN attribute fstype not found, using default.")
1123-
} else {
1124-
fstype = lunFSType
11251130
}
11261131

11271132
// Get the format options
11281133
// An example of how formatOption may look like:
11291134
// "-E stride=256,stripe_width=16 -F -b 2435965"
1130-
formatOptions, err := clientAPI.LunGetAttribute(ctx, lunPath, "formatOptions")
1131-
if err != nil {
1132-
Logc(ctx).Warnf("Failed to get format options for LUN: %v", err)
1135+
formatOptions := volConfig.FormatOptions
1136+
if formatOptions == "" {
1137+
formatOptions, err = clientAPI.LunGetAttribute(ctx, lunPath, "formatOptions")
1138+
if err != nil {
1139+
Logc(ctx).WithError(err).Error("Failed to get format options for LUN")
1140+
}
11331141
}
11341142

11351143
// Get LUN Serial Number

storage_drivers/ontap/ontap_common_test.go

Lines changed: 112 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2026 NetApp, Inc. All Rights Reserved.
22

33
package ontap
44

@@ -6614,6 +6614,11 @@ func TestPublishLun(t *testing.T) {
66146614

66156615
config.SANType = sa.ISCSI
66166616

6617+
publishVolCfg := func(fileSystem, formatOptions string) *storage.VolumeConfig {
6618+
return &storage.VolumeConfig{FileSystem: fileSystem, FormatOptions: formatOptions}
6619+
}
6620+
volNoFsOrFmt := publishVolCfg("", "")
6621+
66176622
publishInfo := &tridentmodels.VolumePublishInfo{
66186623
BackendUUID: "fakeBackendUUID",
66196624
Localhost: false,
@@ -6630,7 +6635,7 @@ func TestPublishLun(t *testing.T) {
66306635
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
66316636
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
66326637

6633-
err := PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6638+
err := PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
66346639

66356640
assert.NoError(t, err)
66366641

@@ -6639,7 +6644,7 @@ func TestPublishLun(t *testing.T) {
66396644
publishInfo.Localhost = false
66406645
publishInfo.HostIQN = []string{}
66416646

6642-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6647+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
66436648

66446649
assert.Error(t, err)
66456650

@@ -6654,11 +6659,12 @@ func TestPublishLun(t *testing.T) {
66546659
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
66556660
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
66566661

6657-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6662+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
66586663

66596664
assert.NoError(t, err)
6665+
assert.Equal(t, drivers.DefaultFileSystemType, publishInfo.FilesystemType)
66606666

6661-
// Test 4 - LunGetFSType returns error
6667+
// Test 4 - LunGetAttribute returns error (fstype still from LUN)
66626668
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
66636669
publishInfo.HostIQN = []string{"host_iqn"}
66646670
mockAPI.EXPECT().LunGetFSType(ctx, lunPath).Return("fsType", nil)
@@ -6669,9 +6675,10 @@ func TestPublishLun(t *testing.T) {
66696675
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
66706676
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
66716677

6672-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6678+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
66736679

66746680
assert.NoError(t, err)
6681+
assert.Equal(t, "fsType", publishInfo.FilesystemType)
66756682

66766683
// Test 5 - No target node found
66776684
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
@@ -6681,7 +6688,7 @@ func TestPublishLun(t *testing.T) {
66816688
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
66826689
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, nil)
66836690

6684-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6691+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
66856692

66866693
assert.Error(t, err)
66876694

@@ -6699,7 +6706,7 @@ func TestPublishLun(t *testing.T) {
66996706
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName,
67006707
gomock.Any()).Return(errors.New("EnsureIgroupAdded returned error"))
67016708

6702-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6709+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
67036710

67046711
assert.Error(t, err)
67056712

@@ -6711,7 +6718,7 @@ func TestPublishLun(t *testing.T) {
67116718
errors.New("EnsureLunMapped returned error"))
67126719
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName, gomock.Any()).Return(nil)
67136720

6714-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6721+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
67156722

67166723
assert.Error(t, err)
67176724

@@ -6720,7 +6727,7 @@ func TestPublishLun(t *testing.T) {
67206727
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
67216728
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, errors.New("LunGetByName returned error"))
67226729

6723-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6730+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
67246731

67256732
assert.Error(t, err)
67266733

@@ -6729,7 +6736,7 @@ func TestPublishLun(t *testing.T) {
67296736
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
67306737
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLunNoSerial, nil)
67316738

6732-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6739+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
67336740

67346741
assert.Error(t, err)
67356742

@@ -6750,9 +6757,102 @@ func TestPublishLun(t *testing.T) {
67506757
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
67516758
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
67526759

6753-
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName)
6760+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
67546761
assert.NoError(t, err)
67556762
assert.Equal(t, tempFormatOptions, publishInfo.FormatOptions)
6763+
6764+
// Test 11 - volume FileSystem (volConfig) is "xfs", LunGetFSType should NOT be called
6765+
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
6766+
publishInfo = &tridentmodels.VolumePublishInfo{
6767+
BackendUUID: "fakeBackendUUID",
6768+
Localhost: false,
6769+
Unmanaged: true,
6770+
Nodes: nodeList,
6771+
HostIQN: []string{"host_iqn"},
6772+
}
6773+
config.FileSystemType = ""
6774+
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
6775+
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, nil)
6776+
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName, publishInfo.HostIQN[0])
6777+
mockAPI.EXPECT().EnsureLunMapped(ctx, igroupName, lunPath).Return(1111, nil)
6778+
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
6779+
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
6780+
6781+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName,
6782+
publishVolCfg("xfs", ""))
6783+
6784+
assert.NoError(t, err)
6785+
assert.Equal(t, "xfs", publishInfo.FilesystemType)
6786+
assert.Contains(t, publishInfo.MountOptions, "nouuid")
6787+
6788+
// Test 11b - FileSystem and FormatOptions from vol (as after Create); no LunGetFSType or LunGetAttribute
6789+
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
6790+
publishInfo = &tridentmodels.VolumePublishInfo{
6791+
BackendUUID: "fakeBackendUUID",
6792+
Localhost: false,
6793+
Unmanaged: true,
6794+
Nodes: nodeList,
6795+
HostIQN: []string{"host_iqn"},
6796+
}
6797+
volFmtOpts := "-b 4096 -T stride=256"
6798+
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, nil)
6799+
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName, publishInfo.HostIQN[0])
6800+
mockAPI.EXPECT().EnsureLunMapped(ctx, igroupName, lunPath).Return(1111, nil)
6801+
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
6802+
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
6803+
6804+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName,
6805+
publishVolCfg("xfs", volFmtOpts))
6806+
assert.NoError(t, err)
6807+
assert.Equal(t, "xfs", publishInfo.FilesystemType)
6808+
assert.Equal(t, volFmtOpts, publishInfo.FormatOptions)
6809+
assert.Contains(t, publishInfo.MountOptions, "nouuid")
6810+
6811+
// Test 12 - volume fstype empty, LunGetFSType returns empty string with no error, use default
6812+
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
6813+
publishInfo = &tridentmodels.VolumePublishInfo{
6814+
BackendUUID: "fakeBackendUUID",
6815+
Localhost: false,
6816+
Unmanaged: true,
6817+
Nodes: nodeList,
6818+
HostIQN: []string{"host_iqn"},
6819+
}
6820+
config.FileSystemType = ""
6821+
mockAPI.EXPECT().LunGetFSType(ctx, lunPath).Return("", nil)
6822+
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
6823+
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, nil)
6824+
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName, publishInfo.HostIQN[0])
6825+
mockAPI.EXPECT().EnsureLunMapped(ctx, igroupName, lunPath).Return(1111, nil)
6826+
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
6827+
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
6828+
6829+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
6830+
6831+
assert.NoError(t, err)
6832+
assert.Equal(t, drivers.DefaultFileSystemType, publishInfo.FilesystemType)
6833+
6834+
// Test 13 - volume fstype empty, LunGetFSType returns error, use default
6835+
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
6836+
publishInfo = &tridentmodels.VolumePublishInfo{
6837+
BackendUUID: "fakeBackendUUID",
6838+
Localhost: false,
6839+
Unmanaged: true,
6840+
Nodes: nodeList,
6841+
HostIQN: []string{"host_iqn"},
6842+
}
6843+
config.FileSystemType = ""
6844+
mockAPI.EXPECT().LunGetFSType(ctx, lunPath).Return("", errors.New("LunGetFSType returned error"))
6845+
mockAPI.EXPECT().LunGetAttribute(ctx, lunPath, "formatOptions").Return("formatOptions", nil)
6846+
mockAPI.EXPECT().LunGetByName(ctx, lunPath).Return(dummyLun, nil)
6847+
mockAPI.EXPECT().EnsureIgroupAdded(ctx, igroupName, publishInfo.HostIQN[0])
6848+
mockAPI.EXPECT().EnsureLunMapped(ctx, igroupName, lunPath).Return(1111, nil)
6849+
mockAPI.EXPECT().LunMapGetReportingNodes(ctx, igroupName, lunPath).Return([]string{"Node1"}, nil)
6850+
mockAPI.EXPECT().GetSLMDataLifs(ctx, ips, []string{"Node1"}).Return([]string{}, nil)
6851+
6852+
err = PublishLUN(ctx, mockAPI, config, ips, publishInfo, lunPath, igroupName, iSCSINodeName, volNoFsOrFmt)
6853+
6854+
assert.NoError(t, err)
6855+
assert.Equal(t, drivers.DefaultFileSystemType, publishInfo.FilesystemType)
67566856
}
67576857

67586858
func TestValidateSANDriver(t *testing.T) {

storage_drivers/ontap/ontap_san.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 NetApp, Inc. All Rights Reserved.
1+
// Copyright 2026 NetApp, Inc. All Rights Reserved.
22

33
package ontap
44

@@ -1039,7 +1039,7 @@ func (d *SANStorageDriver) Publish(
10391039
nodeName = iSCSINodeName
10401040
}
10411041

1042-
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, nodeName)
1042+
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, nodeName, volConfig)
10431043
if err != nil {
10441044
return fmt.Errorf("error publishing %s driver: %v", d.Name(), err)
10451045
}

0 commit comments

Comments
 (0)