Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure - fix create azure disk PV in regions that don't have zones #90535

Merged
merged 2 commits into from May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -84,10 +84,12 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
var err error
klog.V(4).Infof("azureDisk - creating new managed Name:%s StorageAccountType:%s Size:%v", options.DiskName, options.StorageAccountType, options.SizeGB)

var createZones *[]string
var createZones []string
if len(options.AvailabilityZone) > 0 {
zoneList := []string{c.common.cloud.GetZoneID(options.AvailabilityZone)}
createZones = &zoneList
requestedZone := c.common.cloud.GetZoneID(options.AvailabilityZone)
if requestedZone != "" {
createZones = append(createZones, requestedZone)
}
}

// insert original tags to newTags
Expand Down Expand Up @@ -161,13 +163,16 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
model := compute.Disk{
Location: &c.common.location,
Tags: newTags,
Zones: createZones,
Sku: &compute.DiskSku{
Name: diskSku,
},
DiskProperties: &diskProperties,
}

if len(createZones) > 0 {
model.Zones = &createZones
}

if options.ResourceGroup == "" {
options.ResourceGroup = c.common.resourceGroup
}
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/framework/providers/azure/azure.go
Expand Up @@ -72,10 +72,14 @@ func (p *Provider) CreatePD(zone string) (string, error) {
PVCName: pdName,
SizeGB: 1,
Tags: nil,
AvailabilityZone: zone,
DiskIOPSReadWrite: "",
DiskMBpsReadWrite: "",
}

// do not use blank zone definition
if len(zone) > 0 {
volumeOptions.AvailabilityZone = zone
}
return p.azureCloud.CreateManagedDisk(volumeOptions)
}

Expand Down