Skip to content

Commit 9d4329f

Browse files
committed
Check for empty zone string
1 parent 850da22 commit 9d4329f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_managedDiskController.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
8484
var err error
8585
klog.V(4).Infof("azureDisk - creating new managed Name:%s StorageAccountType:%s Size:%v", options.DiskName, options.StorageAccountType, options.SizeGB)
8686

87-
var createZones *[]string
88-
if len(options.AvailabilityZone) > 0 && options.AvailabilityZone != "0" {
89-
zoneList := []string{c.common.cloud.GetZoneID(options.AvailabilityZone)}
90-
createZones = &zoneList
87+
var createZones []string
88+
if len(options.AvailabilityZone) > 0 {
89+
requestedZone := c.common.cloud.GetZoneID(options.AvailabilityZone)
90+
if requestedZone != "" {
91+
createZones = append(createZones, requestedZone)
92+
}
9193
}
9294

9395
// insert original tags to newTags
@@ -167,8 +169,8 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
167169
DiskProperties: &diskProperties,
168170
}
169171

170-
if createZones != nil && len(*createZones) > 0 {
171-
model.Zones = createZones
172+
if len(createZones) > 0 {
173+
model.Zones = &createZones
172174
}
173175

174176
if options.ResourceGroup == "" {

test/e2e/framework/providers/azure/azure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (p *Provider) CreatePD(zone string) (string, error) {
7777
}
7878

7979
// do not use blank zone definition
80-
if len(zone) > 0 && zone != "0" {
80+
if len(zone) > 0 {
8181
volumeOptions.AvailabilityZone = zone
8282
}
8383
return p.azureCloud.CreateManagedDisk(volumeOptions)

0 commit comments

Comments
 (0)