From a961e39e55711d1517efe074e8913cd7d7dbbd23 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Wed, 27 Sep 2023 23:09:09 -0700 Subject: [PATCH] Improve log messages --- source/ambassador_host.go | 2 +- source/contour_httpproxy.go | 12 ++++++------ source/f5_virtualserver.go | 12 +++++++----- source/gateway.go | 2 +- source/gloo_proxy.go | 6 +++++- source/ingress.go | 12 ++++++------ source/istio_gateway.go | 6 +++--- source/istio_virtualservice.go | 12 ++++++------ source/kong_tcpingress.go | 6 +++--- source/node.go | 2 +- source/openshift_route.go | 12 ++++++------ source/service.go | 2 +- source/skipper_routegroup.go | 13 +++++++------ source/source.go | 14 +++++++++----- source/source_test.go | 11 +---------- source/traefik_proxy.go | 18 +++++++++--------- 16 files changed, 72 insertions(+), 70 deletions(-) diff --git a/source/ambassador_host.go b/source/ambassador_host.go index 4e131a9c60..2bb4b924e5 100644 --- a/source/ambassador_host.go +++ b/source/ambassador_host.go @@ -170,7 +170,7 @@ func (sc *ambassadorHostSource) endpointsFromHost(ctx context.Context, host *amb resource := fmt.Sprintf("host/%s/%s", host.Namespace, host.Name) annotations := host.Annotations - ttl := getTTLFromAnnotations(annotations) + ttl := getTTLFromAnnotations(annotations, resource) if host.Spec != nil { hostname := host.Spec.Hostname diff --git a/source/contour_httpproxy.go b/source/contour_httpproxy.go index 814487347b..818646e420 100644 --- a/source/contour_httpproxy.go +++ b/source/contour_httpproxy.go @@ -186,7 +186,9 @@ func (sc *httpProxySource) endpointsFromTemplate(httpProxy *projectcontour.HTTPP return nil, err } - ttl := getTTLFromAnnotations(httpProxy.Annotations) + resource := fmt.Sprintf("HTTPProxy/%s/%s", httpProxy.Namespace, httpProxy.Name) + + ttl := getTTLFromAnnotations(httpProxy.Annotations, resource) targets := getTargetsFromTargetAnnotation(httpProxy.Annotations) if len(targets) == 0 { @@ -202,8 +204,6 @@ func (sc *httpProxySource) endpointsFromTemplate(httpProxy *projectcontour.HTTPP providerSpecific, setIdentifier := getProviderSpecificAnnotations(httpProxy.Annotations) - resource := fmt.Sprintf("HTTPProxy/%s/%s", httpProxy.Namespace, httpProxy.Name) - var endpoints []*endpoint.Endpoint for _, hostname := range hostnames { endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific, setIdentifier, resource)...) @@ -249,7 +249,9 @@ func (sc *httpProxySource) endpointsFromHTTPProxy(httpProxy *projectcontour.HTTP return nil, nil } - ttl := getTTLFromAnnotations(httpProxy.Annotations) + resource := fmt.Sprintf("HTTPProxy/%s/%s", httpProxy.Namespace, httpProxy.Name) + + ttl := getTTLFromAnnotations(httpProxy.Annotations, resource) targets := getTargetsFromTargetAnnotation(httpProxy.Annotations) @@ -266,8 +268,6 @@ func (sc *httpProxySource) endpointsFromHTTPProxy(httpProxy *projectcontour.HTTP providerSpecific, setIdentifier := getProviderSpecificAnnotations(httpProxy.Annotations) - resource := fmt.Sprintf("HTTPProxy/%s/%s", httpProxy.Namespace, httpProxy.Name) - var endpoints []*endpoint.Endpoint if virtualHost := httpProxy.Spec.VirtualHost; virtualHost != nil { diff --git a/source/f5_virtualserver.go b/source/f5_virtualserver.go index 6db082db00..f9de0a8ba3 100644 --- a/source/f5_virtualserver.go +++ b/source/f5_virtualserver.go @@ -147,7 +147,9 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f var endpoints []*endpoint.Endpoint for _, virtualServer := range virtualServers { - ttl := getTTLFromAnnotations(virtualServer.Annotations) + resource := fmt.Sprintf("f5-virtualserver/%s/%s", virtualServer.Namespace, virtualServer.Name) + + ttl := getTTLFromAnnotations(virtualServer.Annotations, resource) if virtualServer.Spec.VirtualServerAddress != "" { ep := &endpoint.Endpoint{ @@ -160,7 +162,7 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f RecordTTL: ttl, } - vs.setResourceLabel(virtualServer, ep) + vs.setResourceLabel(ep, resource) endpoints = append(endpoints, ep) continue } @@ -176,7 +178,7 @@ func (vs *f5VirtualServerSource) endpointsFromVirtualServers(virtualServers []*f RecordTTL: ttl, } - vs.setResourceLabel(virtualServer, ep) + vs.setResourceLabel(ep, resource) endpoints = append(endpoints, ep) continue } @@ -232,6 +234,6 @@ func (vs *f5VirtualServerSource) filterByAnnotations(virtualServers []*f5.Virtua return filteredList, nil } -func (vs *f5VirtualServerSource) setResourceLabel(virtualServer *f5.VirtualServer, ep *endpoint.Endpoint) { - ep.Labels[endpoint.ResourceLabelKey] = fmt.Sprintf("f5-virtualserver/%s/%s", virtualServer.Namespace, virtualServer.Name) +func (vs *f5VirtualServerSource) setResourceLabel(ep *endpoint.Endpoint, resource string) { + ep.Labels[endpoint.ResourceLabelKey] = resource } diff --git a/source/gateway.go b/source/gateway.go index 378c751c84..78e8ac5685 100644 --- a/source/gateway.go +++ b/source/gateway.go @@ -230,7 +230,7 @@ func (src *gatewayRouteSource) Endpoints(ctx context.Context) ([]*endpoint.Endpo // Create endpoints from hostnames and targets. resource := fmt.Sprintf("%s/%s/%s", kind, meta.Namespace, meta.Name) providerSpecific, setIdentifier := getProviderSpecificAnnotations(annots) - ttl := getTTLFromAnnotations(annots) + ttl := getTTLFromAnnotations(annots, resource) for host, targets := range hostTargets { endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific, setIdentifier, resource)...) } diff --git a/source/gloo_proxy.go b/source/gloo_proxy.go index 510878c42e..69ca9234d6 100644 --- a/source/gloo_proxy.go +++ b/source/gloo_proxy.go @@ -19,6 +19,7 @@ package source import ( "context" "encoding/json" + "fmt" "strings" log "github.com/sirupsen/logrus" @@ -150,13 +151,16 @@ func (gs *glooSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro func (gs *glooSource) generateEndpointsFromProxy(ctx context.Context, proxy *proxy, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { endpoints := []*endpoint.Endpoint{} + + resource := fmt.Sprintf("proxy/%s/%s", proxy.Metadata.Namespace, proxy.Metadata.Name) + for _, listener := range proxy.Spec.Listeners { for _, virtualHost := range listener.HTTPListener.VirtualHosts { annotations, err := gs.annotationsFromProxySource(ctx, virtualHost) if err != nil { return nil, err } - ttl := getTTLFromAnnotations(annotations) + ttl := getTTLFromAnnotations(annotations, resource) providerSpecific, setIdentifier := getProviderSpecificAnnotations(annotations) for _, domain := range virtualHost.Domains { endpoints = append(endpoints, endpointsForHostname(strings.TrimSuffix(domain, "."), targets, ttl, providerSpecific, setIdentifier, "")...) diff --git a/source/ingress.go b/source/ingress.go index 223362775c..14676e8cef 100644 --- a/source/ingress.go +++ b/source/ingress.go @@ -188,7 +188,9 @@ func (sc *ingressSource) endpointsFromTemplate(ing *networkv1.Ingress) ([]*endpo return nil, err } - ttl := getTTLFromAnnotations(ing.Annotations) + resource := fmt.Sprintf("ingress/%s/%s", ing.Namespace, ing.Name) + + ttl := getTTLFromAnnotations(ing.Annotations, resource) targets := getTargetsFromTargetAnnotation(ing.Annotations) if len(targets) == 0 { @@ -197,8 +199,6 @@ func (sc *ingressSource) endpointsFromTemplate(ing *networkv1.Ingress) ([]*endpo providerSpecific, setIdentifier := getProviderSpecificAnnotations(ing.Annotations) - resource := fmt.Sprintf("ingress/%s/%s", ing.Namespace, ing.Name) - var endpoints []*endpoint.Endpoint for _, hostname := range hostnames { endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific, setIdentifier, resource)...) @@ -286,7 +286,9 @@ func (sc *ingressSource) setDualstackLabel(ingress *networkv1.Ingress, endpoints // endpointsFromIngress extracts the endpoints from ingress object func endpointsFromIngress(ing *networkv1.Ingress, ignoreHostnameAnnotation bool, ignoreIngressTLSSpec bool, ignoreIngressRulesSpec bool) []*endpoint.Endpoint { - ttl := getTTLFromAnnotations(ing.Annotations) + resource := fmt.Sprintf("ingress/%s/%s", ing.Namespace, ing.Name) + + ttl := getTTLFromAnnotations(ing.Annotations, resource) targets := getTargetsFromTargetAnnotation(ing.Annotations) @@ -296,8 +298,6 @@ func endpointsFromIngress(ing *networkv1.Ingress, ignoreHostnameAnnotation bool, providerSpecific, setIdentifier := getProviderSpecificAnnotations(ing.Annotations) - resource := fmt.Sprintf("ingress/%s/%s", ing.Namespace, ing.Name) - // Gather endpoints defined on hosts sections of the ingress var definedHostsEndpoints []*endpoint.Endpoint // Skip endpoints if we do not want entries from Rules section diff --git a/source/istio_gateway.go b/source/istio_gateway.go index b398b22b10..1c780c31c9 100644 --- a/source/istio_gateway.go +++ b/source/istio_gateway.go @@ -306,8 +306,10 @@ func (sc *gatewaySource) endpointsFromGateway(ctx context.Context, hostnames []s var endpoints []*endpoint.Endpoint var err error + resource := fmt.Sprintf("gateway/%s/%s", gateway.Namespace, gateway.Name) + annotations := gateway.Annotations - ttl := getTTLFromAnnotations(annotations) + ttl := getTTLFromAnnotations(annotations, resource) targets := getTargetsFromTargetAnnotation(annotations) if len(targets) == 0 { @@ -319,8 +321,6 @@ func (sc *gatewaySource) endpointsFromGateway(ctx context.Context, hostnames []s providerSpecific, setIdentifier := getProviderSpecificAnnotations(annotations) - resource := fmt.Sprintf("gateway/%s/%s", gateway.Namespace, gateway.Name) - for _, host := range hostnames { endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific, setIdentifier, resource)...) } diff --git a/source/istio_virtualservice.go b/source/istio_virtualservice.go index 747033f688..1eed91d1a8 100644 --- a/source/istio_virtualservice.go +++ b/source/istio_virtualservice.go @@ -222,11 +222,11 @@ func (sc *virtualServiceSource) endpointsFromTemplate(ctx context.Context, virtu return nil, err } - ttl := getTTLFromAnnotations(virtualService.Annotations) + resource := fmt.Sprintf("virtualservice/%s/%s", virtualService.Namespace, virtualService.Name) - providerSpecific, setIdentifier := getProviderSpecificAnnotations(virtualService.Annotations) + ttl := getTTLFromAnnotations(virtualService.Annotations, resource) - resource := fmt.Sprintf("virtualservice/%s/%s", virtualService.Namespace, virtualService.Name) + providerSpecific, setIdentifier := getProviderSpecificAnnotations(virtualService.Annotations) var endpoints []*endpoint.Endpoint for _, hostname := range hostnames { @@ -311,14 +311,14 @@ func (sc *virtualServiceSource) endpointsFromVirtualService(ctx context.Context, var endpoints []*endpoint.Endpoint var err error - ttl := getTTLFromAnnotations(virtualservice.Annotations) + resource := fmt.Sprintf("virtualservice/%s/%s", virtualservice.Namespace, virtualservice.Name) + + ttl := getTTLFromAnnotations(virtualservice.Annotations, resource) targetsFromAnnotation := getTargetsFromTargetAnnotation(virtualservice.Annotations) providerSpecific, setIdentifier := getProviderSpecificAnnotations(virtualservice.Annotations) - resource := fmt.Sprintf("virtualservice/%s/%s", virtualservice.Namespace, virtualservice.Name) - for _, host := range virtualservice.Spec.Hosts { if host == "" || host == "*" { continue diff --git a/source/kong_tcpingress.go b/source/kong_tcpingress.go index 9c1b5fc85e..ced4db4fdb 100644 --- a/source/kong_tcpingress.go +++ b/source/kong_tcpingress.go @@ -202,11 +202,11 @@ func (sc *kongTCPIngressSource) setDualstackLabel(tcpIngress *TCPIngress, endpoi func (sc *kongTCPIngressSource) endpointsFromTCPIngress(tcpIngress *TCPIngress, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint - ttl := getTTLFromAnnotations(tcpIngress.Annotations) + resource := fmt.Sprintf("tcpingress/%s/%s", tcpIngress.Namespace, tcpIngress.Name) - providerSpecific, setIdentifier := getProviderSpecificAnnotations(tcpIngress.Annotations) + ttl := getTTLFromAnnotations(tcpIngress.Annotations, resource) - resource := fmt.Sprintf("tcpingress/%s/%s", tcpIngress.Namespace, tcpIngress.Name) + providerSpecific, setIdentifier := getProviderSpecificAnnotations(tcpIngress.Annotations) hostnameList := getHostnamesFromAnnotations(tcpIngress.Annotations) for _, hostname := range hostnameList { diff --git a/source/node.go b/source/node.go index d0f84820c0..ef7b795025 100644 --- a/source/node.go +++ b/source/node.go @@ -102,7 +102,7 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro log.Debugf("creating endpoint for node %s", node.Name) - ttl := getTTLFromAnnotations(node.Annotations) + ttl := getTTLFromAnnotations(node.Annotations, fmt.Sprintf("node/%s", node.Name)) // create new endpoint with the information we already have ep := &endpoint.Endpoint{ diff --git a/source/openshift_route.go b/source/openshift_route.go index 02256a7c34..dd50913f61 100644 --- a/source/openshift_route.go +++ b/source/openshift_route.go @@ -174,7 +174,9 @@ func (ors *ocpRouteSource) endpointsFromTemplate(ocpRoute *routev1.Route) ([]*en return nil, err } - ttl := getTTLFromAnnotations(ocpRoute.Annotations) + resource := fmt.Sprintf("route/%s/%s", ocpRoute.Namespace, ocpRoute.Name) + + ttl := getTTLFromAnnotations(ocpRoute.Annotations, resource) targets := getTargetsFromTargetAnnotation(ocpRoute.Annotations) if len(targets) == 0 { @@ -184,8 +186,6 @@ func (ors *ocpRouteSource) endpointsFromTemplate(ocpRoute *routev1.Route) ([]*en providerSpecific, setIdentifier := getProviderSpecificAnnotations(ocpRoute.Annotations) - resource := fmt.Sprintf("route/%s/%s", ocpRoute.Namespace, ocpRoute.Name) - var endpoints []*endpoint.Endpoint for _, hostname := range hostnames { endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific, setIdentifier, resource)...) @@ -227,7 +227,9 @@ func (ors *ocpRouteSource) filterByAnnotations(ocpRoutes []*routev1.Route) ([]*r func (ors *ocpRouteSource) endpointsFromOcpRoute(ocpRoute *routev1.Route, ignoreHostnameAnnotation bool) []*endpoint.Endpoint { var endpoints []*endpoint.Endpoint - ttl := getTTLFromAnnotations(ocpRoute.Annotations) + resource := fmt.Sprintf("route/%s/%s", ocpRoute.Namespace, ocpRoute.Name) + + ttl := getTTLFromAnnotations(ocpRoute.Annotations, resource) targets := getTargetsFromTargetAnnotation(ocpRoute.Annotations) targetsFromRoute, host := ors.getTargetsFromRouteStatus(ocpRoute.Status) @@ -238,8 +240,6 @@ func (ors *ocpRouteSource) endpointsFromOcpRoute(ocpRoute *routev1.Route, ignore providerSpecific, setIdentifier := getProviderSpecificAnnotations(ocpRoute.Annotations) - resource := fmt.Sprintf("route/%s/%s", ocpRoute.Namespace, ocpRoute.Name) - if host != "" { endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific, setIdentifier, resource)...) } diff --git a/source/service.go b/source/service.go index c1883d026f..7cf20e5aad 100644 --- a/source/service.go +++ b/source/service.go @@ -460,7 +460,7 @@ func (sc *serviceSource) setResourceLabel(service *v1.Service, endpoints []*endp func (sc *serviceSource) generateEndpoints(svc *v1.Service, hostname string, providerSpecific endpoint.ProviderSpecific, setIdentifier string, useClusterIP bool) []*endpoint.Endpoint { hostname = strings.TrimSuffix(hostname, ".") - ttl := getTTLFromAnnotations(svc.Annotations) + ttl := getTTLFromAnnotations(svc.Annotations, fmt.Sprintf("service/%s/%s", svc.Namespace, svc.Name)) epA := &endpoint.Endpoint{ RecordTTL: ttl, diff --git a/source/skipper_routegroup.go b/source/skipper_routegroup.go index 7b722d5cd1..2c3475ac4e 100644 --- a/source/skipper_routegroup.go +++ b/source/skipper_routegroup.go @@ -300,8 +300,10 @@ func (sc *routeGroupSource) endpointsFromTemplate(rg *routeGroup) ([]*endpoint.E hostnames := buf.String() + resource := fmt.Sprintf("routegroup/%s/%s", rg.Metadata.Namespace, rg.Metadata.Name) + // error handled in endpointsFromRouteGroup(), otherwise duplicate log - ttl := getTTLFromAnnotations(rg.Metadata.Annotations) + ttl := getTTLFromAnnotations(rg.Metadata.Annotations, resource) targets := getTargetsFromTargetAnnotation(rg.Metadata.Annotations) @@ -311,8 +313,6 @@ func (sc *routeGroupSource) endpointsFromTemplate(rg *routeGroup) ([]*endpoint.E providerSpecific, setIdentifier := getProviderSpecificAnnotations(rg.Metadata.Annotations) - resource := fmt.Sprintf("routegroup/%s/%s", rg.Metadata.Namespace, rg.Metadata.Name) - var endpoints []*endpoint.Endpoint // splits the FQDN template and removes the trailing periods hostnameList := strings.Split(strings.Replace(hostnames, " ", "", -1), ",") @@ -336,7 +336,10 @@ func (sc *routeGroupSource) setRouteGroupDualstackLabel(rg *routeGroup, eps []*e // annotation logic ported from source/ingress.go without Spec.TLS part, because it'S not supported in RouteGroup func (sc *routeGroupSource) endpointsFromRouteGroup(rg *routeGroup) []*endpoint.Endpoint { endpoints := []*endpoint.Endpoint{} - ttl := getTTLFromAnnotations(rg.Metadata.Annotations) + + resource := fmt.Sprintf("routegroup/%s/%s", rg.Metadata.Namespace, rg.Metadata.Name) + + ttl := getTTLFromAnnotations(rg.Metadata.Annotations, resource) targets := getTargetsFromTargetAnnotation(rg.Metadata.Annotations) if len(targets) == 0 { @@ -352,8 +355,6 @@ func (sc *routeGroupSource) endpointsFromRouteGroup(rg *routeGroup) []*endpoint. providerSpecific, setIdentifier := getProviderSpecificAnnotations(rg.Metadata.Annotations) - resource := fmt.Sprintf("routegroup/%s/%s", rg.Metadata.Namespace, rg.Metadata.Name) - for _, src := range rg.Spec.Hosts { if src == "" { continue diff --git a/source/source.go b/source/source.go index fb1a117f71..6af02ec319 100644 --- a/source/source.go +++ b/source/source.go @@ -87,7 +87,7 @@ type Source interface { AddEventHandler(context.Context, func()) } -func getTTLFromAnnotations(annotations map[string]string) endpoint.TTL { +func getTTLFromAnnotations(annotations map[string]string, resource string) endpoint.TTL { ttlNotConfigured := endpoint.TTL(0) ttlAnnotation, exists := annotations[ttlAnnotationKey] if !exists { @@ -95,7 +95,7 @@ func getTTLFromAnnotations(annotations map[string]string) endpoint.TTL { } ttlValue, err := parseTTL(ttlAnnotation) if err != nil { - log.Warnf("\"%v\" is not a valid TTL value", ttlAnnotation) + log.Warnf("%s: \"%v\" is not a valid TTL value: %v", resource, ttlAnnotation, err) return ttlNotConfigured } if ttlValue < ttlMinimum || ttlValue > ttlMaximum { @@ -112,9 +112,13 @@ func getTTLFromAnnotations(annotations map[string]string) endpoint.TTL { // Note: for durations like "1.5s" the fraction is omitted (resulting in 1 second // for the example). func parseTTL(s string) (ttlSeconds int64, err error) { - ttlDuration, err := time.ParseDuration(s) - if err != nil { - return strconv.ParseInt(s, 10, 64) + ttlDuration, errDuration := time.ParseDuration(s) + if errDuration != nil { + ttlInt, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return 0, errDuration + } + return ttlInt, nil } return int64(ttlDuration.Seconds()), nil diff --git a/source/source_test.go b/source/source_test.go index 4ce933d889..417a3c14e5 100644 --- a/source/source_test.go +++ b/source/source_test.go @@ -30,59 +30,50 @@ func TestGetTTLFromAnnotations(t *testing.T) { title string annotations map[string]string expectedTTL endpoint.TTL - expectedErr error }{ { title: "TTL annotation not present", annotations: map[string]string{"foo": "bar"}, expectedTTL: endpoint.TTL(0), - expectedErr: nil, }, { title: "TTL annotation value is not a number", annotations: map[string]string{ttlAnnotationKey: "foo"}, expectedTTL: endpoint.TTL(0), - expectedErr: fmt.Errorf("\"foo\" is not a valid TTL value"), }, { title: "TTL annotation value is empty", annotations: map[string]string{ttlAnnotationKey: ""}, expectedTTL: endpoint.TTL(0), - expectedErr: fmt.Errorf("\"\" is not a valid TTL value"), }, { title: "TTL annotation value is negative number", annotations: map[string]string{ttlAnnotationKey: "-1"}, expectedTTL: endpoint.TTL(0), - expectedErr: fmt.Errorf("TTL value must be between [%d, %d]", ttlMinimum, ttlMaximum), }, { title: "TTL annotation value is too high", annotations: map[string]string{ttlAnnotationKey: fmt.Sprintf("%d", 1<<32)}, expectedTTL: endpoint.TTL(0), - expectedErr: fmt.Errorf("TTL value must be between [%d, %d]", ttlMinimum, ttlMaximum), }, { title: "TTL annotation value is set correctly using integer", annotations: map[string]string{ttlAnnotationKey: "60"}, expectedTTL: endpoint.TTL(60), - expectedErr: nil, }, { title: "TTL annotation value is set correctly using duration (whole)", annotations: map[string]string{ttlAnnotationKey: "10m"}, expectedTTL: endpoint.TTL(600), - expectedErr: nil, }, { title: "TTL annotation value is set correctly using duration (fractional)", annotations: map[string]string{ttlAnnotationKey: "20.5s"}, expectedTTL: endpoint.TTL(20), - expectedErr: nil, }, } { t.Run(tc.title, func(t *testing.T) { - ttl := getTTLFromAnnotations(tc.annotations) + ttl := getTTLFromAnnotations(tc.annotations, "resource/test") assert.Equal(t, tc.expectedTTL, ttl) }) } diff --git a/source/traefik_proxy.go b/source/traefik_proxy.go index 2c0be154d9..2050cb7ceb 100644 --- a/source/traefik_proxy.go +++ b/source/traefik_proxy.go @@ -647,11 +647,11 @@ func (ts *traefikSource) setDualstackLabelIngressRouteUDP(ingressRoute *IngressR func (ts *traefikSource) endpointsFromIngressRoute(ingressRoute *IngressRoute, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint - ttl := getTTLFromAnnotations(ingressRoute.Annotations) + resource := fmt.Sprintf("ingressroute/%s/%s", ingressRoute.Namespace, ingressRoute.Name) - providerSpecific, setIdentifier := getProviderSpecificAnnotations(ingressRoute.Annotations) + ttl := getTTLFromAnnotations(ingressRoute.Annotations, resource) - resource := fmt.Sprintf("ingressroute/%s/%s", ingressRoute.Namespace, ingressRoute.Name) + providerSpecific, setIdentifier := getProviderSpecificAnnotations(ingressRoute.Annotations) hostnameList := getHostnamesFromAnnotations(ingressRoute.Annotations) for _, hostname := range hostnameList { @@ -681,11 +681,11 @@ func (ts *traefikSource) endpointsFromIngressRoute(ingressRoute *IngressRoute, t func (ts *traefikSource) endpointsFromIngressRouteTCP(ingressRoute *IngressRouteTCP, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint - ttl := getTTLFromAnnotations(ingressRoute.Annotations) + resource := fmt.Sprintf("ingressroutetcp/%s/%s", ingressRoute.Namespace, ingressRoute.Name) - providerSpecific, setIdentifier := getProviderSpecificAnnotations(ingressRoute.Annotations) + ttl := getTTLFromAnnotations(ingressRoute.Annotations, resource) - resource := fmt.Sprintf("ingressroutetcp/%s/%s", ingressRoute.Namespace, ingressRoute.Name) + providerSpecific, setIdentifier := getProviderSpecificAnnotations(ingressRoute.Annotations) hostnameList := getHostnamesFromAnnotations(ingressRoute.Annotations) for _, hostname := range hostnameList { @@ -716,12 +716,12 @@ func (ts *traefikSource) endpointsFromIngressRouteTCP(ingressRoute *IngressRoute func (ts *traefikSource) endpointsFromIngressRouteUDP(ingressRoute *IngressRouteUDP, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint - ttl := getTTLFromAnnotations(ingressRoute.Annotations) + resource := fmt.Sprintf("ingressrouteudp/%s/%s", ingressRoute.Namespace, ingressRoute.Name) + + ttl := getTTLFromAnnotations(ingressRoute.Annotations, resource) providerSpecific, setIdentifier := getProviderSpecificAnnotations(ingressRoute.Annotations) - resource := fmt.Sprintf("ingressrouteudp/%s/%s", ingressRoute.Namespace, ingressRoute.Name) - hostnameList := getHostnamesFromAnnotations(ingressRoute.Annotations) for _, hostname := range hostnameList { endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific, setIdentifier, resource)...)