apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

when upstream pass_host="node" only support one node

Open liangliang4ward opened this issue 3 years ago • 13 comments

Issue description

image

but use apisix admin api is ok

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
  "uris": [
    "/blog/*"
  ],
  "name": "11",
  "plugins": {
    "proxy-rewrite": {
      "regex_uri": [
        "/blog/(.*)",
        "/$1"
      ],
      "scheme": "http"
    }
  },
  "upstream": {
    "nodes": [
      {
        "host": "192.168.0.1",
        "port": 80,
        "weight": 1
      },
      {
        "host": "192.168.0.2",
        "port": 80,
        "weight": 1
      }
    ],
    "type": "roundrobin",
    "hash_on": "vars",
    "scheme": "http",
    "pass_host": "node"
  },
  "status": 1
}'

Expected behavior

through dashboard can add upstream multi node when pass_host=node

How to Reproduce

...

Screenshots

No response

Environment

  • apisix version (cmd: apisix version): 2.12.1
  • OS (cmd: uname -a):
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run etcd --version):
  • apisix-dashboard version, if have:
  • Browser version, if have:

Additional context

No response

liangliang4ward avatar Feb 24 '22 02:02 liangliang4ward

Hi, @liangliang4ward. Please ref here https://github.com/apache/apisix/blob/abc20bb38ec663186ef225dc1b50f9cfaf15c21c/apisix/upstream.lua#L424 , dashboard just follow APISIX rules.

zaunist avatar Feb 24 '22 03:02 zaunist

Hi, @liangliang4ward. Please ref here https://github.com/apache/apisix/blob/abc20bb38ec663186ef225dc1b50f9cfaf15c21c/apisix/upstream.lua#L424 , dashboard just follow APISIX rules.

yes,but apisix not only check nodes!=1,also has other conditions

not balancer.recreate_request

liangliang4ward avatar Feb 24 '22 05:02 liangliang4ward

Hi, @liangliang4ward. Please ref here https://github.com/apache/apisix/blob/abc20bb38ec663186ef225dc1b50f9cfaf15c21c/apisix/upstream.lua#L424 , dashboard just follow APISIX rules.

when balancer.recreate_request ==true , Multiple nodes can be supported

liangliang4ward avatar Feb 24 '22 05:02 liangliang4ward

Sorry, I'm not familiar with ngx.balancer, but it does seem to be a bug here. @starsz Please take a look, thanks.

zaunist avatar Feb 24 '22 06:02 zaunist

Hi, please provide the apisix-dashboard version.

Baoyuantop avatar Feb 24 '22 07:02 Baoyuantop

Hi, please provide the apisix-dashboard version.

2.10.1

liangliang4ward avatar Feb 24 '22 07:02 liangliang4ward

Hi, please provide the apisix-dashboard version.

The master branch has the same problem, so we need to discuss how to solve it.

zaunist avatar Feb 24 '22 08:02 zaunist

Hi @zaunist. The error is returned here:

https://github.com/apache/apisix-dashboard/blob/88f323285f2bdbafca027da9aef357b2e3eb4008/api/internal/core/store/validate.go#L168-L170

The master branch has the same problem, so we need to discuss how to solve it.

I think we should keep the same as APISIX, APISIX can, APISIX-Dashboard should also can.

starsz avatar Feb 24 '22 10:02 starsz

Hi @zaunist. The error is returned here:

https://github.com/apache/apisix-dashboard/blob/88f323285f2bdbafca027da9aef357b2e3eb4008/api/internal/core/store/validate.go#L168-L170

The master branch has the same problem, so we need to discuss how to solve it.

I think we should keep the same as APISIX, APISIX can, APISIX-Dashboard should also can.

😂,I want to know what is the balancer.recreate_request ==true, I just read openresty docs, but I still don't understand the operation of this judgment in the manager-api.

zaunist avatar Feb 24 '22 15:02 zaunist

apisix-dashboard/api/internal/core/store/validate.go

So do I. @nic-chen Can you give the answer? I see it's written by you.

starsz avatar Feb 28 '22 01:02 starsz

😂,I want to know what is the balancer.recreate_request ==true, I just read openresty docs, but I still don't understand the operation of this judgment in the manager-api.

see https://github.com/apache/apisix/blob/master/apisix/balancer.lua#L331-L347 would help you understand. but we cannot do this in Manager API.

nic-chen avatar Feb 28 '22 04:02 nic-chen

😂,I want to know what is the balancer.recreate_request ==true, I just read openresty docs, but I still don't understand the operation of this judgment in the manager-api.

see https://github.com/apache/apisix/blob/master/apisix/balancer.lua#L331-L347 would help you understand. but we cannot do this in Manager API.

So do we have another way to solve this problem, this bug needs to be solved.

zaunist avatar Mar 03 '22 13:03 zaunist

Manager API cannot interact directly with APISIX. Maybe we could add configuration to let users decide for themselves.

nic-chen avatar Mar 04 '22 13:03 nic-chen