Enrich the unit tests for azure_vmss.go.
This commit is contained in:
		@@ -61,6 +61,7 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) {
 | 
				
			|||||||
			SecurityGroupName:            "nsg",
 | 
								SecurityGroupName:            "nsg",
 | 
				
			||||||
			RouteTableName:               "rt",
 | 
								RouteTableName:               "rt",
 | 
				
			||||||
			PrimaryAvailabilitySetName:   "as",
 | 
								PrimaryAvailabilitySetName:   "as",
 | 
				
			||||||
 | 
								PrimaryScaleSetName:          "vmss",
 | 
				
			||||||
			MaximumLoadBalancerRuleCount: 250,
 | 
								MaximumLoadBalancerRuleCount: 250,
 | 
				
			||||||
			VMType:                       vmTypeStandard,
 | 
								VMType:                       vmTypeStandard,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1733,7 +1733,7 @@ func subnet(service *v1.Service) *string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// getServiceLoadBalancerMode parses the mode value.
 | 
					// getServiceLoadBalancerMode parses the mode value.
 | 
				
			||||||
// if the value is __auto__ it returns isAuto = TRUE.
 | 
					// if the value is __auto__ it returns isAuto = TRUE.
 | 
				
			||||||
// if anything else it returns the unique VM set names after triming spaces.
 | 
					// if anything else it returns the unique VM set names after trimming spaces.
 | 
				
			||||||
func getServiceLoadBalancerMode(service *v1.Service) (hasMode bool, isAuto bool, vmSetNames []string) {
 | 
					func getServiceLoadBalancerMode(service *v1.Service) (hasMode bool, isAuto bool, vmSetNames []string) {
 | 
				
			||||||
	mode, hasMode := service.Annotations[ServiceAnnotationLoadBalancerMode]
 | 
						mode, hasMode := service.Annotations[ServiceAnnotationLoadBalancerMode]
 | 
				
			||||||
	mode = strings.TrimSpace(mode)
 | 
						mode = strings.TrimSpace(mode)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ var (
 | 
				
			|||||||
	// virtualMachineScaleSetsDeallocating indicates VMSS instances are in Deallocating state.
 | 
						// virtualMachineScaleSetsDeallocating indicates VMSS instances are in Deallocating state.
 | 
				
			||||||
	virtualMachineScaleSetsDeallocating = "Deallocating"
 | 
						virtualMachineScaleSetsDeallocating = "Deallocating"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ErrorNotVmssInstance indicates an instance is not belongint to any vmss.
 | 
						// ErrorNotVmssInstance indicates an instance is not belonging to any vmss.
 | 
				
			||||||
	ErrorNotVmssInstance = errors.New("not a vmss instance")
 | 
						ErrorNotVmssInstance = errors.New("not a vmss instance")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scaleSetNameRE         = regexp.MustCompile(`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)`)
 | 
						scaleSetNameRE         = regexp.MustCompile(`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines(?:.*)`)
 | 
				
			||||||
@@ -289,7 +289,7 @@ func (ss *scaleSet) GetNodeNameByProviderID(providerID string) (types.NodeName,
 | 
				
			|||||||
	// NodeName is not part of providerID for vmss instances.
 | 
						// NodeName is not part of providerID for vmss instances.
 | 
				
			||||||
	scaleSetName, err := extractScaleSetNameByProviderID(providerID)
 | 
						scaleSetName, err := extractScaleSetNameByProviderID(providerID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.V(4).Infof("Can not extract scale set name from providerID (%s), assuming it is mananaged by availability set: %v", providerID, err)
 | 
							klog.V(4).Infof("Can not extract scale set name from providerID (%s), assuming it is managed by availability set: %v", providerID, err)
 | 
				
			||||||
		return ss.availabilitySet.GetNodeNameByProviderID(providerID)
 | 
							return ss.availabilitySet.GetNodeNameByProviderID(providerID)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -300,7 +300,7 @@ func (ss *scaleSet) GetNodeNameByProviderID(providerID string) (types.NodeName,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	instanceID, err := getLastSegment(providerID)
 | 
						instanceID, err := getLastSegment(providerID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.V(4).Infof("Can not extract instanceID from providerID (%s), assuming it is mananaged by availability set: %v", providerID, err)
 | 
							klog.V(4).Infof("Can not extract instanceID from providerID (%s), assuming it is managed by availability set: %v", providerID, err)
 | 
				
			||||||
		return ss.availabilitySet.GetNodeNameByProviderID(providerID)
 | 
							return ss.availabilitySet.GetNodeNameByProviderID(providerID)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -433,11 +433,11 @@ func (ss *scaleSet) GetIPByNodeName(nodeName string) (string, string, error) {
 | 
				
			|||||||
	return internalIP, publicIP, nil
 | 
						return internalIP, publicIP, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ss *scaleSet) getVMSSPublicIPAddress(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string) (network.PublicIPAddress, bool, error) {
 | 
					func (ss *scaleSet) getVMSSPublicIPAddress(resourceGroupName string, virtualMachineScaleSetName string, virtualMachineIndex string, networkInterfaceName string, IPConfigurationName string, publicIPAddressName string) (network.PublicIPAddress, bool, error) {
 | 
				
			||||||
	ctx, cancel := getContextWithCancel()
 | 
						ctx, cancel := getContextWithCancel()
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pip, err := ss.PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress(ctx, resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, IPConfigurationName, publicIPAddressName, "")
 | 
						pip, err := ss.PublicIPAddressesClient.GetVirtualMachineScaleSetPublicIPAddress(ctx, resourceGroupName, virtualMachineScaleSetName, virtualMachineIndex, networkInterfaceName, IPConfigurationName, publicIPAddressName, "")
 | 
				
			||||||
	exists, rerr := checkResourceExistsFromError(err)
 | 
						exists, rerr := checkResourceExistsFromError(err)
 | 
				
			||||||
	if rerr != nil {
 | 
						if rerr != nil {
 | 
				
			||||||
		return pip, false, rerr.Error()
 | 
							return pip, false, rerr.Error()
 | 
				
			||||||
@@ -712,7 +712,7 @@ func (ss *scaleSet) GetPrimaryInterface(nodeName string) (network.Interface, err
 | 
				
			|||||||
		exists, realErr := checkResourceExistsFromError(rerr)
 | 
							exists, realErr := checkResourceExistsFromError(rerr)
 | 
				
			||||||
		if realErr != nil {
 | 
							if realErr != nil {
 | 
				
			||||||
			klog.Errorf("error: ss.GetPrimaryInterface(%s), ss.GetVirtualMachineScaleSetNetworkInterface.Get(%s, %s, %s), err=%v", nodeName, resourceGroup, ssName, nicName, realErr)
 | 
								klog.Errorf("error: ss.GetPrimaryInterface(%s), ss.GetVirtualMachineScaleSetNetworkInterface.Get(%s, %s, %s), err=%v", nodeName, resourceGroup, ssName, nicName, realErr)
 | 
				
			||||||
			return network.Interface{}, err
 | 
								return network.Interface{}, realErr.Error()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if !exists {
 | 
							if !exists {
 | 
				
			||||||
@@ -956,7 +956,7 @@ func (ss *scaleSet) ensureVMSSInPool(service *v1.Service, nodes []*v1.Node, back
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations == nil {
 | 
							if vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations == nil {
 | 
				
			||||||
			klog.V(4).Infof("EnsureHostInPool: cannot obtain the primary network interface configuration, of vmss %s", vmssName)
 | 
								klog.V(4).Infof("EnsureHostInPool: cannot obtain the primary network interface configuration of vmss %s", vmssName)
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		vmssNIC := *vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations
 | 
							vmssNIC := *vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user