Change:
assert.Equal(t, c.expected, loadbalancerName, c.description) } } <ins> func TestGetLoadBalancingRuleName(t *testing.T) { az := getTestCloud() az.PrimaryAvailabilitySetName = "primary" svc := &v1.Service{ ObjectMeta: meta.ObjectMeta{ Annotations: map[string]string{}, 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 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 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 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) 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 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 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 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) ipconfigName := az.getFrontendIPConfigName(svc) assert.Equal(t, c.expected, ipconfigName, c.description) } } </ins>

Discussion:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: When the specified internal LB uses a subnet with longer name, the LB configuration will fail with following error: What you expected to happen: When constructing the frontend IP configuration name and the load balancing rules name, the subnet name should be truncated if too long. How to reproduce it (as minimally and precisely as possible): Use a subnet that has long name (70 charactors) and create ILB service. Anything else we need to know?: Environment: Kubernetes version (use ): 1.15 Cloud provider or hardware configuration: azure OS (e.g: ): Ubuntu 16.04 Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
/sig cloud-provider /area provider/azure /assign