-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(source): add min-ttl support #5641
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
Merged
k8s-ci-robot
merged 20 commits into
kubernetes-sigs:master
from
gofogo:feat-default-ttl
Sep 10, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
be3dd5f
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 51bf78e
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 1e85a23
feat(source/min-ttl): added min-ttl support
ivankatliarchuk ca1ed8d
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 2d9385f
feat(source/min-ttl): added min-ttl support
ivankatliarchuk e65e233
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 9bb7cce
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 7c96dc3
feat(source/min-ttl): added min-ttl support
ivankatliarchuk b5ff56f
feat(source/min-ttl): added min-ttl support
ivankatliarchuk bd4678a
feat(source/min-ttl): added min-ttl support
ivankatliarchuk c9e26ed
Merge branch 'master' into feat-default-ttl
ivankatliarchuk 7722aeb
feat(source/min-ttl): added min-ttl support
ivankatliarchuk a419624
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 5acae05
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 2fb38b7
feat(source/min-ttl): added min-ttl support
ivankatliarchuk 6d125a7
feat(source): add min-ttl support
ivankatliarchuk 0dde96f
feat(source): add min-ttl support
ivankatliarchuk 27d4fae
feat(source): add min-ttl support
ivankatliarchuk 09fe108
feat(source/min-ttl): added min-ttl support
ivankatliarchuk a1e0162
feat(source): add min-ttl support
ivankatliarchuk 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
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
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
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| Copyright 2025 The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package wrappers | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| log "github.com/sirupsen/logrus" | ||
|
|
||
| "sigs.k8s.io/external-dns/endpoint" | ||
| "sigs.k8s.io/external-dns/source" | ||
| ) | ||
|
|
||
| type postProcessor struct { | ||
| source source.Source | ||
| cfg PostProcessorConfig | ||
| } | ||
|
|
||
| type PostProcessorConfig struct { | ||
| ttl int64 | ||
| isConfigured bool | ||
| } | ||
|
|
||
| type PostProcessorOption func(*PostProcessorConfig) | ||
|
|
||
| func WithTTL(ttl time.Duration) PostProcessorOption { | ||
| return func(cfg *PostProcessorConfig) { | ||
| if int64(ttl.Seconds()) > 0 { | ||
| cfg.isConfigured = true | ||
| cfg.ttl = int64(ttl.Seconds()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func NewPostProcessor(source source.Source, opts ...PostProcessorOption) source.Source { | ||
| cfg := PostProcessorConfig{} | ||
| for _, opt := range opts { | ||
| opt(&cfg) | ||
| } | ||
| return &postProcessor{source: source, cfg: cfg} | ||
| } | ||
|
|
||
| func (pp *postProcessor) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error) { | ||
| endpoints, err := pp.source.Endpoints(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if !pp.cfg.isConfigured { | ||
| return endpoints, nil | ||
| } | ||
|
|
||
| for _, ep := range endpoints { | ||
| if ep == nil { | ||
| continue | ||
| } | ||
| ep.WithMinTTL(pp.cfg.ttl) | ||
| // Additional post-processing can be added here. | ||
| } | ||
|
|
||
| return endpoints, nil | ||
| } | ||
|
|
||
| func (pp *postProcessor) AddEventHandler(ctx context.Context, handler func()) { | ||
| log.Debug("postProcessor: adding event handler") | ||
| pp.source.AddEventHandler(ctx, handler) | ||
| } |
Oops, something went wrong.
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.
On other flags / annotation pair, the annotation (always) override the CLI flag.
I have doubt about this specific point of the behavior 🤔 .
@ivankatliarchuk Wdyt ? Do you have a strong motivation behind it that I missed ?
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.
Need to review 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.
So, this is an edge case. Only when value is set to
0. I have tried to change that, but it will require to change the whole logic behind TTLexternal-dns/endpoint/endpoint.go
Line 70 in 07ae419
external-dns/endpoint/endpoint.go
Line 239 in 07ae419
int64, but the change is quite complexSo I'm proposing to keep this edge case as is, and if we have any feature requests, to revisit this edge case in the future.
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.
Basically, at the moment, following two are equal in terms of TTL
One is without TTL annotation and the other one with will TTL annotation set to explicitly to
0. This case at the moment classed as TTL is not configured.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 decision was explicitly being made here #320 (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.
And if there is annotation TTL, and if it's set to 0, is currently overrided in providers, as well as there are explicit flags example
--ns1-min-ttlThere 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.
And here #320 (comment)
Basically, when annotation is set to 0, it means use defaults.