-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(Gateway API): improve annotations support #4870
base: master
Are you sure you want to change the base?
feat(Gateway API): improve annotations support #4870
Conversation
Welcome @Dadeos-Menlo! |
Hi @Dadeos-Menlo. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
@abursavich do you think you can do a first review on this PR ? |
b632a81
to
cc10e6d
Compare
What additional documentation do you feel would add clarity? In my opinion the proposed changes merely bring the implementation in line with the existing documentation.
|
In current documentation, the behavior when there are annotations on both Gateway & HTTPRoute is not detailed: no explanation and no example. |
/retitle feat(Gateway API): improve annotations support |
Hi @Dadeos-Menlo . Nice work. Would it be possible to extract the refactoring into a separate pull-request to simplify a review and reduce blast radius?
You could add tests as well that highlights current/incorrect behaviour to it. |
Hi Ivan, In the interests of easing any review I separated the proposed changes into stand-alone commits. The sequence of which were broadly described by the bullet points provided in the initial description. My intention with these stand-alone commits was to mutate the pre-existing implementation, step-by-step, into one that exhibits what I consider to be more desirable behaviour (i.e. the consistent honouring of annotations assigned to Gateway resources). The initial commit seeks to introduce additional unit-tests/expectations, regarding the The second commit seeks to refactor the existing implementation into a form conducive to tracking the relationship between …Route and Gateway resources throughout the processing required to generate the The third commit builds upon the refactored implementation in order to provide the intended additional functionality; namely the consistent honouring of annotations assigned to Gateway resources. This commit introduces new unit-test scenarios, associated with annotations being assigned to Gateway resources and in support of the proposed new behaviours, whilst avoiding modification of existing unit-test scenarios, thus demonstrating no regressions with respect to pre-existing asserted behaviours (NB: The essence of the "DualStack" tests were incorporated into the Gateway annotation orientated unit-test scenarios introduced). The forth, and final, commit modifies the documentation as requested. In direct response to your questions:
Whilst this would be possible, I consider that the proposed changes belong together in a single pull-request, and have made efforts to separate the mutations applied as outlined above.
I consider that unit-test scenarios asserting the intended behaviour of annotations assigned to Gateway resources have been introduced, as part of the behavioural modifications proposed in commit three. I hope that the explanation offered above aids your understanding and consideration. Thank you for your interest in these proposed changes. Regards, Peter |
Thanks for the explanation. I agree with the overall direction of this change, so I won't raise any objections. However, given the complexity of the changes, (I do not possess maintainer access), I will be unable to formally approve this pull request, which is not an issue anyway.
This make sense. To potentially accelerate the approval process, consider splitting the refactoring from the new functionality in the next pull request. This would allow community members to contribute more easily by focusing on smaller, more manageable changes. |
source/gateway.go
Outdated
hosts[host] = struct{}{} | ||
} | ||
} | ||
// TODO: The ignore-hostname-annotation flag help says "valid only when using fqdn-template" |
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.
The help is valid.
This option has been introduced with PR #745.
As you can see, it's still checked:
https://github.com/kubernetes-sigs/external-dns/blob/master/pkg/apis/externaldns/validation/validation.go#L84
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.
This comment was merely relocated from the pre-existing sources…
I suspect that the observation being made by its original author is that the referenced help states that:
"Ignore hostname annotation when generating DNS names, valid only when --fqdn-template is set (default: false)"
and yet various implementations, including this one, do not check that the value of FQDNTemplate
has been specified. However, they may not have appreciated the additional validation to which you refer that appears to preclude the IgnoreHostnameAnnotation
value being true
whilst the FQDNTemplate
is empty.
Would you like me to eliminate the "TODO: …" comment?
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.
Yes, please
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.
304439d
to
b75786f
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
} | ||
if !match { | ||
log.Debugf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rtHosts) | ||
log.Debugf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rt.Hostnames()) |
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.
log.Debugf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rt.Hostnames()) | |
log.Warnf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rt.Hostnames()) |
Shouldn't this be a warning ?
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.
Quite possibly; this comment was merely relocated from the pre-existing sources…
I'm not familiar with the desired log verbosity and was attempting to minimise unnecessary changes in both behaviour and implementation.
I'll try to deduce what, if anything, that log is attempting to convey with a view to either upgrading it or eliminating it.
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.
I see no compelling reason to change this logging…
It's arguably debug level algorithm diagnostics, similar to several other log.Debugf(…)
function calls throughout the pre-existing implementation. The algorithm in question is broadly a combination of the logic outlined beneath the GatewaySpec.listeners and HTTPRouteSpec.hostnames specifications. This particular log line appears to pertain to a scenario whereby a …Route object has been accepted by a Gateway controller implementation (i.e. there is an affirmative entry in the RouteStatus.parents list) but that this implementation of the algorithm logic does not consider there to be a match between the parent Gateway's listeners and the …Route in question.
One would perhaps not expect such a scenario to occur. If such a scenario does occur then it might be a consequence of an issue with the Gateway controller or an issue with this implementation.
I'm not particularly familiar with the log level semantics employed by external-dns, or Kubernetes as a whole, but I tend to employ:
- Error - something that is never expected to happen and is generally catastrophic
- Warn - something that is expected to happen rarely and is potentially problematic
- Debug - something that is potentially of interest to someone investigating in detail
A case could be made for upgrading most of the existing debug level logging to warn but, given the prior art, a log level of debug seems reasonable to me in this instance.
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.
I'm not particularly familiar with the log level semantics employed by external-dns, or Kubernetes as a whole, but I tend to employ:
* Error - something that is never expected to happen and is generally catastrophic
* Warn - something that is expected to happen rarely and is potentially problematic
* Debug - something that is potentially of interest to someone investigating in detail
100% aligned with that.
A case could be made for upgrading most of the existing debug level logging to warn but, given the prior art, a log level of debug seems reasonable to me in this instance.
Works for me, even if we should not restrain ourselves from the current prior art.
@ivankatliarchuk wdyt ?
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.
Debug is fine. I usually find myselft silencing WARN level as could not action on them
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.
Could you please also provide a way to test this manually with manifests and kubectl commands for affected resources?
} | ||
if !match { | ||
log.Debugf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rtHosts) | ||
log.Debugf("Gateway %s/%s section %q does not match %s %s/%s hostnames %q", namespace, ref.Name, section, c.src.rtKind, meta.Namespace, meta.Name, rt.Hostnames()) |
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.
Debug is fine. I usually find myselft silencing WARN level as could not action on them
@@ -246,47 +245,3 @@ func TestIsDNS1123Domain(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestDualStackLabel(t *testing.T) { |
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.
Is this test moved or removed?
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.
As noted previously…
NB: The essence of the "DualStack" tests were incorporated into the Gateway annotation orientated unit-test scenarios introduced
Manual testing is generally inconvenient. This is especially the case when dealing with systems like "external-dns" that cover a significant expanse of external dependencies. That's why unit-tests are provided. However, the following Kubernetes specification should offer a reasonable starting point for any manual testing that you may wish to perform:
Once customised to specify a |
Agree is inconvenient to test manually, but there is no other way to validate things, unless you have a proposal. I understand that this change was not tested on a cluster then, is my assumption correct? Unit tests is just another layer, you can't test everything with them. For example, I could not validate with unit tests, that the feature is actually working. At the moment there are no automated acceptance tests or conformance tests. Could you please as well share the arguments required, and add to an example an annotation external-dns.alpha.kubernetes.io/ttl. Am I understand correctly, the change was made, in a way, if it's set on HTTPRoute and on Gateway, it will be merge to yield the lowest specified value? Worth to update |
No; your assumption is incorrect.
You're probably not writing the correct unit tests then.
I'm sorry; I don't understand what you mean by this request.
You're understanding is correct; (see: description):
and associated TTLGateway unit-test. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description
The generation of DNS records from Gateway API resources involves combining information from a …Route resource and a Gateway resource. The current implementation, for the most part, only considers annotations from the Route resource. There are potential scenarios whereby it may be more convenient to assign annotations to the Gateway resource, thus ensuring that all DNS records associated with the given Gateway are similarly effected. An extreme example of such a scenario being when no Hostname information is specified (i.e. the given Gateway should accept any communication, irrespective of the DNS name used to establish it) but that a DNS record is desired to cover all Routes associated with the Gateway; in which case it would be convenient to apply an
external-dns.alpha.kubernetes.io/hostname
annotation to the Gateway itself, rather than having to apply annotations to every associated Route and having to deal with the potential confusion arising from precisely which Route owns the shared DNS record.The proposed changes include:
resource
endpoint label ownership to all of the Gateway related unit-testsEndpoint
generation in order to preserve the relationship between Route and Gateway resourcesEndpoint
external-dns.alpha.kubernetes.io/ttl
annotations are merged to yield the lowest specified valueexternal-dns.alpha.kubernetes.io/hostname
is specified on a Gateway and that Gateway is the only Gateway contributing to anEndpoint
the resource label is recorded as referring to the Gateway rather than the RouteNo changes to the documentation are proposed because it currently implies that annotations on Gateway resources are supported, whereas in reality such annotations are only honoured when specified on Route resources.
Checklist