Skip to content

Commit 2159fae

Browse files
author
Jeff Bornemann
authored
Merge pull request #301 from oracle/sec_list_leak_fix
Bug fix: node subnet ingress security rules can sometimes leak after deletion
2 parents 92a88ed + e698c81 commit 2159fae

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

pkg/cloudprovider/providers/oci/load_balancer_security_lists.go

+10-17
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (s *defaultSecurityListManager) Delete(ctx context.Context, lbSubnets []*co
239239
return err
240240
}
241241

242-
return s.updateBackendRules(ctx, noSubnets, backendSubnets, nil, ports)
242+
return s.updateBackendRules(ctx, noSubnets, backendSubnets, &ports, ports)
243243
}
244244

245245
// frontendSecurityListManager manages only the ingress security list rules required for
@@ -408,22 +408,15 @@ func getNodeIngressRules(
408408
ingressRules = append(ingressRules, rule)
409409
desiredHealthChecker.Delete(*rule.Source)
410410
continue
411-
}
412-
413-
inUse, err := healthCheckPortInUse(serviceLister, int32(desiredPorts.HealthCheckerPort))
414-
if err != nil {
415-
// Unable to determine if this port is in use by another service, so I guess
416-
// we better err on the safe side and keep the rule.
417-
logger.Errorf("failed to determine if port: %d is still in use: %v", desiredPorts.HealthCheckerPort, err)
418-
ingressRules = append(ingressRules, rule)
419-
continue
420-
}
421-
if inUse {
422-
// This rule is no longer needed for this service, but is still used
423-
// by another service, so we must still keep it.
424-
logger.Infof("Port %d still in use by another service.", desiredPorts.HealthCheckerPort)
425-
ingressRules = append(ingressRules, rule)
426-
continue
411+
} else if *r.Max == desiredPorts.HealthCheckerPort {
412+
inUse, err := healthCheckPortInUse(serviceLister, int32(desiredPorts.HealthCheckerPort))
413+
if err != nil {
414+
logger.Errorf("failed to determine if port: %d is still in use: %v", desiredPorts.HealthCheckerPort, err)
415+
ingressRules = append(ingressRules, rule)
416+
} else if inUse {
417+
logger.Infof("Port %d still in use by another service.", desiredPorts.HealthCheckerPort)
418+
ingressRules = append(ingressRules, rule)
419+
}
427420
}
428421

429422
// else the actual cidr no longer exists so we don't need to do

pkg/cloudprovider/providers/oci/load_balancer_security_lists_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ func TestGetNodeIngressRules(t *testing.T) {
141141
makeIngressSecurityRule("existing", 9001),
142142
},
143143
}, {
144-
name: "do not delete a rule which is used by another services (default) health check",
144+
name: "do not delete health check rules that are used by other services",
145145
securityList: &core.SecurityList{
146146
IngressSecurityRules: []core.IngressSecurityRule{
147147
makeIngressSecurityRule("0.0.0.0/0", lbNodesHealthCheckPort),
148+
makeIngressSecurityRule("0.0.0.0/0", 80),
148149
},
149150
},
150151
lbSubnets: []*core.Subnet{},
@@ -157,7 +158,7 @@ func TestGetNodeIngressRules(t *testing.T) {
157158
ObjectMeta: metav1.ObjectMeta{Namespace: "namespace", Name: "using-default-health-check-port"},
158159
Spec: v1.ServiceSpec{
159160
Type: v1.ServiceTypeLoadBalancer,
160-
Ports: []v1.ServicePort{{Port: 80}},
161+
Ports: []v1.ServicePort{{Port: 443}},
161162
},
162163
},
163164
},

0 commit comments

Comments
 (0)