amphp / dns

Async DNS resolution for PHP based on Amp.
https://amphp.org/dns
MIT License
156 stars 32 forks source link

Ignore ServFail / NxDomain for search list, e.g. in Kubernetes cluster #99

Closed roquie closed 4 years ago

roquie commented 4 years ago

Any requests called with amphp/http-client will use these dns package. Where requests will sent inside kubernetes cluster it fails with following reason:

In Rfc1035StubResolver.php line 193:

  All query attempts failed for {{ADDRESS}}-prod.svc.cluster.l
  ocal: Server returned error code: 3, Server returned error code: 3

In functions.php line 534:

  Multiple errors encountered; use Amp\MultiReasonException::getReasons() to
  retrieve the array of exceptions thrown

Requests from pod to pod inside a same namespace in Kubernetes cluster by service name (kubectl get svc). If using local ip address instead of dns it works. But this workaround is not possible for all cases.

I think this is critical issue because a lot of many users use Kubernetes every day.

PHP: 7.4.5 amphp/amp: v2.4.4 amphp/dns: v1.2.1 amphp/http-client: v4.2.2 OS: Alpine

UV extension installed from pecl.

roquie commented 4 years ago

https://github.com/amphp/dns/issues/41

kelunik commented 4 years ago

I haven't used Kubernetes, yet. How does DNS resolution work there? What's different?

roquie commented 4 years ago

Sorry for long answer. On next week I will be again works with amphp/dns and try to run series of tests in cluster. Before this bug I should fix the issue with amphp/postgres because it blocks my work.

roquie commented 4 years ago

In all cases gethostbyname returns ip.

UPD: For 1.2.1 version this hack not help me. https://github.com/amphp/dns/issues/82

/etc/resolv.conf

cat /etc/resolv.conf
nameserver 172.17.0.10
search calcifer-dev.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

I'm trying to find some bugs in PR https://github.com/amphp/dns/pull/89 ...

kelunik commented 4 years ago

What's the error message you get for github.com?

roquie commented 4 years ago
Screenshot 2020-06-19 at 22 37 13
kelunik commented 4 years ago

Please retry with https://github.com/amphp/dns/commit/8cf2ccc4fa5a97f15b0b11087b22d2b544e45ab2 / latest dev-master.

roquie commented 4 years ago

Yes, that works in all cases. Thanks! :)

kelunik commented 4 years ago

Thanks for testing! Tagged as v1.2.2.