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 3 commits intokubernetes-sigs:masterfrom
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 25158358874Coverage increased (+0.005%) to 80.491%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions3 previously-covered lines in 2 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. |
|
[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 |
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