mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Merge pull request #107981 from lzhecheng/fix-enabletcpreset
Cherry-pick: Fix incorrect EnableTCPReset for non-TCP protocols
This commit is contained in:
commit
9d18c761af
@ -1700,6 +1700,10 @@ func (az *Cloud) reconcileLoadBalancerRule(
|
||||
loadDistribution = network.LoadDistributionSourceIP
|
||||
}
|
||||
|
||||
tcpReset := enableTCPReset
|
||||
if port.Protocol != v1.ProtocolTCP {
|
||||
tcpReset = nil
|
||||
}
|
||||
expectedRule := network.LoadBalancingRule{
|
||||
Name: &lbRuleName,
|
||||
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||
@ -1714,7 +1718,7 @@ func (az *Cloud) reconcileLoadBalancerRule(
|
||||
FrontendPort: to.Int32Ptr(port.Port),
|
||||
BackendPort: to.Int32Ptr(port.Port),
|
||||
DisableOutboundSnat: to.BoolPtr(az.disableLoadBalancerOutboundSNAT()),
|
||||
EnableTCPReset: enableTCPReset,
|
||||
EnableTCPReset: tcpReset,
|
||||
EnableFloatingIP: to.BoolPtr(true),
|
||||
},
|
||||
}
|
||||
@ -2409,14 +2413,21 @@ func equalLoadBalancingRulePropertiesFormat(s *network.LoadBalancingRuleProperti
|
||||
return false
|
||||
}
|
||||
|
||||
properties := reflect.DeepEqual(s.Protocol, t.Protocol) &&
|
||||
reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
|
||||
properties := reflect.DeepEqual(s.Protocol, t.Protocol)
|
||||
if !properties {
|
||||
return false
|
||||
}
|
||||
|
||||
if reflect.DeepEqual(s.Protocol, network.TransportProtocolTCP) {
|
||||
properties = properties && reflect.DeepEqual(to.Bool(s.EnableTCPReset), to.Bool(t.EnableTCPReset))
|
||||
}
|
||||
|
||||
properties = properties && reflect.DeepEqual(s.FrontendIPConfiguration, t.FrontendIPConfiguration) &&
|
||||
reflect.DeepEqual(s.BackendAddressPool, t.BackendAddressPool) &&
|
||||
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) &&
|
||||
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) &&
|
||||
reflect.DeepEqual(s.BackendPort, t.BackendPort) &&
|
||||
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP) &&
|
||||
reflect.DeepEqual(to.Bool(s.EnableTCPReset), to.Bool(t.EnableTCPReset)) &&
|
||||
reflect.DeepEqual(to.Bool(s.DisableOutboundSnat), to.Bool(t.DisableOutboundSnat))
|
||||
|
||||
if wantLB && s.IdleTimeoutInMinutes != nil && t.IdleTimeoutInMinutes != nil {
|
||||
|
@ -3909,3 +3909,48 @@ func TestEnsurePIPTagged(t *testing.T) {
|
||||
assert.Equal(t, expectedPIP, pip)
|
||||
})
|
||||
}
|
||||
|
||||
func TestEqualLoadBalancingRulePropertiesFormat(t *testing.T) {
|
||||
var enableTCPReset, disableTCPReset *bool = to.BoolPtr(true), to.BoolPtr(false)
|
||||
var frontPort *int32 = to.Int32Ptr(80)
|
||||
|
||||
testcases := []struct {
|
||||
s *network.LoadBalancingRulePropertiesFormat
|
||||
t *network.LoadBalancingRulePropertiesFormat
|
||||
wantLb bool
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
s: &network.LoadBalancingRulePropertiesFormat{
|
||||
Protocol: network.TransportProtocolTCP,
|
||||
EnableTCPReset: enableTCPReset,
|
||||
FrontendPort: frontPort,
|
||||
},
|
||||
t: &network.LoadBalancingRulePropertiesFormat{
|
||||
Protocol: network.TransportProtocolTCP,
|
||||
EnableTCPReset: enableTCPReset,
|
||||
FrontendPort: frontPort,
|
||||
},
|
||||
wantLb: true,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
s: &network.LoadBalancingRulePropertiesFormat{
|
||||
Protocol: network.TransportProtocolUDP,
|
||||
EnableTCPReset: disableTCPReset,
|
||||
FrontendPort: frontPort,
|
||||
},
|
||||
t: &network.LoadBalancingRulePropertiesFormat{
|
||||
Protocol: network.TransportProtocolUDP,
|
||||
EnableTCPReset: enableTCPReset,
|
||||
FrontendPort: frontPort,
|
||||
},
|
||||
wantLb: true,
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
assert.Equal(t, tc.expected, equalLoadBalancingRulePropertiesFormat(tc.s, tc.t, tc.wantLb))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user