-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(source/pod): add support for fqdn templating #5512
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(source/pod): add support for fqdn templating #5512
Conversation
Signed-off-by: ivan katliarchuk <[email protected]>
Hi @vflaux wdyt to review this feature? Probably worth to have a look, there is one test, and it seems bit flakey #5470 (comment) Never seen it before the refactoring. |
possibly flaky test is fixed #5514, we will see it |
source/pod_test.go
Outdated
// if tc.expectedDebugMsgs != nil { | ||
// for _, expectedMsg := range tc.expectedDebugMsgs { | ||
// testutils.TestHelperLogContains(expectedMsg, hook, t) | ||
// } | ||
// } else { | ||
// require.Empty(t, hook.AllEntries(), "Expected no debug messages") | ||
// } |
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.
Should this still be commented?
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.
Nice one. Need to uncomment this
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.
Yeah. There were a bug, fixed in this pr #5514. Merged with master
source/pod_test.go
Outdated
|
||
// for _, ep := range endpoints { | ||
// // TODO: source should always set the resource label key. currently not supported by the pod source. | ||
// assert.Empty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName) | ||
// assert.NotContains(t, ep.Labels, endpoint.ResourceLabelKey) | ||
// } |
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.
Should this still be commented?
Maybe use require
instead of assert
?
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.
changed to require
} | ||
|
||
func (*podSource) AddEventHandler(ctx context.Context, handler func()) { | ||
func (*podSource) AddEventHandler(_ context.Context, _ func()) { |
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.
Out of curiosity, do you know why this function does nothing? (Other sources often add the handler to informers)
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.
Yeah. We need to fix that as well. Related PR #5274
We need to review and fix all the handlers. It's a useful feature. I'm not too sure how it differ from adding handlers in constructur, that the only gotcha
source/pod.go
Outdated
} | ||
|
||
endpointMap := make(map[endpoint.EndpointKey][]string) | ||
fqdnEndpointMap := make(map[endpoint.EndpointKey][]string) |
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 map there to ensure the fqdn endpoints get priority over pod endpoints by adding them to endpointMap
at the end? Or we could copy directly into endpointMap
without 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 can try to copy. The code could be slightly more complex. As currently we could merge them at the end. Do you want me try to re-use single map?
The main challange I experience, is that ps.addPodEndpointsToEndpointMap(endpointMap, pod)
actually modify same map. But still possible
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.
done. removed fqdn map, and we are using single map
source/pod.go
Outdated
if ps.fqdnTemplate != nil { | ||
fqdnHosts, err := ps.hostsFromTemplate(pod) | ||
if err != nil { | ||
log.Debug(err) |
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.
Shouldn't this be a warning at least? Or this is expected to "silently" ignore errors?
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.
Someone may decide to use FQDN with {{ .PodSpec.PodDNSConfig }}
, one pod could have it, the other pod not necessary. We may have too many warnings. No prference, shell I change it to warn?
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've looked at other Sources and they return the error directly.
I'm not sure what is the best thing to do here.
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.
Make sense. I'll do the same then
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.
Changed to return error directly as in others.
@vflaux: changing LGTM is restricted to collaborators In response to this: 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. |
* master: test(source): fix flaky test (kubernetes-sigs#5514) chore(source/node): added resouce labels for nodes (kubernetes-sigs#5509) chore(deps): bump the dev-dependencies group across 1 directory with 14 updates (kubernetes-sigs#5511) fix(ovh): correct handling of records deletion (kubernetes-sigs#5450)
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Co-authored-by: vflaux <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
Signed-off-by: ivan katliarchuk <[email protected]>
@vflaux: changing LGTM is restricted to collaborators In response to this: 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. |
/assign @mloiseleur |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mloiseleur, vflaux The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Co-authored-by: Michel Loiseleur <[email protected]>
/lgtm |
@ivankatliarchuk: you cannot LGTM your own PR. In response to this:
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. |
Signed-off-by: ivan katliarchuk <[email protected]>
…t-for-fqdn' into feat-pod-add-support-for-fqdn * refs/remotes/origin/feat-pod-add-support-for-fqdn: feat(source/pod): add support for fqdn templating
/lgtm |
What does it do ?
Motivation
Worth to add support for FQDN templating for pods. Similar to nodes
Quite useful for debugging and create on the fly DNS records based on different pod spec or annotations without the need to restart/reboot them or apply any other sources.
What else I found, pod source does not support
external-dns/source/pod.go
Line 167 in 3e0c509
More