Skip to content

Commit 562e5c6

Browse files
author
wenjgao
committed
add lun info when construct iscsi volumeSpec from mountPath
1 parent 07f68ea commit 562e5c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/volume/iscsi/iscsi.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,22 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
231231
if err != nil {
232232
return nil, err
233233
}
234+
arr := strings.Split(device, "-lun-")
235+
if len(arr) < 2 {
236+
return nil, fmt.Errorf("failed to retrieve lun from globalPDPath: %v", globalPDPath)
237+
}
238+
lun, err := strconv.Atoi(arr[1])
239+
if err != nil {
240+
return nil, err
241+
}
234242
iface, _ := extractIface(globalPDPath)
235243
iscsiVolume := &v1.Volume{
236244
Name: volumeName,
237245
VolumeSource: v1.VolumeSource{
238246
ISCSI: &v1.ISCSIVolumeSource{
239247
TargetPortal: bkpPortal,
240248
IQN: iqn,
249+
Lun: int32(lun),
241250
ISCSIInterface: iface,
242251
},
243252
},

0 commit comments

Comments
 (0)