You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/04/22 16:34:59 UTC

[GitHub] [apisix-dashboard] liuxiran commented on pull request #1812: fix: can not configure upstream with no nodes

liuxiran commented on pull request #1812:
URL: https://github.com/apache/apisix-dashboard/pull/1812#issuecomment-824998296


   > @liuxiran
   > 
   > How about we make it in the backend? Please see https://github.com/apache/apisix-dashboard/blob/master/api/internal/core/entity/format.go#L49, we can initialize the `nodes` as an empty slice instead of a nil one. Just change `var nodes []*Node` to `nodes := make([]*Node, 0)` .
   > 
   > Looking forward to your insights.
   
   @imjoey Thanks for your advice, and it really make sense for me.
   
   before this change, when get info about an upstream with no nodes
   fe will get
   <img width="834" alt="WechatIMG5" src="https://user-images.githubusercontent.com/2561857/115748640-ee326980-a3c8-11eb-809a-e09e63cd6955.png">
   
   
   actually `nodes:null` causes the problem
   
   after this change, fe will get
   <img width="969" alt="WechatIMG4" src="https://user-images.githubusercontent.com/2561857/115748817-1ae68100-a3c9-11eb-87c6-89c5c9dcd18f.png">
   
   which is matches expectation.
   
   BTW, I have a question in the process of debugging:
   there are some logs I added to watch the changes of `upstream.Nodes` before the advice
   <img width="740" alt="WechatIMG7" src="https://user-images.githubusercontent.com/2561857/115749803-11a9e400-a3ca-11eb-96cc-a6621465ab08.png">
   I found even if I did not do this change, the `upstram.Nodes` will always be `[]`, but what Fe got is different, I haven't thought about it for a long time. 
   
   Also @nic-chen @Jaycean @starsz to take a look, thanks a lot


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org