Skip to content
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

Add support for IPV6 resolvers #3882

Merged
merged 1 commit into from
Mar 21, 2019
Merged

Conversation

aledbf
Copy link
Member

@aledbf aledbf commented Mar 10, 2019

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged):

fixes #3881

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 10, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 10, 2019
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 10, 2019
@aledbf aledbf force-pushed the ipv6-resolver branch 2 times, most recently from 101fdc9 to e0c9774 Compare March 10, 2019 00:36
@jacksontj
Copy link
Contributor

Do we need this format in the config file? If not then a cleaner solution might be https://github.com/kubernetes/ingress-nginx/compare/master...jacksontj:issue_3881?expand=1 ? (I'm not familiar enough with this codebase to know if others require it in the non-bracket form).

@jacksontj
Copy link
Contributor

jacksontj commented Mar 10, 2019

I applied this patch (through a configmap) on my cluster, but it seems that there are more ipv6 compatibility issues with this lua script:

2019/03/10 00:45:09 [error] 41#41: *235 [lua] dns.lua:78: resolve(): no A record resolved, context: ngx.timer

@jacksontj
Copy link
Contributor

jacksontj commented Mar 10, 2019

the problem line now is that its doing an A query only -- https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/lua/util/dns.lua#L54

so here the descision needs to be made if we do A, AAAA, or fail between them. For my use-case (as a workaround) I'm using this script and I've just changed the type to AAAA all the time -- not ideal, but unblocks me :) )

@aledbf
Copy link
Member Author

aledbf commented Mar 10, 2019

@ElvinEfendi I think this is the opportunity to migrate to http://kong.github.io/lua-resty-dns-client/modules/resty.dns.client.html#resolve

@ElvinEfendi
Copy link
Member

As @jacksontj suggested above I think this should be done in the controller (I had an impression we already do it in template.go).

As to no A record resolved error, it should be easy to add support for it.

@ElvinEfendi I think this is the opportunity to migrate to http://kong.github.io/lua-resty-dns-client/modules/resty.dns.client.html#resolve

I looked at the implementation of that library again, and it's really unnecessarily (for this project) complicated.

@aledbf
Copy link
Member Author

aledbf commented Mar 14, 2019

I looked at the implementation of that library again, and it's really unnecessarily (for this project) complicated.

Ok, any suggestion how to fix this issue?

As to no A record resolved error, it should be easy to add support for it.

How? (attempting to resolve AAAA after failing A if the dns is ipv6)

@ElvinEfendi
Copy link
Member

How? (attempting to resolve AAAA after failing A if the dns is ipv6)

Yes. Basically extract that logic out into separate function i.e query(host, qtype) and call it first with r.TYPE_A and if unsuccessful then call it again with r.TYPE_AAAA.

And even better we can probably deduce which one of r.TYPE_A or r.TYPE_AAAA to try first by looking at nameservers (i.e when all entries in the nameservers list is IPv6 then try r.TYPE_AAAA first).

@jacksontj
Copy link
Contributor

jacksontj commented Mar 14, 2019 via email

@jacksontj
Copy link
Contributor

Created #3895 for the resolver config fix.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 19, 2019
local addresses, ttl
addresses, ttl, err = resolve_host(host, resolver.TYPE_A)
if not addresses then
ngx.log(ngx.ERR, "failed to query the DNS server: " .. tostring(err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not log an error here, because it might be expected that there's no TYPE_A record, so we will keep logging error.

Instead I suggest you collect this and the error below and log them in the end only if both TYPE_A and TYPE_AAAA queries fail

@ElvinEfendi
Copy link
Member

@aledbf implementation looks good (just few comments), you will need to edit the unit test file to adjust the expected error messages.

@aledbf aledbf force-pushed the ipv6-resolver branch 2 times, most recently from b35b4c4 to 9bb1b3b Compare March 21, 2019 00:26
@ElvinEfendi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 6db61fa into kubernetes:master Mar 21, 2019
@ElvinEfendi
Copy link
Member

Right now we short circuit and does not check for IPv6 address when IPv4 exists. I wonder if it would be better to always check for both and combine the result before returning.

@aledbf @jacksontj thoughts?

@aledbf aledbf deleted the ipv6-resolver branch March 21, 2019 17:39
@jacksontj
Copy link
Contributor

I believe I covered this in #3882 (comment)

TLDR; should be ipv6 with fallback to ipv4; optionally have config to control that lookup priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dns.lua unable to instantiate ipv6 resolver
4 participants