AKS icon indicating copy to clipboard operation
AKS copied to clipboard

DNS lookup timeouts

Open juan-lee opened this issue 8 years ago • 41 comments

Symptoms Outbound requests from pods can see a 5 second delay during DNS lookups. This is known to impact containers based off of the alpine image.

Root Cause https://www.weave.works/blog/racy-conntrack-and-dns-lookup-timeouts

Workaround Add the following to your impacted pod's manifest.

postStart:
  exec:
    command:
    - /bin/sh
    - -c
    - "/bin/echo 'options single-request-reopen' >> /etc/resolv.conf"

What is single-request-reopen?

single-request-reopen (since glibc 2.9)
  Sets RES_SNGLKUPREOP in _res.options.  The resolver
  uses the same socket for the A and AAAA requests.  Some
  hardware mistakenly sends back only one reply.  When
  that happens the client system will sit and wait for
  the second reply.  Turning this option on changes this
  behavior so that if two requests from the same port are
  not handled correctly it will close the socket and open
  a new one before sending the second request.

juan-lee avatar Sep 26 '18 21:09 juan-lee

FYI, I have not testing this personally -- this supposedly will not work for Alpine based containers since MUSL lib that Alpine uses does not support this option.

https://github.com/kubernetes/kubernetes/issues/62628#issuecomment-389341878

devteng avatar Sep 26 '18 21:09 devteng

We had the same issue using alpine image. It's not a AKS problem, but a general kubernetes issue: See https://github.com/kubernetes/kubernetes/issues/56903

I would recommend to read this: https://blog.quentin-machu.fr/2018/06/24/5-15s-dns-lookups-on-kubernetes/

We changed our base image to jessie-slim and added this to the pod manifest.

dnsConfig:  
  options:  
    - name: single-request-reopen

more details : https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

I think it is a cleaner solution than adding a postStart hook.

epoyraz avatar Oct 01 '18 08:10 epoyraz

I'm not sure what to think about this. Is the advice going to be: 'you can't run Alpine and need to customise DNS' if you expect proper DNS performance?

Could someone from Microsoft weigh in here?

timwebster9 avatar Oct 04 '18 16:10 timwebster9

This also works, and it works on alpine pods:

https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy service/networking/custom-dns.yaml apiVersion: v1 kind: Pod metadata: namespace: default name: dns-example spec: containers: - name: test image: nginx dnsPolicy: "None" dnsConfig: nameservers: - 1.2.3.4 searches: - ns1.svc.cluster.local - my.dns.search.suffix options: - name: ndots value: "2" - name: edns0

alistardust avatar Oct 05 '18 21:10 alistardust

We have the same problem, will AKS rollout a solution for us? I don't see an elegant workaround so far.

wutingbupt avatar Nov 14 '18 07:11 wutingbupt

@AXington Your solution reduces the delay from 5 seconds to 2.5 :), but still not fully work.

wutingbupt avatar Nov 15 '18 10:11 wutingbupt

@juan-lee your workaround didn't work perfectly for the alpine based images, any better idea?

wutingbupt avatar Nov 15 '18 10:11 wutingbupt

@juan-lee your workaround didn't work perfectly for the alpine based images, any better idea?

My understanding is that we've rolled the fix out during this week's release. You will have to upgrade your cluster to a newer version of k8s to get the changes.

juan-lee avatar Nov 15 '18 19:11 juan-lee

Thanks very much, @juan-lee, I will let you know how does it work. Br, Tim

wutingbupt avatar Nov 15 '18 20:11 wutingbupt

@juan-lee The 1.11.4 solves this problem, thanks for your help.

Br, Tim

wutingbupt avatar Nov 15 '18 21:11 wutingbupt

I checked official change log can't find specific change that addresses this bug in the change log, but amazingly the upgrade seems to fix this issue for our AKS cluster. I hope it will not come back on next version bump.

motarski avatar Nov 16 '18 08:11 motarski

I checked official change log can't find specific change that addresses this bug in the change log, but amazingly the upgrade seems to fix this issue for our AKS cluster. I hope it will not come back on next version bump.

The fix isn't in k8s, but rather a kernel patch that is now default for new agent nodes. The reason you're seeing the problem go away with an upgrade is because your old agent nodes are replaced with ones that have the new kernel.

juan-lee avatar Nov 19 '18 16:11 juan-lee

Ok I see, thanks for explanation@juan-lee

motarski avatar Nov 20 '18 10:11 motarski

@juan-lee is the fix only present in the new 'MobyImage' that you have to register for, or is it present in all 1.11.4 images?

timwebster9 avatar Nov 22 '18 13:11 timwebster9

Hi people! As it stands today, all new VMs (through new cluster, scale, or upgrade) have the kernel fix '"netfilter: nf_conntrack: resolve clash for matching conntracks" fixes the 1st race (accepted).` described in https://www.weave.works/blog/racy-conntrack-and-dns-lookup-timeouts

Thanks

weinong avatar Dec 04 '18 17:12 weinong

@weinong any info on when the second race will be addressed?

nodeselector avatar Feb 22 '19 00:02 nodeselector

I just hit this, and single-request-reopen does seem to make it go away! This is on a recent fresh 1.13.5 aks cluster. Not sure why the DNS server gives the wrong answer to begin with. Is this a coredns issue ? Thanks @juan-lee for the work-around 👍

kim0 avatar Jun 18 '19 22:06 kim0

Hi @weinong .. I deployed a cluster a few days back, and still hitting this. So I think it's still not fixed. Is there any update when a fix is expected to land. Also taking a chance and pinging @jnoller

kim0 avatar Jun 19 '19 11:06 kim0

Hi people. Is this issue fixed with kubernetes 1.13.5? I wanted to upgrade my AKS cluster to the said version, but I am using multiple deployments with alpine-based images.

tapanhalani avatar Jun 30 '19 13:06 tapanhalani

Still seeing the issue with kernel-version 4.15.0-1063-azure

jemag avatar Nov 20 '19 16:11 jemag