Break out of the loop when active endpoint is found

This commit is contained in:
Ted Yu 2019-09-11 09:01:06 -07:00 committed by Ted Yu
parent 8b4fd4104d
commit 31581e7cb5

View File

@ -210,6 +210,7 @@ func (c *AvailableConditionController) sync(key string) error {
if port.Port == *servicePort {
foundPort = true
portName = port.Name
break
}
}
if !foundPort {
@ -238,6 +239,7 @@ func (c *AvailableConditionController) sync(key string) error {
return err
}
hasActiveEndpoints := false
outer:
for _, subset := range endpoints.Subsets {
if len(subset.Addresses) == 0 {
continue
@ -245,6 +247,7 @@ func (c *AvailableConditionController) sync(key string) error {
for _, endpointPort := range subset.Ports {
if endpointPort.Name == portName {
hasActiveEndpoints = true
break outer
}
}
}