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

bug: discovery/dns cause panic #8554

Closed
caibirdme opened this issue Dec 22, 2022 · 6 comments
Closed

bug: discovery/dns cause panic #8554

caibirdme opened this issue Dec 22, 2022 · 6 comments

Comments

@caibirdme
Copy link

Current Behavior

  1. config dns dicovery in config.yaml:
discovery:
  dns:
    servers:
      - 9.166.239.254:53  # k8s coredns svc
  1. config tcp proxy:
    stream_routes:
      - server_port: 10000
        upstream:
          service_name: app-service.namespace:8081
          scheme: tcp
          discovery_type: dns
          type: roundrobin
  1. send request to xxx:10000
  2. apisix aborted with log:
2022-12-22T15:07:02.512209987Z 2022/12/22 23:07:02 [error] 56#56: *91098 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/discovery/dns/init.lua:32: attempt to index upvalue 'dns_client' (a nil value)
2022-12-22T15:07:02.512250920Z stack traceback:
2022-12-22T15:07:02.512256678Z coroutine 0:
2022-12-22T15:07:02.512259872Z 	/usr/local/apisix/apisix/discovery/dns/init.lua: in function 'nodes'
2022-12-22T15:07:02.512263539Z 	/usr/local/apisix/apisix/upstream.lua:259: in function 'set_upstream'
2022-12-22T15:07:02.512266986Z 	/usr/local/apisix/apisix/init.lua:959: in function 'stream_preread_phase'
2022-12-22T15:07:02.512270259Z 	preread_by_lua(nginx.conf:90):2: in main chunk while prereading client data, client: 9.166.233.109, server: 0.0.0.0:10000

Expected Behavior

proxy request to desired k8s service

Error Logs

2022-12-22T15:07:02.512209987Z 2022/12/22 23:07:02 [error] 56#56: *91098 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/discovery/dns/init.lua:32: attempt to index upvalue 'dns_client' (a nil value)
2022-12-22T15:07:02.512250920Z stack traceback:
2022-12-22T15:07:02.512256678Z coroutine 0:
2022-12-22T15:07:02.512259872Z /usr/local/apisix/apisix/discovery/dns/init.lua: in function 'nodes'
2022-12-22T15:07:02.512263539Z /usr/local/apisix/apisix/upstream.lua:259: in function 'set_upstream'
2022-12-22T15:07:02.512266986Z /usr/local/apisix/apisix/init.lua:959: in function 'stream_preread_phase'
2022-12-22T15:07:02.512270259Z preread_by_lua(nginx.conf:90):2: in main chunk while prereading client data, client: 9.166.233.109, server: 0.0.0.0:10000

Steps to Reproduce

as current behavior described

Environment

  • APISIX version (run apisix version): 2.15.1 (using helm chart v0.11.4)
  • Operating system (run uname -a): centos7
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): no etcd, yaml
  • APISIX Dashboard version, if relevant: no
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@caibirdme
Copy link
Author

When I use nodes directly rather than dns service_name, it works as expected. So I think this might be a bug of discovery/dns

    stream_routes:
      - server_port: 10000
        upstream:
          nodes:
            "1.2.3.4:8081": 1
          type: roundrobin

And the dns server is healthy, I can use nslookup to check:

nslookup qwe-trpc.test 9.166.239.254:53

Server:         9.166.239.254
Address:        9.166.239.254#53

Name:   qwe-trpc.test.svc.cluster.local
Address: 9.166.239.70

@ronething
Copy link
Contributor

because of dns service discovery didn't support in the stream subsystem yet, so it will cause error like below.

2022-12-22T15:07:02.512209987Z 2022/12/22 23:07:02 [error] 56#56: *91098 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/discovery/dns/init.lua:32: attempt to index upvalue 'dns_client' (a nil value)

@ronething
Copy link
Contributor

@caibirdme Hi, as PR #8593 is merged, you can pull master branch in your development environment and try dns service discovery in the stream subsystem.

@caibirdme
Copy link
Author

@ronething Thx, is this feature included in any releases?

@ronething
Copy link
Contributor

@ronething Thx, is this feature included in any releases?

maybe in version 3.2.0 #8988

@moonming
Copy link
Member

fixed by #8593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants