fix(source): skip pod DNS when PodIP is empty for IP-derived records#6376
fix(source): skip pod DNS when PodIP is empty for IP-derived records#6376isumitsolanki wants to merge 5 commits into
Conversation
Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
|
Welcome @isumitsolanki! |
|
Hi @isumitsolanki. 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. |
|
/ok-to-test |
Coverage Report for CI Build 25335662845Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.01%) to 80.5%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions64 previously-covered lines in 7 files lost coverage.
Coverage Stats
💛 - Coveralls |
…into issue_6375
ivankatliarchuk
left a comment
There was a problem hiding this comment.
The same pattern appears four times in pod.go — identical log message, identical condition
something like
// addInternalHostnameAnnotationEndpoints
if len(targets) == 0 && pod.Status.PodIP == "" {
log.Debugf("skipping pod %q. PodIP is empty with phase %q", pod.Name, pod.Status.Phase)
return
}
// addKopsDNSControllerEndpoints
if pod.Status.PodIP == "" {
log.Debugf("skipping pod %q. PodIP is empty with phase %q", pod.Name, pod.Status.Phase)
}
// addPodSourceDomainEndpoints
if pod.Status.PodIP == "" {
log.Debugf("skipping pod %q. PodIP is empty with phase %q", pod.Name, pod.Status.Phase)
}
// hostsFromTemplate (pre-existing)
if address.IP == "" {
log.Debugf("skipping pod %q. PodIP is empty with phase %q", pod.Name, pod.Status.Phase)
}
A small helper could eliminate the repetition and have a common method
// returns false and logs if PodIP is empty
func podIPReady(pod *v1.Pod) bool {
if pod.Status.PodIP == "" {
log.Debugf("skipping pod %q. PodIP is empty with phase %q", pod.Name, pod.Status.Phase)
return false
}
return true
}
Then the call sites become a single line each - e.g. if !podIPReady(pod) { return }
|
Actually after review, a more robust fix would be a single check at the top of addPodEndpointsToEndpointMap This would cover all paths — current and future - with one guard instead of per-function checks. The trade-off is that it also skips Succeeded/Failed pods with explicit targets annotations (which currently still produce records), but that's arguably correct behavior anyway — a terminated pod shouldn't own DNS records. |
…00 characters. Line 7 in docs/sources/pod.md was one long paragraph (340 characters). Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Have you tested it? Is the problem resolved? https://github.com/kubernetes-sigs/external-dns/blob/master/CONTRIBUTING.md#how-to-test-a-pr |
Hi @ivankatliarchuk , my cluster is on-prem what should i use for --provider ?? I can see any option is available for on-prem. |
|
Exactly as you running the service. Sorry i have no idea, this is your environment |
|
@isumitsolanki You can install build locally a docker image with this PR code, make this image accessible to your k8s cluster and test with it. |
|
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 ?
Skips pod-source endpoint generation whenever the record would be built from
pod.Status.PodIPbut that value is still empty (e.g. pod isPending). This applies to internal hostname annotation,--pod-source-domainwithout explicit targets, and kops-dns-controller internal hostname. It avoidsSuitableType("")producing a CNAME with an empty target; skips are logged at debug, consistent withhostsFromTemplate. Adds threeTestPodSourcetable cases for pending pods with emptyPodIP.Motivation
Fixes #6375 — empty-target CNAMEs could block later A records at the same name (e.g. Azure Private DNS CNAME naming restriction).
More