Skip to content

Commit 03a927e

Browse files
authored
Merge pull request kubernetes#90535 from gnufied/azure-zone-e2e
Azure - fix create azure disk PV in regions that don't have zones
2 parents dc6c640 + 9d4329f commit 03a927e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

Lines changed: 9 additions & 4 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
87+
var createZones []string
8888
if len(options.AvailabilityZone) > 0 {
89-
zoneList := []string{c.common.cloud.GetZoneID(options.AvailabilityZone)}
90-
createZones = &zoneList
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
@@ -161,13 +163,16 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
161163
model := compute.Disk{
162164
Location: &c.common.location,
163165
Tags: newTags,
164-
Zones: createZones,
165166
Sku: &compute.DiskSku{
166167
Name: diskSku,
167168
},
168169
DiskProperties: &diskProperties,
169170
}
170171

172+
if len(createZones) > 0 {
173+
model.Zones = &createZones
174+
}
175+
171176
if options.ResourceGroup == "" {
172177
options.ResourceGroup = c.common.resourceGroup
173178
}

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 {
81+
volumeOptions.AvailabilityZone = zone
82+
}
7983
return p.azureCloud.CreateManagedDisk(volumeOptions)
8084
}
8185

0 commit comments

Comments
 (0)