From 441ab3d970b0b166d86a447bd5e28fd3d15f08d7 Mon Sep 17 00:00:00 2001 From: Anders Liu Date: Fri, 13 Dec 2019 23:27:57 -0800 Subject: [PATCH 1/4] fix: should truncate long subnet name on lb rules --- .../azure/azure_loadbalancer.go | 6 +- .../azure/azure_loadbalancer_test.go | 2 +- .../azure/azure_standard.go | 28 ++++-- .../azure/azure_standard_test.go | 85 +++++++++++++++++++ .../azure/azure_test.go | 4 +- 5 files changed, 113 insertions(+), 12 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go index 70fb51e3112f..7d11c43454f1 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go @@ -407,7 +407,7 @@ func (az *Cloud) getServiceLoadBalancerStatus(service *v1.Service, lb *network.L return nil, nil } isInternal := requiresInternalLoadBalancer(service) - lbFrontendIPConfigName := az.getFrontendIPConfigName(service, subnet(service)) + lbFrontendIPConfigName := az.getFrontendIPConfigName(service) serviceName := getServiceName(service) for _, ipConfiguration := range *lb.FrontendIPConfigurations { if lbFrontendIPConfigName == *ipConfiguration.Name { @@ -697,7 +697,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service, } lbName := *lb.Name klog.V(2).Infof("reconcileLoadBalancer for service(%s): lb(%s) wantLb(%t) resolved load balancer name", serviceName, lbName, wantLb) - lbFrontendIPConfigName := az.getFrontendIPConfigName(service, subnet(service)) + lbFrontendIPConfigName := az.getFrontendIPConfigName(service) lbFrontendIPConfigID := az.getFrontendIPConfigID(lbName, lbFrontendIPConfigName) lbBackendPoolName := getBackendPoolName(clusterName, service) lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName) @@ -1030,7 +1030,7 @@ func (az *Cloud) reconcileLoadBalancerRule( } for _, protocol := range protocols { - lbRuleName := az.getLoadBalancerRuleName(service, protocol, port.Port, subnet(service)) + lbRuleName := az.getLoadBalancerRuleName(service, protocol, port.Port) klog.V(2).Infof("reconcileLoadBalancerRule lb name (%s) rule name (%s)", lbName, lbRuleName) transportProto, _, probeProto, err := getProtocolsFromKubernetesProtocol(protocol) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer_test.go index ed9675d92153..b915c40a451a 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer_test.go @@ -1628,7 +1628,7 @@ func TestGetServiceLoadBalancerStatus(t *testing.T) { }, { desc: "getServiceLoadBalancerStatus shall return nil if lb.FrontendIPConfigurations.name != " + - "az.getFrontendIPConfigName(service, subnet(service))", + "az.getFrontendIPConfigName(service)", service: &internalService, lb: &lb3, }, diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go index 10f4bcd0a223..d7a188e68679 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go @@ -275,12 +275,21 @@ func getBackendPoolName(clusterName string, service *v1.Service) string { return clusterName } -func (az *Cloud) getLoadBalancerRuleName(service *v1.Service, protocol v1.Protocol, port int32, subnetName *string) string { +func (az *Cloud) getLoadBalancerRuleName(service *v1.Service, protocol v1.Protocol, port int32) string { prefix := az.getRulePrefix(service) - if subnetName == nil { - return fmt.Sprintf("%s-%s-%d", prefix, protocol, port) + ruleName := fmt.Sprintf("%s-%s-%d", prefix, protocol, port) + subnet := subnet(service) + if subnet == nil { + return ruleName } - return fmt.Sprintf("%s-%s-%s-%d", prefix, *subnetName, protocol, port) + + // Load balancer rule name must be less or equal to 80 charactors, so excluding the hyphen two segments cannot exceed 79 + subnetSegment := *subnet + if len(ruleName) + len(subnetSegment) > 79 { + subnetSegment = subnetSegment[:79 - len(ruleName)] + } + + return fmt.Sprintf("%s-%s-%s-%d", prefix, subnetSegment, protocol, port) } func (az *Cloud) getSecurityRuleName(service *v1.Service, port v1.ServicePort, sourceAddrPrefix string) string { @@ -318,10 +327,17 @@ func (az *Cloud) serviceOwnsFrontendIP(fip network.FrontendIPConfiguration, serv return strings.HasPrefix(*fip.Name, baseName) } -func (az *Cloud) getFrontendIPConfigName(service *v1.Service, subnetName *string) string { +func (az *Cloud) getFrontendIPConfigName(service *v1.Service) string { baseName := az.GetLoadBalancerName(context.TODO(), "", service) + subnetName := subnet(service) if subnetName != nil { - return fmt.Sprintf("%s-%s", baseName, *subnetName) + ipcName := fmt.Sprintf("%s-%s", baseName, *subnetName) + + // Azure lb front end configuration name must not exceed 80 charactors + if len(ipcName) > 80 { + ipcName = ipcName[:80] + } + return ipcName } return baseName } diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go index 1b9b21832824..140c62248e69 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go @@ -20,6 +20,7 @@ package azure import ( "testing" + "strconv" "github.com/stretchr/testify/assert" @@ -264,3 +265,87 @@ func TestGetAzureLoadBalancerName(t *testing.T) { assert.Equal(t, c.expected, loadbalancerName, c.description) } } + +func TestGetLoadBalancingRuleName(t *testing.T) { + az := getTestCloud() + az.PrimaryAvailabilitySetName = "primary" + + svc := &v1.Service{ + ObjectMeta: meta.ObjectMeta{ + Annotations: map[string]string{ + ServiceAnnotationLoadBalancerInternalSubnet: "subnet", + ServiceAnnotationLoadBalancerInternal: "true", + }, + UID: "257b9655-5137-4ad2-b091-ef3f07043ad3", + }, + } + + cases := []struct { + description string + subnetName string + isInternal bool + useStandardLB bool + protocol v1.Protocol + port int32 + expected string + }{ + { + description: "internal lb should have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: true, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet-TCP-9000", + }, + { + description: "internal standard lb should have subnet name on the rule name but truncated to 80 charactors", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", + }, + { + description: "internal basic lb should have subnet name on the rule name but truncated to 80 charactors", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: false, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", + }, + { + description: "external standard lb should not have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", + }, + { + description: "external basic lb should not have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: false, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", + }, + } + + for _, c := range cases { + if c.useStandardLB { + az.Config.LoadBalancerSku = loadBalancerSkuStandard + } else { + az.Config.LoadBalancerSku = loadBalancerSkuBasic + } + svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName + svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal) + + loadbalancerName := az.getLoadBalancerRuleName(svc, c.protocol, c.port) + assert.Equal(t, c.expected, loadbalancerName, c.description) + } +} diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_test.go index 13f2616c04cb..089937252235 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_test.go @@ -1240,14 +1240,14 @@ func validateLoadBalancer(t *testing.T, loadBalancer *network.LoadBalancer, serv if len(svc.Spec.Ports) > 0 { expectedFrontendIPCount++ expectedFrontendIP := ExpectedFrontendIPInfo{ - Name: az.getFrontendIPConfigName(&svc, subnet(&svc)), + Name: az.getFrontendIPConfigName(&svc), Subnet: subnet(&svc), } expectedFrontendIPs = append(expectedFrontendIPs, expectedFrontendIP) } for _, wantedRule := range svc.Spec.Ports { expectedRuleCount++ - wantedRuleName := az.getLoadBalancerRuleName(&svc, wantedRule.Protocol, wantedRule.Port, subnet(&svc)) + wantedRuleName := az.getLoadBalancerRuleName(&svc, wantedRule.Protocol, wantedRule.Port) foundRule := false for _, actualRule := range *loadBalancer.LoadBalancingRules { if strings.EqualFold(*actualRule.Name, wantedRuleName) && From 86b0e7511356d98caf325acf9ed84ad82d614a26 Mon Sep 17 00:00:00 2001 From: Anders Liu Date: Sat, 14 Dec 2019 01:15:21 -0800 Subject: [PATCH 2/4] fix: add unit tests for truncate long subnet name on lb ip configuration --- .../azure/azure_standard_test.go | 79 +++++++++++++++++-- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go index 140c62248e69..6786e6a09802 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go @@ -272,10 +272,7 @@ func TestGetLoadBalancingRuleName(t *testing.T) { svc := &v1.Service{ ObjectMeta: meta.ObjectMeta{ - Annotations: map[string]string{ - ServiceAnnotationLoadBalancerInternalSubnet: "subnet", - ServiceAnnotationLoadBalancerInternal: "true", - }, + Annotations: map[string]string{ }, UID: "257b9655-5137-4ad2-b091-ef3f07043ad3", }, } @@ -345,7 +342,79 @@ func TestGetLoadBalancingRuleName(t *testing.T) { svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal) - loadbalancerName := az.getLoadBalancerRuleName(svc, c.protocol, c.port) + loadbalancerRuleName := az.getLoadBalancerRuleName(svc, c.protocol, c.port) + assert.Equal(t, c.expected, loadbalancerRuleName, c.description) + } +} + +func TestgetFrontendIPConfigName(t *testing.T) { + az := getTestCloud() + az.PrimaryAvailabilitySetName = "primary" + + svc := &v1.Service{ + ObjectMeta: meta.ObjectMeta{ + Annotations: map[string]string{ + ServiceAnnotationLoadBalancerInternalSubnet: "subnet", + ServiceAnnotationLoadBalancerInternal: "true", + }, + UID: "257b9655-5137-4ad2-b091-ef3f07043ad3", + }, + } + + cases := []struct { + description string + subnetName string + isInternal bool + useStandardLB bool + expected string + }{ + { + description: "internal lb should have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: true, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet", + }, + { + description: "internal standard lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg", + }, + { + description: "internal basic lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: false, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg", + }, + { + description: "external standard lb should not have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad", + }, + { + description: "external basic lb should not have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: false, + expected: "a257b965551374ad2b091ef3f07043ad", + }, + } + + for _, c := range cases { + if c.useStandardLB { + az.Config.LoadBalancerSku = loadBalancerSkuStandard + } else { + az.Config.LoadBalancerSku = loadBalancerSkuBasic + } + svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName + svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal) + + loadbalancerName := az.getFrontendIPConfigName(svc) assert.Equal(t, c.expected, loadbalancerName, c.description) } } From cbfabe7ac190b5db67cf450db60985a2540bc081 Mon Sep 17 00:00:00 2001 From: Anders Liu Date: Sat, 14 Dec 2019 22:19:05 -0800 Subject: [PATCH 3/4] fix: address test failure and review comments --- .../legacy-cloud-providers/azure/azure_standard.go | 10 ++++++---- .../azure/azure_standard_test.go | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go index d7a188e68679..caed74713a9e 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go @@ -67,6 +67,8 @@ const ( nicFailedState = "Failed" storageAccountNameMaxLength = 24 + frontendIPConfigNameMaxLength = 80 + loadBalancerRuleNameMaxLength = 80 ) var errNotInVMSet = errors.New("vm is not in the vmset") @@ -285,8 +287,8 @@ func (az *Cloud) getLoadBalancerRuleName(service *v1.Service, protocol v1.Protoc // Load balancer rule name must be less or equal to 80 charactors, so excluding the hyphen two segments cannot exceed 79 subnetSegment := *subnet - if len(ruleName) + len(subnetSegment) > 79 { - subnetSegment = subnetSegment[:79 - len(ruleName)] + if len(ruleName) + len(subnetSegment) + 1 > loadBalancerRuleNameMaxLength { + subnetSegment = subnetSegment[:loadBalancerRuleNameMaxLength - len(ruleName) - 1] } return fmt.Sprintf("%s-%s-%s-%d", prefix, subnetSegment, protocol, port) @@ -334,8 +336,8 @@ func (az *Cloud) getFrontendIPConfigName(service *v1.Service) string { ipcName := fmt.Sprintf("%s-%s", baseName, *subnetName) // Azure lb front end configuration name must not exceed 80 charactors - if len(ipcName) > 80 { - ipcName = ipcName[:80] + if len(ipcName) > frontendIPConfigNameMaxLength { + ipcName = ipcName[:frontendIPConfigNameMaxLength] } return ipcName } diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go index 6786e6a09802..76a345ec9589 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go @@ -347,7 +347,7 @@ func TestGetLoadBalancingRuleName(t *testing.T) { } } -func TestgetFrontendIPConfigName(t *testing.T) { +func TestGetFrontendIPConfigName(t *testing.T) { az := getTestCloud() az.PrimaryAvailabilitySetName = "primary" @@ -380,14 +380,14 @@ func TestgetFrontendIPConfigName(t *testing.T) { subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", isInternal: true, useStandardLB: true, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg", + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", }, { description: "internal basic lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors", subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", isInternal: true, useStandardLB: false, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg", + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", }, { description: "external standard lb should not have subnet name on the frontend ip configuration name", @@ -414,7 +414,7 @@ func TestgetFrontendIPConfigName(t *testing.T) { svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal) - loadbalancerName := az.getFrontendIPConfigName(svc) - assert.Equal(t, c.expected, loadbalancerName, c.description) + ipconfigName := az.getFrontendIPConfigName(svc) + assert.Equal(t, c.expected, ipconfigName, c.description) } } From c568e62f5202cc9cec285f37b322ca3a5068ec69 Mon Sep 17 00:00:00 2001 From: Anders Liu Date: Sat, 14 Dec 2019 23:25:52 -0800 Subject: [PATCH 4/4] fix: formating and typo --- .../azure/azure_standard.go | 12 +- .../azure/azure_standard_test.go | 130 +++++++++--------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go index caed74713a9e..5eb024085d56 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go @@ -66,7 +66,7 @@ const ( nodeLabelRole = "kubernetes.io/role" nicFailedState = "Failed" - storageAccountNameMaxLength = 24 + storageAccountNameMaxLength = 24 frontendIPConfigNameMaxLength = 80 loadBalancerRuleNameMaxLength = 80 ) @@ -285,10 +285,10 @@ func (az *Cloud) getLoadBalancerRuleName(service *v1.Service, protocol v1.Protoc return ruleName } - // Load balancer rule name must be less or equal to 80 charactors, so excluding the hyphen two segments cannot exceed 79 + // Load balancer rule name must be less or equal to 80 characters, so excluding the hyphen two segments cannot exceed 79 subnetSegment := *subnet - if len(ruleName) + len(subnetSegment) + 1 > loadBalancerRuleNameMaxLength { - subnetSegment = subnetSegment[:loadBalancerRuleNameMaxLength - len(ruleName) - 1] + if len(ruleName)+len(subnetSegment)+1 > loadBalancerRuleNameMaxLength { + subnetSegment = subnetSegment[:loadBalancerRuleNameMaxLength-len(ruleName)-1] } return fmt.Sprintf("%s-%s-%s-%d", prefix, subnetSegment, protocol, port) @@ -334,8 +334,8 @@ func (az *Cloud) getFrontendIPConfigName(service *v1.Service) string { subnetName := subnet(service) if subnetName != nil { ipcName := fmt.Sprintf("%s-%s", baseName, *subnetName) - - // Azure lb front end configuration name must not exceed 80 charactors + + // Azure lb front end configuration name must not exceed 80 characters if len(ipcName) > frontendIPConfigNameMaxLength { ipcName = ipcName[:frontendIPConfigNameMaxLength] } diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go index 76a345ec9589..ce091dfbc073 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard_test.go @@ -19,8 +19,8 @@ limitations under the License. package azure import ( - "testing" "strconv" + "testing" "github.com/stretchr/testify/assert" @@ -272,13 +272,13 @@ func TestGetLoadBalancingRuleName(t *testing.T) { svc := &v1.Service{ ObjectMeta: meta.ObjectMeta{ - Annotations: map[string]string{ }, - UID: "257b9655-5137-4ad2-b091-ef3f07043ad3", + Annotations: map[string]string{}, + UID: "257b9655-5137-4ad2-b091-ef3f07043ad3", }, } cases := []struct { - description string + description string subnetName string isInternal bool useStandardLB bool @@ -287,49 +287,49 @@ func TestGetLoadBalancingRuleName(t *testing.T) { expected string }{ { - description: "internal lb should have subnet name on the rule name", - subnetName: "shortsubnet", - isInternal: true, - useStandardLB: true, - protocol: v1.ProtocolTCP, - port: 9000, - expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet-TCP-9000", + description: "internal lb should have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: true, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet-TCP-9000", }, { - description: "internal standard lb should have subnet name on the rule name but truncated to 80 charactors", - subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", - isInternal: true, - useStandardLB: true, - protocol: v1.ProtocolTCP, - port: 9000, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", + description: "internal standard lb should have subnet name on the rule name but truncated to 80 characters", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", }, { - description: "internal basic lb should have subnet name on the rule name but truncated to 80 charactors", - subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", - isInternal: true, - useStandardLB: false, - protocol: v1.ProtocolTCP, - port: 9000, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", + description: "internal basic lb should have subnet name on the rule name but truncated to 80 characters", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: false, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg-TCP-9000", }, { - description: "external standard lb should not have subnet name on the rule name", - subnetName: "shortsubnet", - isInternal: false, - useStandardLB: true, - protocol: v1.ProtocolTCP, - port: 9000, - expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", + description: "external standard lb should not have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: true, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", }, { - description: "external basic lb should not have subnet name on the rule name", - subnetName: "shortsubnet", - isInternal: false, - useStandardLB: false, - protocol: v1.ProtocolTCP, - port: 9000, - expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", + description: "external basic lb should not have subnet name on the rule name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: false, + protocol: v1.ProtocolTCP, + port: 9000, + expected: "a257b965551374ad2b091ef3f07043ad-TCP-9000", }, } @@ -362,46 +362,46 @@ func TestGetFrontendIPConfigName(t *testing.T) { } cases := []struct { - description string + description string subnetName string isInternal bool useStandardLB bool expected string }{ { - description: "internal lb should have subnet name on the frontend ip configuration name", - subnetName: "shortsubnet", - isInternal: true, - useStandardLB: true, - expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet", + description: "internal lb should have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: true, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad-shortsubnet", }, { - description: "internal standard lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors", - subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", - isInternal: true, - useStandardLB: true, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", + description: "internal standard lb should have subnet name on the frontend ip configuration name but truncated to 80 characters", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", }, { - description: "internal basic lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors", - subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", - isInternal: true, - useStandardLB: false, - expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", + description: "internal basic lb should have subnet name on the frontend ip configuration name but truncated to 80 characters", + subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet", + isInternal: true, + useStandardLB: false, + expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg", }, { - description: "external standard lb should not have subnet name on the frontend ip configuration name", - subnetName: "shortsubnet", - isInternal: false, - useStandardLB: true, - expected: "a257b965551374ad2b091ef3f07043ad", + description: "external standard lb should not have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: true, + expected: "a257b965551374ad2b091ef3f07043ad", }, { - description: "external basic lb should not have subnet name on the frontend ip configuration name", - subnetName: "shortsubnet", - isInternal: false, - useStandardLB: false, - expected: "a257b965551374ad2b091ef3f07043ad", + description: "external basic lb should not have subnet name on the frontend ip configuration name", + subnetName: "shortsubnet", + isInternal: false, + useStandardLB: false, + expected: "a257b965551374ad2b091ef3f07043ad", }, }