fix(endpoint): compare every target in Targets.Same - #6686
Conversation
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @PixiBixi. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Could you provide real kubernetes setup, where the problem could be reproduced? I'm not fully understand what this actually fixing, I couldn't construct a failing scenario against current setup in my head. Looks more like a correctness of sorting algorithm at the moment. I see here a behavior change bundled into what's framed as a pure bug fix aka "alphabetically first" to "first in source order". Most likely low risk.
|
ivankatliarchuk
left a comment
There was a problem hiding this comment.
Same and IsLess still each hand-roll their own IP-parse-and-compare loop, and the Len/Less/Swap sort.Interface trio only exists to support the old in-place sort.Sort/sort.Stable calls this PR is replacing - nothing else in the repo calls sort on a Targets value or uses those methods directly.
|
/ok-to-test |
Coverage Report for CI Build 33436331167Coverage decreased (-0.006%) to 82.075%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Same returned as soon as it hit a differing pair that both parsed as IP addresses, so that single pair decided the whole comparison. A record whose first target was an IPv6 written in an equivalent but different form (shortened vs expanded) therefore reported Same even when the remaining targets differed, plan never emitted the update, and the record silently stopped being reconciled. Keep comparing the remaining targets instead of returning, and compare the parsed netip.Addr values directly rather than their string forms. Signed-off-by: Jeremy Delgado <PixiBixi@users.noreply.github.com>
cab33c7 to
bed9594
Compare
|
You're right on both counts, I dropped the Repro: The provider hands back Order: confirmed. The source produced Amortization: also confirmed, and the cost was worse than the lost amortization. The in-place mutation is still real, |
Follow up on review: wire a fake Kubernetes client, the service source, the TXT registry and a provider that canonicalizes IPv6 targets the way Route53, Cloudflare and Azure DNS do, then change only the second target of a record whose first target is an expanded IPv6. Before the Targets.Same fix the change never reaches the provider and the record keeps its old value with nothing logged. Signed-off-by: Jeremy Delgado <PixiBixi@users.noreply.github.com>
1a71c55 to
b69eca9
Compare
| @@ -0,0 +1,140 @@ | |||
| /* | |||
There was a problem hiding this comment.
not too sure about this tests, what are they for?
|
PR needs rebase. DetailsInstructions 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. |
What does it do ?
Targets.Samereturned on the first differing pair when both sides parsed as IPaddresses, so that one pair decided the whole comparison. It now keeps going
through the rest of the targets.
While in there,
SameandIsLessno longer sort their receiver and theirargument in place.
Motivation
Found this reading through the plan and registry path. If the first target is an
IPv6 that the provider returns in a different form than the source has it
(shortened vs expanded), the two strings differ, both parse as IPs, and the
function returns "same" right there. Anything after it is never looked at.
plan.targetChangeduses this, so no update gets planned and the record staysstale. No error, nothing in the logs.
The in-place sort is a separate thing I noticed while writing the test.
plancalls
Sameon endpoints the TXT registry keeps in its cache, so the reorderingsurvives into the next reconciliation. It sorts a copy now, and skips it when the
targets are already in order.
More