Skip to content

Commit 3d4124f

Browse files
authored
Merge pull request kubernetes#68108 from wenjun93/iscsiVol
add lun info when construct iscsi volumeSpec from mountPath
2 parents 5fe9101 + 562e5c6 commit 3d4124f

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
@@ -235,13 +235,22 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
235235
if err != nil {
236236
return nil, err
237237
}
238+
arr := strings.Split(device, "-lun-")
239+
if len(arr) < 2 {
240+
return nil, fmt.Errorf("failed to retrieve lun from globalPDPath: %v", globalPDPath)
241+
}
242+
lun, err := strconv.Atoi(arr[1])
243+
if err != nil {
244+
return nil, err
245+
}
238246
iface, _ := extractIface(globalPDPath)
239247
iscsiVolume := &v1.Volume{
240248
Name: volumeName,
241249
VolumeSource: v1.VolumeSource{
242250
ISCSI: &v1.ISCSIVolumeSource{
243251
TargetPortal: bkpPortal,
244252
IQN: iqn,
253+
Lun: int32(lun),
245254
ISCSIInterface: iface,
246255
},
247256
},

0 commit comments

Comments
 (0)