proxy/iptables, proxy/ipvs: Remove an unnecessary check

The iptables and ipvs proxiers both had a check that none of the
elements of svcInfo.LoadBalancerIPStrings() were "", but that was
already guaranteed by the svcInfo code. Drop the unnecessary checks
and remove a level of indentation.
This commit is contained in:
Dan Winship 2021-10-29 08:14:02 -04:00
parent a9ad15c421
commit ab67a942ca
2 changed files with 154 additions and 158 deletions

View File

@ -1224,7 +1224,6 @@ func (proxier *Proxier) syncProxyRules() {
// Capture load-balancer ingress. // Capture load-balancer ingress.
fwChain := svcInfo.serviceFirewallChainName fwChain := svcInfo.serviceFirewallChainName
for _, ingress := range svcInfo.LoadBalancerIPStrings() { for _, ingress := range svcInfo.LoadBalancerIPStrings() {
if ingress != "" {
if hasEndpoints { if hasEndpoints {
// create service firewall chain // create service firewall chain
if chain, ok := existingNATChains[fwChain]; ok { if chain, ok := existingNATChains[fwChain]; ok {
@ -1299,7 +1298,6 @@ func (proxier *Proxier) syncProxyRules() {
) )
} }
} }
}
// Capture nodeports. If we had more than 2 rules it might be // Capture nodeports. If we had more than 2 rules it might be
// worthwhile to make a new per-service chain for nodeport rules, but // worthwhile to make a new per-service chain for nodeport rules, but

View File

@ -1307,7 +1307,6 @@ func (proxier *Proxier) syncProxyRules() {
// Capture load-balancer ingress. // Capture load-balancer ingress.
for _, ingress := range svcInfo.LoadBalancerIPStrings() { for _, ingress := range svcInfo.LoadBalancerIPStrings() {
if ingress != "" {
// ipset call // ipset call
entry = &utilipset.Entry{ entry = &utilipset.Entry{
IP: ingress, IP: ingress,
@ -1404,7 +1403,6 @@ func (proxier *Proxier) syncProxyRules() {
klog.ErrorS(err, "Failed to sync service", "serviceName", svcName, "virtualServer", serv) klog.ErrorS(err, "Failed to sync service", "serviceName", svcName, "virtualServer", serv)
} }
} }
}
if svcInfo.NodePort() != 0 { if svcInfo.NodePort() != 0 {
if len(nodeAddresses) == 0 || len(nodeIPs) == 0 { if len(nodeAddresses) == 0 || len(nodeIPs) == 0 {