Skip to content

Commit 850da22

Browse files
committed
Azure - do not use 0 zone or empty string for zone when creating PVs
1 parent 52243de commit 850da22

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
8585
klog.V(4).Infof("azureDisk - creating new managed Name:%s StorageAccountType:%s Size:%v", options.DiskName, options.StorageAccountType, options.SizeGB)
8686

8787
var createZones *[]string
88-
if len(options.AvailabilityZone) > 0 {
88+
if len(options.AvailabilityZone) > 0 && options.AvailabilityZone != "0" {
8989
zoneList := []string{c.common.cloud.GetZoneID(options.AvailabilityZone)}
9090
createZones = &zoneList
9191
}
@@ -161,13 +161,16 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
161161
model := compute.Disk{
162162
Location: &c.common.location,
163163
Tags: newTags,
164-
Zones: createZones,
165164
Sku: &compute.DiskSku{
166165
Name: diskSku,
167166
},
168167
DiskProperties: &diskProperties,
169168
}
170169

170+
if createZones != nil && len(*createZones) > 0 {
171+
model.Zones = createZones
172+
}
173+
171174
if options.ResourceGroup == "" {
172175
options.ResourceGroup = c.common.resourceGroup
173176
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ func (p *Provider) CreatePD(zone string) (string, error) {
7272
PVCName: pdName,
7373
SizeGB: 1,
7474
Tags: nil,
75-
AvailabilityZone: zone,
7675
DiskIOPSReadWrite: "",
7776
DiskMBpsReadWrite: "",
7877
}
78+
79+
// do not use blank zone definition
80+
if len(zone) > 0 && zone != "0" {
81+
volumeOptions.AvailabilityZone = zone
82+
}
7983
return p.azureCloud.CreateManagedDisk(volumeOptions)
8084
}
8185

0 commit comments

Comments
 (0)