-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Prevent orphaning records due to label lengths #6431
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
Open
mmiller-sh
wants to merge
1
commit into
kubernetes-sigs:master
Choose a base branch
from
mmiller-sh:fix/orphaned-records
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,13 +339,28 @@ func (im *TXTRegistry) ApplyChanges(ctx context.Context, changes *plan.Changes) | |
| Delete: endpoint.FilterEndpointsByOwnerID(im.ownerID, changes.Delete), | ||
| } | ||
|
|
||
| for _, r := range filteredChanges.Create { | ||
| pendingCreate := filteredChanges.Create | ||
| filteredChanges.Create = make([]*endpoint.Endpoint, 0, len(pendingCreate)) | ||
| for _, r := range pendingCreate { | ||
| if r.Labels == nil { | ||
| r.Labels = make(map[string]string) | ||
| } | ||
| r.Labels[endpoint.OwnerLabelKey] = im.ownerID | ||
|
|
||
| filteredChanges.Create = append(filteredChanges.Create, im.generateTXTRecordWithFilter(r, im.existingTXTs.isAbsent)...) | ||
| // Skip records whose ownership TXT cannot be established; creating | ||
| // them would leak an unreclaimable record into the zone. | ||
| txts := im.generateTXTRecord(r) | ||
| if len(txts) == 0 { | ||
| log.Warnf("Skipping create of %s %s: cannot establish ownership TXT (label exceeds RFC 1035 63-char limit)", r.RecordType, r.DNSName) | ||
| continue | ||
| } | ||
|
|
||
| filteredChanges.Create = append(filteredChanges.Create, r) | ||
| for _, txt := range txts { | ||
| if im.existingTXTs.isAbsent(txt) { | ||
| filteredChanges.Create = append(filteredChanges.Create, txt) | ||
| } | ||
| } | ||
|
Comment on lines
+344
to
+363
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. The change manually re-inlines the isAbsent filter after splitting from generateTXTRecordWithFilter. This is fragile if the helper ever gains new behavior. Not sure if it should be even here |
||
|
|
||
| if im.cacheInterval > 0 { | ||
| im.addToCache(r) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 my understand correct that your fix doesn't bypass the string limit, but simply output log?
Uh oh!
There was an error while loading. Please reload this page.
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.
It prevents the A/AAAA/CNAME records from being created (and orphaned) in the first place when the TXT record names cross the string limit, as well as logging the event.
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.
In my opinion, this change breaks backward compatibility and feels more like a workaround.
I would prefer changing the TXT registry format when the record lenght limit is reached.
What do you think?
Uh oh!
There was an error while loading. Please reload this page.
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 agree this is a workaround. I believe moving the record type into it's own label when it would overflow, ie:
TXT cname.label1.label2.comshould fix the immediate issue. Let me look into what might be needed to safely implement this in a non-breaking way.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.
@u-kai I created a new PR with the alternate approach: #6436
Thanks!
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 have not read that. Actually my view is opposite #6436 (comment). Tool should not change the registry format dynamically. This is an operational hell.
Frankly speaking, the user should have a convention, and manage zone naming. When the DNS hits 50 characters, it's already a signal that it's a time to create a new label/zone