@@ -584,7 +584,7 @@ func getServiceEndpoints(
584584 // for TCP as this is the default protocol for service ports.
585585 protocols := listProtocols (svc )
586586
587- // Check if the service is an upstream service either by annotation or controller configuration .
587+ // Check if the service is an upstream service through Ingress Class parameters .
588588 var isSvcUpstream bool
589589 ingressClassParameters , err := getIngressClassParametersOrDefault (s )
590590 if err != nil {
@@ -637,19 +637,19 @@ func getEndpoints(
637637 getEndpoints func (string , string ) (* corev1.Endpoints , error ),
638638 isSvcUpstream bool ,
639639) []util.Endpoint {
640- upsServers := []util.Endpoint {}
641-
642640 if s == nil || port == nil {
643- return upsServers
641+ return []util. Endpoint {}
644642 }
645643
646644 // If service is an upstream service...
647645 if isSvcUpstream || annotations .HasServiceUpstreamAnnotation (s .Annotations ) {
648646 // ... return its address as the only endpoint.
649- return append (upsServers , util.Endpoint {
650- Address : s .Name + "." + s .Namespace + ".svc" ,
651- Port : fmt .Sprintf ("%v" , port .Port ),
652- })
647+ return []util.Endpoint {
648+ {
649+ Address : s .Name + "." + s .Namespace + ".svc" ,
650+ Port : fmt .Sprintf ("%v" , port .Port ),
651+ },
652+ }
653653 }
654654
655655 log = log .WithFields (logrus.Fields {
@@ -666,26 +666,22 @@ func getEndpoints(
666666 // ExternalName services
667667 if s .Spec .Type == corev1 .ServiceTypeExternalName {
668668 log .Debug ("found service of type=ExternalName" )
669-
670- return append (upsServers , util.Endpoint {
671- Address : s .Spec .ExternalName ,
672- Port : port .TargetPort .String (),
673- })
674- }
675- if annotations .HasServiceUpstreamAnnotation (s .Annotations ) {
676- return append (upsServers , util.Endpoint {
677- Address : s .Name + "." + s .Namespace + ".svc" ,
678- Port : fmt .Sprintf ("%v" , port .Port ),
679- })
669+ return []util.Endpoint {
670+ {
671+ Address : s .Spec .ExternalName ,
672+ Port : port .TargetPort .String (),
673+ },
674+ }
680675 }
681676
682677 log .Debugf ("fetching endpoints" )
683678 ep , err := getEndpoints (s .Namespace , s .Name )
684679 if err != nil {
685680 log .WithError (err ).Error ("failed to fetch endpoints" )
686- return upsServers
681+ return []util. Endpoint {}
687682 }
688683
684+ upsServers := []util.Endpoint {}
689685 for _ , ss := range ep .Subsets {
690686 for _ , epPort := range ss .Ports {
691687 if ! reflect .DeepEqual (epPort .Protocol , proto ) {
0 commit comments