-
Notifications
You must be signed in to change notification settings - Fork 2.9k
chore: fix two bugs associated with istio ingress annotation processing #6439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,11 @@ import ( | |
| "sigs.k8s.io/external-dns/source/template" | ||
| ) | ||
|
|
||
| // IstioGatewayIngressSource is the annotation used to determine if the gateway is implemented by an Ingress object | ||
| // instead of a standard LoadBalancer service type | ||
| // Using var instead of const because annotation keys can be customized | ||
| var IstioGatewayIngressSource = annotations.Ingress | ||
| // IstioGatewayIngressSource returns the annotation key used to determine if the gateway | ||
| // is implemented by an Ingress object instead of a standard LoadBalancer service type. | ||
| // This must be a function (not a package-level var) because the annotation prefix can | ||
| // be customized at runtime via --annotation-prefix / SetAnnotationPrefix. | ||
| func IstioGatewayIngressSource() string { return annotations.Ingress } | ||
|
|
||
| // gatewaySource is an implementation of Source for Istio Gateway objects. | ||
| // The gateway implementation uses the spec.servers.hosts values for the hostnames. | ||
|
|
@@ -152,7 +153,8 @@ func (sc *gatewaySource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, err | |
|
|
||
| gwEndpoints, err := sc.endpointsFromGateway(gwHostnames, gateway) | ||
| if err != nil { | ||
| return nil, err | ||
| log.Warnf("Could not generate endpoints for gateway '%s/%s': %v", gateway.Namespace, gateway.Name, err) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need other maintainers view on that one. From high level perspective it make sense, but very much on the edge. As there is is a behaviour change. The PR's blanket warn+continue on endpointsFromGateway is API change for a specific reason - look at what targetsFromGateway can return errors from: EndpointTargetsFromServices failing means the informer/API is broken — that affects every gateway, not one. Swallowing that with warn+continue would silently skip all gateways each cycle with no escalation. There's also a double-logging bug: targetsFromIngress already calls log.Error(err) before returning, and then the PR adds log.Warnf(...) at the caller - two log lines at two different levels for the same event. The error handling belongs inside targetsFromIngress, not at the Endpoints() loop level. When the annotation references an ingress that doesn't exist, that's not an error — it means zero targets for that gateway (the same outcome as a service with no load balancer IPs, which already returns empty with no error). This is not a call for action, but a probabal change |
||
| continue | ||
| } | ||
|
|
||
| // apply template if host is missing on gateway | ||
|
|
@@ -167,7 +169,8 @@ func (sc *gatewaySource) Endpoints(_ context.Context) ([]*endpoint.Endpoint, err | |
| }, | ||
| ) | ||
| if err != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be reverted. A template error is a configuration error that will fail for every resource on every reconciliation cycle, producing a warning flood without ever halting or surfacing the root cause. Every other source propagates template errors up. |
||
| return nil, err | ||
| log.Warnf("Could not apply template for gateway '%s/%s': %v", gateway.Namespace, gateway.Name, err) | ||
| continue | ||
| } | ||
|
|
||
| if endpoint.HasNoEmptyEndpoints(gwEndpoints, types.IstioGateway, gateway) { | ||
|
|
@@ -220,7 +223,7 @@ func (sc *gatewaySource) targetsFromGateway(gateway *networkingv1.Gateway) (endp | |
| return targets, nil | ||
| } | ||
|
|
||
| ingressStr, ok := gateway.Annotations[IstioGatewayIngressSource] | ||
| ingressStr, ok := gateway.Annotations[IstioGatewayIngressSource()] | ||
| if ok && ingressStr != "" { | ||
| return sc.targetsFromIngress(ingressStr, gateway) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically not clear why this wrapper is even required, we could just remove the wrapper, use annotations.Ingress directly, to satisfy split brain annotation.
The bug related to that feature #5923
We may going to have similar issues elsewhere.