apisix-ingress-controller icon indicating copy to clipboard operation
apisix-ingress-controller copied to clipboard

request help: upstreamNode json解析异常

Open marchlhw opened this issue 2 years ago • 7 comments

Issue description

问题1:

  1. admin api根据id获取upstream json数据如下: image

  2. apisix-ingress-controller定义的数据结构如下: image

  3. 注释红框中的判断,否则解析报错 image

3.1 不注释代码的情况下,报错:

2022-08-04 22:04:55.984	error	unexpected non-empty object

3.2 注释代码的情况下,upstreamNode解析为空:

&{Metadata:{ID:419230261889204925 Name:test Desc: Labels:map[]} Type:roundrobin HashOn: Key: Checks:<nil> Nodes:[] Scheme:http Retries:<nil> Timeout:0xc0000d80d8 TLS:<nil>}
  1. 下面的json数据结构不注释代码的情况下也可以正常解析 image

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long): 1.5.0
  • your Kubernetes cluster version (output of kubectl version): 1.18
  • if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a): centos7.4

marchlhw avatar Aug 04 '22 12:08 marchlhw

Thank you very much. I am trying to reproduce this problem. This problem does exist.

AlinsRan avatar Aug 04 '22 15:08 AlinsRan

Can you tell me the version of your apisix-dashboard?

AlinsRan avatar Aug 04 '22 15:08 AlinsRan

xref: #712

tao12345666333 avatar Aug 04 '22 17:08 tao12345666333

Can you tell me the version of your apisix-dashboard?

apisix-dashboard 我用的最新的master分支,我看manager-api的源码有做数据结构转换 https://github.com/apache/apisix-dashboard/blob/master/api/internal/core/entity/format.go

marchlhw avatar Aug 05 '22 01:08 marchlhw

@bzp2010 Could you help confirm this if you have time?

tao12345666333 avatar Aug 05 '22 01:08 tao12345666333

apisix-ingress-controller调用的是admin-api,会有上面提到的数据解析问题;manager-api虽然有对upstreamNodes做数据结构转换,响应的json数据controller可以正常的解析,但是controller只支持api-key的验证,而manager-api是jwt的验证

marchlhw avatar Aug 05 '22 01:08 marchlhw

I'll fix it #1222 .

AlinsRan avatar Aug 05 '22 03:08 AlinsRan