mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
fix: address test failure and review comments
This commit is contained in:
parent
c6a2c4fa79
commit
d7f14fb38e
@ -66,6 +66,8 @@ const (
|
|||||||
nicFailedState = "Failed"
|
nicFailedState = "Failed"
|
||||||
|
|
||||||
storageAccountNameMaxLength = 24
|
storageAccountNameMaxLength = 24
|
||||||
|
frontendIPConfigNameMaxLength = 80
|
||||||
|
loadBalancerRuleNameMaxLength = 80
|
||||||
)
|
)
|
||||||
|
|
||||||
var errNotInVMSet = errors.New("vm is not in the vmset")
|
var errNotInVMSet = errors.New("vm is not in the vmset")
|
||||||
@ -283,8 +285,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
|
// Load balancer rule name must be less or equal to 80 charactors, so excluding the hyphen two segments cannot exceed 79
|
||||||
subnetSegment := *subnet
|
subnetSegment := *subnet
|
||||||
if len(ruleName) + len(subnetSegment) > 79 {
|
if len(ruleName) + len(subnetSegment) + 1 > loadBalancerRuleNameMaxLength {
|
||||||
subnetSegment = subnetSegment[:79 - len(ruleName)]
|
subnetSegment = subnetSegment[:loadBalancerRuleNameMaxLength - len(ruleName) - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s-%s-%s-%d", prefix, subnetSegment, protocol, port)
|
return fmt.Sprintf("%s-%s-%s-%d", prefix, subnetSegment, protocol, port)
|
||||||
@ -332,8 +334,8 @@ func (az *Cloud) getFrontendIPConfigName(service *v1.Service) string {
|
|||||||
ipcName := fmt.Sprintf("%s-%s", baseName, *subnetName)
|
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 charactors
|
||||||
if len(ipcName) > 80 {
|
if len(ipcName) > frontendIPConfigNameMaxLength {
|
||||||
ipcName = ipcName[:80]
|
ipcName = ipcName[:frontendIPConfigNameMaxLength]
|
||||||
}
|
}
|
||||||
return ipcName
|
return ipcName
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ func TestGetLoadBalancingRuleName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestgetFrontendIPConfigName(t *testing.T) {
|
func TestGetFrontendIPConfigName(t *testing.T) {
|
||||||
az := getTestCloud()
|
az := getTestCloud()
|
||||||
az.PrimaryAvailabilitySetName = "primary"
|
az.PrimaryAvailabilitySetName = "primary"
|
||||||
|
|
||||||
@ -369,14 +369,14 @@ func TestgetFrontendIPConfigName(t *testing.T) {
|
|||||||
subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet",
|
subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet",
|
||||||
isInternal: true,
|
isInternal: true,
|
||||||
useStandardLB: 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",
|
description: "internal basic lb should have subnet name on the frontend ip configuration name but truncated to 80 charactors",
|
||||||
subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet",
|
subnetName: "averylonnnngggnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggsubet",
|
||||||
isInternal: true,
|
isInternal: true,
|
||||||
useStandardLB: false,
|
useStandardLB: false,
|
||||||
expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnngg",
|
expected: "a257b965551374ad2b091ef3f07043ad-averylonnnngggnnnnnnnnnnnnnnnnnnnnnnggggggggggg",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "external standard lb should not have subnet name on the frontend ip configuration name",
|
description: "external standard lb should not have subnet name on the frontend ip configuration name",
|
||||||
@ -403,7 +403,7 @@ func TestgetFrontendIPConfigName(t *testing.T) {
|
|||||||
svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName
|
svc.Annotations[ServiceAnnotationLoadBalancerInternalSubnet] = c.subnetName
|
||||||
svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal)
|
svc.Annotations[ServiceAnnotationLoadBalancerInternal] = strconv.FormatBool(c.isInternal)
|
||||||
|
|
||||||
loadbalancerName := az.getFrontendIPConfigName(svc)
|
ipconfigName := az.getFrontendIPConfigName(svc)
|
||||||
assert.Equal(t, c.expected, loadbalancerName, c.description)
|
assert.Equal(t, c.expected, ipconfigName, c.description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user