Merge pull request #65258 from ddebroy/ddebroy-ebs1

Automatic merge from submit-queue (batch tested with PRs 65164, 65258). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Query candidate zones for EBS when zone/zones not passed

**What this PR does / why we need it**:
This PR skips invoking `getCandidateZonesForDynamicVolume` to query EC2 zones of instances when zone/zones is present.

/sig storage

**Release note**:
```
none
```
This commit is contained in:
Kubernetes Submit Queue 2018-06-25 14:44:08 -07:00 committed by GitHub
commit 7f23a743e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2134,13 +2134,13 @@ func (c *Cloud) DetachDisk(diskName KubernetesVolumeID, nodeName types.NodeName)
// CreateDisk implements Volumes.CreateDisk
func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (KubernetesVolumeID, error) {
allZones, err := c.getCandidateZonesForDynamicVolume()
if err != nil {
return "", fmt.Errorf("error querying for all zones: %v", err)
}
var createAZ string
if !volumeOptions.ZonePresent && !volumeOptions.ZonesPresent {
// querry for candidate zones only if zone parameters absent
allZones, err := c.getCandidateZonesForDynamicVolume()
if err != nil {
return "", fmt.Errorf("error querying for all zones: %v", err)
}
createAZ = volumeutil.ChooseZoneForVolume(allZones, volumeOptions.PVCName)
}
if !volumeOptions.ZonePresent && volumeOptions.ZonesPresent {