apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.35k stars 2.49k forks source link

help request: failed to query the DNS server #11311

Open ilya-tishonok opened 4 months ago

ilya-tishonok commented 4 months ago

Current Behavior

"DNS resolver domain: ${{LOS_SERVICE_UPSTREAM_ADDRESS}} error: failed to query the DNS server: DNS server error: 3 name error" appears when sending a request to the target service (LOS), but the request is hitting the target service. (No configuration was changed after the APISIX server startup). Apisix is started in standalone mode and docker enviroment.

It looks like everything in the request flow is working as expected, but it constantly produces such errors in the logs even if the request was upstreamed to the correct target service (which means that the ENV variable was found).

Expected Behavior

No errors should be produced in the logs

Error Logs

image

Steps to Reproduce

  1. Configure apisix.yaml to retrieve node for upstream from envs variables:
    upstreams:
    -
    id: los_service_upstream
    nodes:
      "${{LOS_SERVICE_UPSTREAM_ADDRESS}}": 1
    type: roundrobin
  2. Run apisix in docker environment (standalone mode).

Environment

Docker image: apache/apisix:3.9.0-debian

juzhiyuan commented 4 months ago

Hello @ilya-tishonok, kindly check https://docs.api7.ai/apisix/reference/environment-variables. This page includes all environments APISIX support.

I don't think APISIX now supports injecting an environment variable into the apisix.yaml configuration.

kayx23 commented 4 months ago

APISIX supports ENV injections in apisix.yaml. Test case can be found in t/cli/test_standalone.sh:

image

The fact that your request hits the LOS service also confirms it.

As it's not relevant to the variable injection, I'm updating the title to the DNS resolution error.

ilya-tishonok commented 4 months ago

Hello, @juzhiyuan, according to https://apisix.apache.org/docs/apisix/profile/, it's possible to use envs in apisix.yaml file: image

kayx23 commented 3 months ago

Just realized {{LOS_SERVICE_UPSTREAM_ADDRESS}} was showed up as the string literal in the log so it's still a variable resolution issue.

Did you by chance set the variable with LOS_SERVICE_UPSTREAM_ADDRESS=xxxxx instead of export LOS_SERVICE_UPSTREAM_ADDRESS=xxxxx?