Skip to content

Commit a892d17

Browse files
Remove targets from publish context (#565)
Co-authored-by: Christian Coffield <christian_coffield@dell.com>
1 parent 311be04 commit a892d17

File tree

9 files changed

+685
-319
lines changed

9 files changed

+685
-319
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Dockerfile-debug
77
# test directories and artifacts
88
service/c.out
99
service/test/
10+
vendor
1011

1112
# IDE
1213
.idea

pkg/controller/controller_test.go

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,15 +3082,8 @@ var _ = ginkgo.Describe("CSIControllerService", func() {
30823082
gomega.Expect(err).To(gomega.BeNil())
30833083
gomega.Expect(res).To(gomega.Equal(&csi.ControllerPublishVolumeResponse{
30843084
PublishContext: map[string]string{
3085-
"PORTAL0": "192.168.1.1:3260",
3086-
"TARGET0": "iqn",
3087-
"NVMEFCPORTAL0": "nn-0x58ccf090c9200c22:pn-0x58ccf091492b0c22",
3088-
"NVMEFCTARGET0": "nqn",
3089-
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3090-
"LUN_ADDRESS": "1",
3091-
"FCWWPN0": "58ccf09348a003a3",
3092-
"NVMETCPTARGET0": "nqn",
3093-
"NVMETCPPORTAL0": "192.168.1.1:4420",
3085+
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3086+
"LUN_ADDRESS": "1",
30943087
},
30953088
}))
30963089
})
@@ -3280,12 +3273,8 @@ var _ = ginkgo.Describe("CSIControllerService", func() {
32803273
gomega.Expect(err).To(gomega.BeNil())
32813274
gomega.Expect(res).To(gomega.Equal(&csi.ControllerPublishVolumeResponse{
32823275
PublishContext: map[string]string{
3283-
"PORTAL0": "192.168.1.1:3260",
3284-
"TARGET0": "iqn",
3285-
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3286-
"LUN_ADDRESS": "1",
3287-
"NVMETCPPORTAL0": "192.168.1.1:4420",
3288-
"NVMETCPTARGET0": "",
3276+
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3277+
"LUN_ADDRESS": "1",
32893278
},
32903279
}))
32913280
})
@@ -3398,12 +3387,8 @@ var _ = ginkgo.Describe("CSIControllerService", func() {
33983387
gomega.Expect(err).To(gomega.BeNil())
33993388
gomega.Expect(res).To(gomega.Equal(&csi.ControllerPublishVolumeResponse{
34003389
PublishContext: map[string]string{
3401-
"PORTAL0": "192.168.1.1:3260",
3402-
"TARGET0": "iqn",
3403-
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3404-
"LUN_ADDRESS": "1",
3405-
"NVMETCPPORTAL0": "192.168.1.1:4420",
3406-
"NVMETCPTARGET0": "",
3390+
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3391+
"LUN_ADDRESS": "1",
34073392
},
34083393
}))
34093394
})
@@ -3505,12 +3490,8 @@ var _ = ginkgo.Describe("CSIControllerService", func() {
35053490
gomega.Expect(err).To(gomega.BeNil())
35063491
gomega.Expect(res).To(gomega.Equal(&csi.ControllerPublishVolumeResponse{
35073492
PublishContext: map[string]string{
3508-
"PORTAL0": "192.168.1.1:3260",
3509-
"TARGET0": "iqn",
3510-
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3511-
"LUN_ADDRESS": "2",
3512-
"NVMETCPPORTAL0": "192.168.1.1:4420",
3513-
"NVMETCPTARGET0": "",
3493+
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3494+
"LUN_ADDRESS": "2",
35143495
},
35153496
}))
35163497
})
@@ -3603,22 +3584,10 @@ var _ = ginkgo.Describe("CSIControllerService", func() {
36033584
gomega.Expect(err).To(gomega.BeNil())
36043585
gomega.Expect(res).To(gomega.Equal(&csi.ControllerPublishVolumeResponse{
36053586
PublishContext: map[string]string{
3606-
"PORTAL0": "192.168.1.1:3260",
3607-
"TARGET0": "iqn",
3608-
"NVMEFCPORTAL0": "nn-0x58ccf090c9200c22:pn-0x58ccf091492b0c22",
3609-
"NVMEFCTARGET0": "nqn",
3610-
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3611-
"LUN_ADDRESS": "1",
3612-
"FCWWPN0": "58ccf09348a003a3",
3613-
"NVMETCPTARGET0": "nqn",
3614-
"NVMETCPPORTAL0": "192.168.1.1:4420",
3615-
"REMOTE_DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3616-
"REMOTE_LUN_ADDRESS": "1",
3617-
"REMOTE_FCWWPN0": "58ccf09348a00333",
3618-
"REMOTE_TARGET0": "iqn.2015-10.com.dell:dellemc-powerstore-apm00223",
3619-
"REMOTE_NVMEFCTARGET0": "nqn.1988-11.com.dell:powerstore:00:303030303030ABCDEFGH",
3620-
"REMOTE_PORTAL0": "192.168.1.2:3260",
3621-
"REMOTE_NVMEFCPORTAL0": "nn-0x58ccf090c9200c33:pn-0x58ccf091492b0c33",
3587+
"DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3588+
"LUN_ADDRESS": "1",
3589+
"REMOTE_DEVICE_WWN": "68ccf098003ceb5e4577a20be6d11bf9",
3590+
"REMOTE_LUN_ADDRESS": "1",
36223591
},
36233592
}))
36243593
})

pkg/controller/publisher.go

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package controller
2020

2121
import (
2222
"context"
23-
"errors"
2423
"fmt"
2524
"strconv"
2625
"strings"
@@ -84,7 +83,6 @@ func (s *SCSIPublisher) Publish(ctx context.Context, publishContext map[string]s
8483
"failed to get mapping for volume with ID '%s': %s", volume.ID, err.Error())
8584
}
8685

87-
err = s.addTargetsInfoToPublishContext(publishContext, volume.ApplianceID, client, isRemote)
8886
if err != nil {
8987
return nil, status.Errorf(codes.Internal, "could not get scsi Targets: %s", err.Error())
9088
}
@@ -161,75 +159,14 @@ func (s *SCSIPublisher) addLUNIDToPublishContext(
161159
isRemote bool,
162160
) {
163161
if !isRemote {
164-
publishContext[identifiers.PublishContextDeviceWWN] = strings.TrimPrefix(volume.Wwn, identifiers.WWNPrefix)
165-
publishContext[identifiers.PublishContextLUNAddress] = strconv.FormatInt(mapping.LogicalUnitNumber, 10)
162+
publishContext[identifiers.TargetMapDeviceWWN] = strings.TrimPrefix(volume.Wwn, identifiers.WWNPrefix)
163+
publishContext[identifiers.TargetMapLUNAddress] = strconv.FormatInt(mapping.LogicalUnitNumber, 10)
166164
} else {
167-
publishContext[identifiers.PublishContextRemoteDeviceWWN] = strings.TrimPrefix(volume.Wwn, identifiers.WWNPrefix)
168-
publishContext[identifiers.PublishContextRemoteLUNAddress] = strconv.FormatInt(mapping.LogicalUnitNumber, 10)
165+
publishContext[identifiers.TargetMapRemoteDeviceWWN] = strings.TrimPrefix(volume.Wwn, identifiers.WWNPrefix)
166+
publishContext[identifiers.TargetMapRemoteLUNAddress] = strconv.FormatInt(mapping.LogicalUnitNumber, 10)
169167
}
170168
}
171169

172-
func (s *SCSIPublisher) addTargetsInfoToPublishContext(
173-
publishContext map[string]string, volumeApplianceID string, client gopowerstore.Client, isRemote bool,
174-
) error {
175-
iscsiPortalsKey := identifiers.PublishContextISCSIPortalsPrefix
176-
iscsiTargetsKey := identifiers.PublishContextISCSITargetsPrefix
177-
fcWwpnKey := identifiers.PublishContextFCWWPNPrefix
178-
nvmeFcPortalsKey := identifiers.PublishContextNVMEFCPortalsPrefix
179-
nvmeFcTargetsKey := identifiers.PublishContextNVMEFCTargetsPrefix
180-
nvmeTCPPortalsKey := identifiers.PublishContextNVMETCPPortalsPrefix
181-
nvmeTCPTargetsKey := identifiers.PublishContextNVMETCPTargetsPrefix
182-
if isRemote {
183-
iscsiPortalsKey = identifiers.PublishContextRemoteISCSIPortalsPrefix
184-
iscsiTargetsKey = identifiers.PublishContextRemoteISCSITargetsPrefix
185-
fcWwpnKey = identifiers.PublishContextRemoteFCWWPNPrefix
186-
nvmeFcPortalsKey = identifiers.PublishContextRemoteNVMEFCPortalsPrefix
187-
nvmeFcTargetsKey = identifiers.PublishContextRemoteNVMEFCTargetsPrefix
188-
nvmeTCPPortalsKey = identifiers.PublishContextRemoteNVMETCPPortalsPrefix
189-
nvmeTCPTargetsKey = identifiers.PublishContextRemoteNVMETCPTargetsPrefix
190-
}
191-
192-
iscsiTargetsInfo, err := identifiers.GetISCSITargetsInfoFromStorage(client, volumeApplianceID)
193-
if err != nil {
194-
log.Error("error unable to get iSCSI targets from array", err)
195-
}
196-
for i, t := range iscsiTargetsInfo {
197-
publishContext[fmt.Sprintf("%s%d", iscsiPortalsKey, i)] = t.Portal
198-
publishContext[fmt.Sprintf("%s%d", iscsiTargetsKey, i)] = t.Target
199-
}
200-
fcTargetsInfo, err := identifiers.GetFCTargetsInfoFromStorage(client, volumeApplianceID)
201-
if err != nil {
202-
log.Error("error unable to get FC targets from array", err)
203-
}
204-
for i, t := range fcTargetsInfo {
205-
publishContext[fmt.Sprintf("%s%d", fcWwpnKey, i)] = t.WWPN
206-
}
207-
208-
nvmefcTargetInfo, err := identifiers.GetNVMEFCTargetInfoFromStorage(client, volumeApplianceID)
209-
if err != nil {
210-
log.Error("error unable to get NVMeFC targets from array", err)
211-
}
212-
for i, t := range nvmefcTargetInfo {
213-
publishContext[fmt.Sprintf("%s%d", nvmeFcPortalsKey, i)] = t.Portal
214-
publishContext[fmt.Sprintf("%s%d", nvmeFcTargetsKey, i)] = t.Target
215-
}
216-
217-
nvmetcpTargetInfo, err := identifiers.GetNVMETCPTargetsInfoFromStorage(client, volumeApplianceID)
218-
if err != nil {
219-
log.Error("error unable to get NVMeTCP targets from array", err)
220-
}
221-
for i, t := range nvmetcpTargetInfo {
222-
publishContext[fmt.Sprintf("%s%d", nvmeTCPPortalsKey, i)] = t.Portal
223-
publishContext[fmt.Sprintf("%s%d", nvmeTCPTargetsKey, i)] = t.Target
224-
}
225-
226-
// If the system is not capable of any protocol, then we will through the error
227-
if len(iscsiTargetsInfo) == 0 && len(fcTargetsInfo) == 0 && len(nvmefcTargetInfo) == 0 && len(nvmetcpTargetInfo) == 0 {
228-
return errors.New("unable to get targets for any protocol")
229-
}
230-
return nil
231-
}
232-
233170
// NfsPublisher implementation of VolumePublisher for NFS volumes
234171
type NfsPublisher struct {
235172
// ExternalAccess used to set custom ip to be added to the NFS Export 'hosts' list

pkg/controller/publisher_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ func TestVolumePublisher_Publish(t *testing.T) {
140140
Return([]gopowerstore.HostVolumeMapping{{HostID: validHostID, LogicalUnitNumber: 1}}, nil).Once()
141141

142142
_, err := sp.Publish(context.Background(), make(map[string]string), nil, clientMock, validNodeID, validBaseVolID, false)
143-
assert.Error(t, err)
144-
assert.Contains(t, err.Error(), e.Error())
143+
// as of 1.16, logic for finding targets is handled in the stager
144+
assert.Nil(t, err)
145145
})
146146
})
147147

pkg/identifiers/identifiers.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,46 +136,46 @@ const (
136136
AutoDetectTransport TransportType = "AUTO"
137137
// NoneTransport indicates that no SCSI transport protocol needed
138138
NoneTransport TransportType = "NONE"
139-
// PublishContextDeviceWWN indicates publish context device wwn
140-
PublishContextDeviceWWN = "DEVICE_WWN"
141-
// PublishContextLUNAddress indicates publish context LUN address
142-
PublishContextLUNAddress = "LUN_ADDRESS"
143-
// PublishContextISCSIPortalsPrefix indicates publish context iSCSI portals prefix
144-
PublishContextISCSIPortalsPrefix = "PORTAL"
145-
// PublishContextISCSITargetsPrefix indicates publish context iSCSI targets prefix
146-
PublishContextISCSITargetsPrefix = "TARGET"
147-
// PublishContextNVMETCPPortalsPrefix indicates publish context NVMeTCP portals prefix
148-
PublishContextNVMETCPPortalsPrefix = "NVMETCPPORTAL"
149-
// PublishContextNVMETCPTargetsPrefix indicates publish context NVMe targets prefix
150-
PublishContextNVMETCPTargetsPrefix = "NVMETCPTARGET"
151-
// PublishContextNVMEFCPortalsPrefix indicates publish context NVMe targets prefix
152-
PublishContextNVMEFCPortalsPrefix = "NVMEFCPORTAL"
153-
// PublishContextNVMEFCTargetsPrefix indicates publish context NVMe targets prefix
154-
PublishContextNVMEFCTargetsPrefix = "NVMEFCTARGET"
139+
// TargetMapDeviceWWN indicates target map device wwn
140+
TargetMapDeviceWWN = "DEVICE_WWN"
141+
// TargetMapLUNAddress indicates publish context LUN address
142+
TargetMapLUNAddress = "LUN_ADDRESS"
143+
// TargetMapISCSIPortalsPrefix indicates target map iSCSI portals prefix
144+
TargetMapISCSIPortalsPrefix = "PORTAL"
145+
// TargetMapISCSITargetsPrefix indicates target map iSCSI targets prefix
146+
TargetMapISCSITargetsPrefix = "TARGET"
147+
// TargetMapNVMETCPPortalsPrefix indicates target map NVMeTCP portals prefix
148+
TargetMapNVMETCPPortalsPrefix = "NVMETCPPORTAL"
149+
// TargetMapNVMETCPTargetsPrefix indicates target mapNVMe targets prefix
150+
TargetMapNVMETCPTargetsPrefix = "NVMETCPTARGET"
151+
// TargetMapNVMEFCPortalsPrefix indicates publish context NVMe targets prefix
152+
TargetMapNVMEFCPortalsPrefix = "NVMEFCPORTAL"
153+
// TargetMapNVMEFCTargetsPrefix indicates target map NVMe targets prefix
154+
TargetMapNVMEFCTargetsPrefix = "NVMEFCTARGET"
155155
// NVMETCPTransport indicates that NVMe/TCP is chosen as the transport protocol
156156
NVMETCPTransport TransportType = "NVMETCP"
157157
// NVMEFCTransport indicates that NVMe/FC is chosen as the transport protocol
158158
NVMEFCTransport TransportType = "NVMEFC"
159-
// PublishContextFCWWPNPrefix indicates publish context FC WWPN prefix
160-
PublishContextFCWWPNPrefix = "FCWWPN"
161-
// PublishContextRemoteDeviceWWN indicates publish context device wwn of remote device
162-
PublishContextRemoteDeviceWWN = "REMOTE_DEVICE_WWN"
163-
// PublishContextRemoteLUNAddress indicates publish context LUN address of remote device
164-
PublishContextRemoteLUNAddress = "REMOTE_LUN_ADDRESS"
165-
// PublishContextRemoteISCSIPortalsPrefix indicates publish context iSCSI portals prefix of remote array
166-
PublishContextRemoteISCSIPortalsPrefix = "REMOTE_PORTAL"
167-
// PublishContextRemoteISCSITargetsPrefix indicates publish context iSCSI targets prefix of remote array
168-
PublishContextRemoteISCSITargetsPrefix = "REMOTE_TARGET"
169-
// PublishContextRemoteNVMETCPPortalsPrefix indicates publish context NVMeTCP portals prefix of remote array
170-
PublishContextRemoteNVMETCPPortalsPrefix = "REMOTE_NVMETCPPORTAL"
171-
// PublishContextRemoteNVMETCPTargetsPrefix indicates publish context NVMe targets prefix of remote array
172-
PublishContextRemoteNVMETCPTargetsPrefix = "REMOTE_NVMETCPTARGET"
173-
// PublishContextRemoteNVMEFCPortalsPrefix indicates publish context NVMe targets prefix of remote array
174-
PublishContextRemoteNVMEFCPortalsPrefix = "REMOTE_NVMEFCPORTAL"
175-
// PublishContextRemoteNVMEFCTargetsPrefix indicates publish context NVMe targets prefix of remote array
176-
PublishContextRemoteNVMEFCTargetsPrefix = "REMOTE_NVMEFCTARGET"
177-
// PublishContextRemoteFCWWPNPrefix indicates publish context FC WWPN prefix of remote array
178-
PublishContextRemoteFCWWPNPrefix = "REMOTE_FCWWPN"
159+
// TargetMapFCWWPNPrefix indicates target map FC WWPN prefix
160+
TargetMapFCWWPNPrefix = "FCWWPN"
161+
// TargetMapRemoteDeviceWWN indicates target map device wwn of remote device
162+
TargetMapRemoteDeviceWWN = "REMOTE_DEVICE_WWN"
163+
// TargetMapRemoteLUNAddress indicates target map LUN address of remote device
164+
TargetMapRemoteLUNAddress = "REMOTE_LUN_ADDRESS"
165+
// TargetMapRemoteISCSIPortalsPrefix indicates target map iSCSI portals prefix of remote array
166+
TargetMapRemoteISCSIPortalsPrefix = "REMOTE_PORTAL"
167+
// TargetMapRemoteISCSITargetsPrefix indicates target map iSCSI targets prefix of remote array
168+
TargetMapRemoteISCSITargetsPrefix = "REMOTE_TARGET"
169+
// TargetMapRemoteNVMETCPPortalsPrefix indicates target map NVMeTCP portals prefix of remote array
170+
TargetMapRemoteNVMETCPPortalsPrefix = "REMOTE_NVMETCPPORTAL"
171+
// TargetMapRemoteNVMETCPTargetsPrefix indicates target map NVMe targets prefix of remote array
172+
TargetMapRemoteNVMETCPTargetsPrefix = "REMOTE_NVMETCPTARGET"
173+
// TargetMapRemoteNVMEFCPortalsPrefix indicates target map NVMe targets prefix of remote array
174+
TargetMapRemoteNVMEFCPortalsPrefix = "REMOTE_NVMEFCPORTAL"
175+
// TargetMapRemoteNVMEFCTargetsPrefix indicates target map NVMe targets prefix of remote array
176+
TargetMapRemoteNVMEFCTargetsPrefix = "REMOTE_NVMEFCTARGET"
177+
// TargetMapRemoteFCWWPNPrefix indicates target map FC WWPN prefix of remote array
178+
TargetMapRemoteFCWWPNPrefix = "REMOTE_FCWWPN"
179179
// WWNPrefix indicates WWN prefix
180180
WWNPrefix = "naa."
181181
// SyncMode indicates Synchronous Replication

pkg/node/node.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ func (s *Service) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeR
313313
return nil, status.Errorf(codes.Internal, "can't find array with ID %s", arrayID)
314314
}
315315

316+
client := arr.GetClient()
317+
316318
var stager VolumeStager
317319
if protocol == "nfs" {
318320
stager = &NFSStager{
@@ -328,7 +330,7 @@ func (s *Service) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeR
328330
}
329331
}
330332

331-
response, err := stager.Stage(ctx, req, logFields, s.Fs, id, false)
333+
response, err := stager.Stage(ctx, req, logFields, s.Fs, id, false, client)
332334
if err != nil {
333335
return nil, err
334336
}
@@ -339,7 +341,7 @@ func (s *Service) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeR
339341
if nfs.IsNFSVolumeID(req.VolumeId) {
340342
req.StagingTargetPath = nfs.NfsExportDirectory
341343
}
342-
response, err = stager.Stage(ctx, req, logFields, s.Fs, remoteVolumeID, true)
344+
response, err = stager.Stage(ctx, req, logFields, s.Fs, remoteVolumeID, true, client)
343345
}
344346

345347
return response, err

0 commit comments

Comments
 (0)