openresty / resty-cli

Fancy command-line utilities for OpenResty
http://openresty.org
263 stars 64 forks source link

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

Open jb6925 opened 3 years ago

jb6925 commented 3 years ago

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.

doujiang24 commented 3 years ago

@jb6925 This should works:

resty --http-conf 'resolver 172.31.0.10' /kong/spec/jwtcache_test.lua
jb6925 commented 3 years ago

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;?

doujiang24 commented 3 years ago

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 commented 3 years ago

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

jb6925 commented 3 years ago

@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?

xiaocang commented 3 years ago

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.