@@ -39,11 +39,10 @@ var (
39
39
// ErrorNotVmssInstance indicates an instance is not belongint to any vmss.
40
40
ErrorNotVmssInstance = errors .New ("not a vmss instance" )
41
41
42
- scaleSetNameRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)` )
43
- resourceGroupRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(?:.*)/virtualMachines(?:.*)` )
44
- vmssNicResourceGroupRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(?:.*)/virtualMachines/(?:.*)/networkInterfaces/(?:.*)` )
45
- vmssMachineIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s"
46
- vmssIPConfigurationRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)/networkInterfaces(?:.*)` )
42
+ scaleSetNameRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)` )
43
+ resourceGroupRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(?:.*)/virtualMachines(?:.*)` )
44
+ vmssMachineIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s"
45
+ vmssIPConfigurationRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(.+)/networkInterfaces(?:.*)` )
47
46
)
48
47
49
48
// scaleSet implements VMSet interface for Azure scale set.
@@ -515,8 +514,8 @@ func (ss *scaleSet) GetVMSetNames(service *v1.Service, nodes []*v1.Node) (vmSetN
515
514
516
515
// extractResourceGroupByVMSSNicID extracts the resource group name by vmss nicID.
517
516
func extractResourceGroupByVMSSNicID (nicID string ) (string , error ) {
518
- matches := vmssNicResourceGroupRE .FindStringSubmatch (nicID )
519
- if len (matches ) != 2 {
517
+ matches := vmssIPConfigurationRE .FindStringSubmatch (nicID )
518
+ if len (matches ) != 4 {
520
519
return "" , fmt .Errorf ("error of extracting resourceGroup from nicID %q" , nicID )
521
520
}
522
521
@@ -579,8 +578,8 @@ func (ss *scaleSet) GetPrimaryInterface(nodeName string) (network.Interface, err
579
578
return nic , nil
580
579
}
581
580
582
- // getPrimarynetworkInterfaceConfiguration gets primary network interface configuration for scale set virtual machine.
583
- func (ss * scaleSet ) getPrimarynetworkInterfaceConfiguration (networkConfigurations []compute.VirtualMachineScaleSetNetworkConfiguration , nodeName string ) (* compute.VirtualMachineScaleSetNetworkConfiguration , error ) {
581
+ // getPrimaryNetworkInterfaceConfiguration gets primary network interface configuration for scale set virtual machine.
582
+ func (ss * scaleSet ) getPrimaryNetworkInterfaceConfiguration (networkConfigurations []compute.VirtualMachineScaleSetNetworkConfiguration , nodeName string ) (* compute.VirtualMachineScaleSetNetworkConfiguration , error ) {
584
583
if len (networkConfigurations ) == 1 {
585
584
return & networkConfigurations [0 ], nil
586
585
}
@@ -622,8 +621,7 @@ func (ss *scaleSet) EnsureHostInPool(service *v1.Service, nodeName types.NodeNam
622
621
}
623
622
624
623
// Check scale set name:
625
- // - For basic SKU load balancer, errNotInVMSet should be returned if the node's
626
- // scale set is mismatched with vmSetName.
624
+ // - For basic SKU load balancer, return nil if the node's scale set is mismatched with vmSetName.
627
625
// - For standard SKU load balancer, backend could belong to multiple VMSS, so we
628
626
// don't check vmSet for it.
629
627
if vmSetName != "" && ! ss .useStandardLoadBalancer () && ! strings .EqualFold (vmSetName , ssName ) {
@@ -633,7 +631,7 @@ func (ss *scaleSet) EnsureHostInPool(service *v1.Service, nodeName types.NodeNam
633
631
634
632
// Find primary network interface configuration.
635
633
networkInterfaceConfigurations := * vm .NetworkProfileConfiguration .NetworkInterfaceConfigurations
636
- primaryNetworkInterfaceConfiguration , err := ss .getPrimarynetworkInterfaceConfiguration (networkInterfaceConfigurations , vmName )
634
+ primaryNetworkInterfaceConfiguration , err := ss .getPrimaryNetworkInterfaceConfiguration (networkInterfaceConfigurations , vmName )
637
635
if err != nil {
638
636
return err
639
637
}
@@ -784,7 +782,7 @@ func (ss *scaleSet) ensureBackendPoolDeletedFromNode(service *v1.Service, nodeNa
784
782
785
783
// Find primary network interface configuration.
786
784
networkInterfaceConfigurations := * vm .NetworkProfileConfiguration .NetworkInterfaceConfigurations
787
- primaryNetworkInterfaceConfiguration , err := ss .getPrimarynetworkInterfaceConfiguration (networkInterfaceConfigurations , nodeName )
785
+ primaryNetworkInterfaceConfiguration , err := ss .getPrimaryNetworkInterfaceConfiguration (networkInterfaceConfigurations , nodeName )
788
786
if err != nil {
789
787
return err
790
788
}
0 commit comments