resty-cli icon indicating copy to clipboard operation
resty-cli copied to clipboard

Cant Resolve host name. Tried adding with CLI parameters. Should this work?

Open jb6925 opened this issue 4 years ago • 6 comments

I'm running a unit test with resty in a kubernetes cluster.

resty /kong/spec/jwtcache_test.lua --http-conf 'resolver 172.31.0.10' --main-conf 'resolver 172.31.0.10'

This test uses "resty.redis" to try to connect to a redis instance that is deployed as a service.

Error: redis could not be resolved (3: Host not found)

Should this work? I'm not really looking up a proxy address in nginx.

Thanks for your time in looking at this issue.

jb6925 avatar Oct 14 '21 18:10 jb6925

@jb6925 This should works:

resty --http-conf 'resolver 172.31.0.10' /kong/spec/jwtcache_test.lua

doujiang24 avatar Oct 15 '21 02:10 doujiang24

Thanks @doujiang24. The resolver was added to the configuration but now I'm unable to override the default . ie nginx: [emerg] "resolver" directive is duplicate in /tmp/resty_rCLHKZYDlc/conf/nginx.conf:172

Is it possible to override the resolver? Or is there a way to set the resolver local=on;?

jb6925 avatar Oct 15 '21 20:10 jb6925

Okay, after checking the source code:

  1. --ns IP, specify a custom name server (multiple instances are supported)
  2. read nameserver from /etc/resolv.conf if no ns specified.

So, I think 1 should work then.

doujiang24 avatar Oct 15 '21 23:10 doujiang24

Also, I'm a bit confused, does nameserver 172.31.0.10 already exists in the /etc/resolv.conf file?

doujiang24 avatar Oct 16 '21 00:10 doujiang24

@doujiang24 yes it does.

my /etc/resolv.conf

nameserver 172.31.0.10
search gitlab-runners.svc.cluster.local svc.cluster.local cluster.local xxxx.yy.zzzz.internal bb.aaaa.internal google.internal
options ndots:5

using the --ns parameter i'm back to my original error. redis could not be resolved (3: Host not found)

is it possible that the search isn't be used?

jb6925 avatar Oct 18 '21 14:10 jb6925

is it possible that the search isn't be used?

Hi @jb6925, currentlly resolver local=on; does not use the search field in /etc/resolv.conf.

xiaocang avatar Oct 18 '21 15:10 xiaocang