Skip to content

Commit 5695840

Browse files
pranavsriram8YashwantGohokar
authored andcommitted
skip healthcheck port in use for services that are deleted or not of type loadbalancer
1 parent 7231edb commit 5695840

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

pkg/cloudprovider/providers/oci/load_balancer_security_lists.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -680,21 +680,22 @@ func healthCheckPortInUse(serviceLister listersv1.ServiceLister, port int32) (bo
680680
return false, err
681681
}
682682
for _, service := range serviceList {
683-
if service.DeletionTimestamp == nil || service.Spec.Type == api.ServiceTypeLoadBalancer {
684-
if service.Spec.ExternalTrafficPolicy == api.ServiceExternalTrafficPolicyCluster {
685-
// This service is using the default healthcheck port, so we must check if
686-
// any other service is also using this default healthcheck port.
687-
if port == lbNodesHealthCheckPort {
688-
return true, nil
689-
}
690-
} else if service.Spec.ExternalTrafficPolicy == api.ServiceExternalTrafficPolicyLocal {
691-
// This service is using a custom healthcheck port (enabled through setting
692-
// externalTrafficPolicy=Local on the service). As this port is unique
693-
// per service, we know no other service will be using this port too.
694-
if port == service.Spec.HealthCheckNodePort {
695-
// Service with this healthCheckerPort is still not deleted (this would be a "delete listener" call in that case)
696-
return true, nil
697-
}
683+
if service.DeletionTimestamp != nil || service.Spec.Type != api.ServiceTypeLoadBalancer {
684+
continue
685+
}
686+
if service.Spec.ExternalTrafficPolicy == api.ServiceExternalTrafficPolicyCluster {
687+
// This service is using the default healthcheck port, so we must check if
688+
// any other service is also using this default healthcheck port.
689+
if port == lbNodesHealthCheckPort {
690+
return true, nil
691+
}
692+
} else if service.Spec.ExternalTrafficPolicy == api.ServiceExternalTrafficPolicyLocal {
693+
// This service is using a custom healthcheck port (enabled through setting
694+
// externalTrafficPolicy=Local on the service). As this port is unique
695+
// per service, we know no other service will be using this port too.
696+
if port == service.Spec.HealthCheckNodePort {
697+
// Service with this healthCheckerPort is still not deleted (this would be a "delete listener" call in that case)
698+
return true, nil
698699
}
699700
}
700701
}

0 commit comments

Comments
 (0)