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: there is a bug in the schema check of nodes when admin-api saves the upstream configuration. #10455

Closed
yujiapingyu opened this issue Nov 6, 2023 · 7 comments

Comments

@yujiapingyu
Copy link

Current Behavior

image
nodes_schema中的port不是必须的呀,辛苦修复一下,会导致通过admin api put上游时,如果node是array形式,无法通过校验!

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

  1. 运行APISIX;
  2. 给admin api发送请求:
    image

Environment

  • APISIX version (run apisix version):3.4.1
  • Operating system (run uname -a):23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:43:05 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6020 arm64
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): 3.5.0
  • APISIX Dashboard version, if relevant:3.0.0
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@yujiapingyu yujiapingyu changed the title bug: admin-api在保存上游配置时对nodes的检查有bug bug: admin-api在保存上游配置时对nodes的schema检查有bug Nov 6, 2023
@shreemaan-abhishek shreemaan-abhishek changed the title bug: admin-api在保存上游配置时对nodes的schema检查有bug bug: there is a bug in the schema check of nodes when admin-api saves the upstream configuration. Nov 7, 2023
@shreemaan-abhishek
Copy link
Contributor

Could you please paste the configuration here?

@yujiapingyu
Copy link
Author

yujiapingyu commented Nov 7, 2023

{
  "nodes": [
    {
      "host": "ops-kuber.newlink.com",
      "weight": 1
    }
  ],
  "retries": 0,
  "timeout": {
    "connect": 6,
    "send": 6,
    "read": 6
  },
  "type": "roundrobin",
  "scheme": "https",
  "pass_host": "node",
  "name": "认证服务",
  "desc": "认证服务",
  "keepalive_pool": {
    "idle_timeout": 60,
    "requests": 1000,
    "size": 320
  }
}

This is a legitimate upstream,but it can not be saved both in apisix-dashboard or admin-api.

@shreemaan-abhishek
Copy link
Contributor

this isn't valid as port is required.

@yujiapingyu
Copy link
Author

yujiapingyu commented Nov 7, 2023

https://apisix.apache.org/zh/docs/apisix/admin-api/#upstream
image
Excerpted from official documentation,port is optional!

And when I set nodes as hashmap, like this:

{
  "nodes": {
     "ops-kuber.newlink.com": 1
   },
  "retries": 0,
  "timeout": {
    "connect": 6,
    "send": 6,
    "read": 6
  },
  "type": "roundrobin",
  "scheme": "https",
  "pass_host": "node",
  "name": "认证服务",
  "desc": "认证服务",
  "keepalive_pool": {
    "idle_timeout": 60,
    "requests": 1000,
    "size": 320
  }
}

It becomes valid.

@shreemaan-abhishek
Copy link
Contributor

even the code says port is required:

required = {"host", "port", "weight"},

Would you like to raise a PR to update the document?

@yujiapingyu
Copy link
Author

I think "port is optional" is reasonable. Because when my node is a domain name, I don’t need to provide a port.

@monkeyDluffy6017
Copy link
Contributor

considered resolved

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

No branches or pull requests

3 participants