Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Support adding disks to more than one scsi adapter Fixes kubernetes#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ritesh H Shukla committed Mar 2, 2017
1 parent f41f18b commit 35e372e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/cloudprovider/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,15 @@ func (vs *VSphere) AttachDisk(vmDiskPath string, nodeName k8stypes.NodeName) (di
return "", "", err
}

scsiController = getSCSIController(vmDevices, vs.cfg.Disk.SCSIControllerType)
// Get VM device list
_, vmDevices, _, _, err := getVirtualMachineDevices(vs.cfg, ctx, vs.client, vSphereInstance)
if err != nil {
glog.Errorf("cannot get vmDevices for VM err=%s", err)
return "", "", fmt.Errorf("cannot get vmDevices for VM err=%s", err)
}

scsiControllersOfRequiredType := getSCSIControllersOfType(vmDevices, diskControllerType)
scsiController := getAvailableSCSIController(scsiControllersOfRequiredType)
if scsiController == nil {
glog.Errorf("cannot find SCSI controller in VM")
// attempt clean up of scsi controller
Expand Down Expand Up @@ -1009,22 +1017,15 @@ func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeNam
}

func checkDiskAttached(volPath string, vmdevices object.VirtualDeviceList, dc *object.Datacenter, client *govmomi.Client) (bool, error) {
virtualDiskControllerKey, err := getVirtualDiskControllerKey(volPath, vmdevices, dc, client)
_, err := getVirtualDiskControllerKey(volPath, vmdevices, dc, client)
if err != nil {
if err == ErrNoDevicesFound {
return false, nil
}
glog.Errorf("Failed to check whether disk is attached. err: %s", err)
return false, err
}
for _, controllerType := range supportedSCSIControllerType {
controllerkey, _ := getControllerKey(controllerType, vmdevices)
if controllerkey == virtualDiskControllerKey {
return true, nil
}
}
return false, ErrNonSupportedControllerType

return true, nil
}

// Returns the object key that denotes the controller object to which vmdk is attached.
Expand Down

0 comments on commit 35e372e

Please sign in to comment.