Merge pull request #68108 from wenjun93/iscsiVol

add lun info when construct iscsi volumeSpec from mountPath
This commit is contained in:
Kubernetes Prow Robot 2019-06-09 20:45:06 -07:00 committed by GitHub
commit 3d4124f2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -235,6 +235,14 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
if err != nil {
return nil, err
}
arr := strings.Split(device, "-lun-")
if len(arr) < 2 {
return nil, fmt.Errorf("failed to retrieve lun from globalPDPath: %v", globalPDPath)
}
lun, err := strconv.Atoi(arr[1])
if err != nil {
return nil, err
}
iface, _ := extractIface(globalPDPath)
iscsiVolume := &v1.Volume{
Name: volumeName,
@ -242,6 +250,7 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
ISCSI: &v1.ISCSIVolumeSource{
TargetPortal: bkpPortal,
IQN: iqn,
Lun: int32(lun),
ISCSIInterface: iface,
},
},