Fix nil pointer dereference in the azure provider

PlatformFaultDomain in the VM properties returned by Azure will be nil
if the VM is not part of an availability set. Use to.Int32() from the
Azure SDK to safely retrieve its value.
This commit is contained in:
Vilmos Nebehaj
2019-12-05 14:33:59 -08:00
parent bd4c9a2263
commit 3fa070ad38

View File

@@ -463,7 +463,7 @@ func (as *availabilitySet) GetZoneByNodeName(name string) (cloudprovider.Zone, e
failureDomain = as.makeZone(to.String(vm.Location), zoneID)
} else {
// Availability zone is not used for the node, falling back to fault domain.
failureDomain = strconv.Itoa(int(*vm.VirtualMachineProperties.InstanceView.PlatformFaultDomain))
failureDomain = strconv.Itoa(int(to.Int32(vm.VirtualMachineProperties.InstanceView.PlatformFaultDomain)))
}
zone := cloudprovider.Zone{