mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #83953 from beautytiger/dev-191015-azure_wrap
fix string trim func isBackendPoolOnSameLB in azure
This commit is contained in:
commit
dc255c6093
@ -350,7 +350,7 @@ func isBackendPoolOnSameLB(newBackendPoolID string, existingBackendPools []strin
|
||||
}
|
||||
|
||||
newLBName := matches[1]
|
||||
newLBNameTrimmed := strings.TrimRight(newLBName, InternalLoadBalancerNameSuffix)
|
||||
newLBNameTrimmed := strings.TrimSuffix(newLBName, InternalLoadBalancerNameSuffix)
|
||||
for _, backendPool := range existingBackendPools {
|
||||
matches := backendPoolIDRE.FindStringSubmatch(backendPool)
|
||||
if len(matches) != 2 {
|
||||
@ -358,7 +358,7 @@ func isBackendPoolOnSameLB(newBackendPoolID string, existingBackendPools []strin
|
||||
}
|
||||
|
||||
lbName := matches[1]
|
||||
if !strings.EqualFold(strings.TrimRight(lbName, InternalLoadBalancerNameSuffix), newLBNameTrimmed) {
|
||||
if !strings.EqualFold(strings.TrimSuffix(lbName, InternalLoadBalancerNameSuffix), newLBNameTrimmed) {
|
||||
return false, lbName, nil
|
||||
}
|
||||
}
|
||||
|
@ -263,6 +263,14 @@ func TestIsBackendPoolOnSameLB(t *testing.T) {
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
backendPoolID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/malformed-lb1-internal/backendAddressPools/pool1",
|
||||
existingBackendPools: []string{
|
||||
"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/malformed-lb1-lanretni/backendAddressPools/pool2",
|
||||
},
|
||||
expected: false,
|
||||
expectedLBName: "malformed-lb1-lanretni",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user