mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Get availability zone for VirtualMachineScaleSetVM
This commit is contained in:
parent
af1875fca6
commit
a29fabe20d
@ -213,9 +213,6 @@ func (ss *scaleSet) GetInstanceTypeByNodeName(name string) (string, error) {
|
|||||||
|
|
||||||
// GetZoneByNodeName gets availability zone for the specified node. If the node is not running
|
// GetZoneByNodeName gets availability zone for the specified node. If the node is not running
|
||||||
// with availability zone, then it returns fault domain.
|
// with availability zone, then it returns fault domain.
|
||||||
// TODO(feiskyer): Add availability zone support of VirtualMachineScaleSetVM
|
|
||||||
// after it is released in Azure Go SDK.
|
|
||||||
// Refer https://github.com/Azure/azure-sdk-for-go/pull/2224.
|
|
||||||
func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) {
|
func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) {
|
||||||
managedByAS, err := ss.isNodeManagedByAvailabilitySet(name)
|
managedByAS, err := ss.isNodeManagedByAvailabilitySet(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -232,14 +229,25 @@ func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) {
|
|||||||
return cloudprovider.Zone{}, err
|
return cloudprovider.Zone{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if vm.InstanceView != nil && vm.InstanceView.PlatformFaultDomain != nil {
|
var failureDomain string
|
||||||
return cloudprovider.Zone{
|
if vm.Zones != nil && len(*vm.Zones) > 0 {
|
||||||
FailureDomain: strconv.Itoa(int(*vm.InstanceView.PlatformFaultDomain)),
|
// Get availability zone for the node.
|
||||||
Region: *vm.Location,
|
zones := *vm.Zones
|
||||||
}, nil
|
zoneID, err := strconv.Atoi(zones[0])
|
||||||
|
if err != nil {
|
||||||
|
return cloudprovider.Zone{}, fmt.Errorf("failed to parse zone %q: %v", zones, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
failureDomain = ss.makeZone(zoneID)
|
||||||
|
} else if vm.InstanceView != nil && vm.InstanceView.PlatformFaultDomain != nil {
|
||||||
|
// Availability zone is not used for the node, falling back to fault domain.
|
||||||
|
failureDomain = strconv.Itoa(int(*vm.InstanceView.PlatformFaultDomain))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloudprovider.Zone{}, nil
|
return cloudprovider.Zone{
|
||||||
|
FailureDomain: failureDomain,
|
||||||
|
Region: *vm.Location,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPrimaryVMSetName returns the VM set name depending on the configured vmType.
|
// GetPrimaryVMSetName returns the VM set name depending on the configured vmType.
|
||||||
|
Loading…
Reference in New Issue
Block a user