You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "saytesnake (via GitHub)" <gi...@apache.org> on 2023/02/02 18:43:04 UTC

[GitHub] [apisix-dashboard] saytesnake opened a new issue, #2728: What are the best practices for export/import in apisix-dashboard?

saytesnake opened a new issue, #2728:
URL: https://github.com/apache/apisix-dashboard/issues/2728

   ### Issue description
   
   We configure the routes in our development environment's apisix dashboard, just like a baseline, then export it, and import it on the client's server.
   
   ### Expected behavior
   
   1. Get the token
   `curl -s -XPOST "http://127.0.0.1:9000/apisix/admin/user/login" -d '{"username":"admin","password":"admin"}` 
   
   2. Export route
   Open [http://192.168.1.100:9000/routes/list](url) in browser, select all routes, and click "Export OpenAPI" to json file, name apisixTemp.json.
   
   3. Replace the host of upsteam nodes
   Using VS Code(Ctrl + H) or `sed` in Linux, replace the host field of all upstream nodes, that's only we need to do.
   
   4. Import the route via apisix dashboard.
   ```
   curl -XPOST "http://127.0.0.1:9000/apisix/admin/import/routes" \
       -H 'Authorization: abcdefg' \
       -F 'file=@./apisixTemp.json'
   ```
   
   All working fine in Apisix Dashboard 2.13.x.
   
   But not working in Apisix Dashboard 2.15.x, maybe caused by OpenAPI 3, or something field in Apisix Dashboard 2.15.x is changed, just like,
   2.13.x :
   `"value":{"upstream":{"scheme":"http","nodes":[{"host":"192.168.1.100","port":10221,"weight":1}]`
   2.15.x :
   `"value":{"priority":0,"upstream":{"scheme":"http","nodes":{"192.168.1.100:10221":1}`
   
   ---
   
   Well, let’s try `/apisix/admin/migrate/export` and `/apisix/admin/migrate/import`
   
   1. Get the baseline apisix dashboard token
   `curl -s -XPOST "http://192.168.1.100:9000/apisix/admin/user/login" -d '{"username":"admin","password":"admin"}` 
   
   2. Export route
   curl -o ./apisixTemp.json 'http://192.168.1.100:9000/apisix/admin/migrate/export' -H 'Authorization: abcdefg'
   
   3. Replace the host of upsteam nodes
   ```
   #!/bin/bash
   
   UPSTREAM_NODES="127.0.0.1"
   
   IP=$(grep -Eo '([^0-9]|\b)((1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9])\.){3}(1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9])([^0-9]|\b)' ./apisixTemp.json | sed -nr 's/([^0-9]|\b)(([0-9]{1,3}\.){3}[0-9]{1,3})([^0-9]|\b)/\2/p' | sort | uniq )
   
   for i in ${IP}; do
           sed -i s@"${i}"@"${UPSTREAM_NODES}"@g ./apisixTemp.json
   done
   ```
   
   4. Import the route via apisix dashboard.
   ```
   curl -XPOST "http://127.0.0.1:9000/apisix/admin/migrate/import" \
       -H 'Authorization: abcdefg'
       -F 'file=@./apisixTemp.json' -F 'mode=overwrite'
   ```
   
   Not good, report error `{"Code":20001,"Message":"Checksum check failure,maybe file broken","Data":null,"SourceSrv":""}`
   
   And check the code, I don't know go language, probably means, when exporting, it will add 4 byte(uint32) checksum at the end of file, when importing, will verify this checksum. 
   
   `sed`, `vim` in linux, or VSCode modification, can not save this checksum, verification failed, apisixTemp.json just feels like a binary file.
   
   ### How to Reproduce
   
   Actually, I don't know if that's a bug.
   
   A better way or idea?
   
   Thx.
   
   ### Screenshots
   
   _No response_
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.15.1
   - OS (cmd: `uname -a`): Anolis OS 7.9
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): openresty/1.21.4.1
   - etcd version, if have (cmd: run `etcd --version`): 3.4
   - apisix-dashboard version, if have: 2.15.0
   - Browser version, if have: Chrome 109.0.5414.120
   
   
   ### Additional context
   
   _No response_


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

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


Re: [I] What are the best practices for export/import in apisix-dashboard? [apisix-dashboard]

Posted by "juzhiyuan (via GitHub)" <gi...@apache.org>.
juzhiyuan closed issue #2728: What are the best practices for export/import in apisix-dashboard?
URL: https://github.com/apache/apisix-dashboard/issues/2728


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


Re: [I] What are the best practices for export/import in apisix-dashboard? [apisix-dashboard]

Posted by "NotFound403 (via GitHub)" <gi...@apache.org>.
NotFound403 commented on issue #2728:
URL: https://github.com/apache/apisix-dashboard/issues/2728#issuecomment-1833025355

   > > i have done it , the export json file is not a pure json, it contains a checksum (4 bit) at the end , if u modify the contents u need to update the checksum
   > > https://github.com/apache/apisix-dashboard/blob/master/api/internal/handler/migrate/migrate.go
   > 
   > How to update the checksum?
   
   It just only needs to be recalculated by the function  in  migrate.go


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


Re: [I] What are the best practices for export/import in apisix-dashboard? [apisix-dashboard]

Posted by "NotFound403 (via GitHub)" <gi...@apache.org>.
NotFound403 commented on issue #2728:
URL: https://github.com/apache/apisix-dashboard/issues/2728#issuecomment-1831168452

   i have done it , the export json file is not a pure json, it contains a checksum (4 bit) at the end , if u modify the contents u need to update the checksum 
   
   https://github.com/apache/apisix-dashboard/blob/master/api/internal/handler/migrate/migrate.go


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


Re: [I] What are the best practices for export/import in apisix-dashboard? [apisix-dashboard]

Posted by "saytesnake (via GitHub)" <gi...@apache.org>.
saytesnake commented on issue #2728:
URL: https://github.com/apache/apisix-dashboard/issues/2728#issuecomment-1832992423

   > i have done it , the export json file is not a pure json, it contains a checksum (4 bit) at the end , if u modify the contents u need to update the checksum
   > 
   > https://github.com/apache/apisix-dashboard/blob/master/api/internal/handler/migrate/migrate.go
   
   How to update the checksum?


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


Re: [I] What are the best practices for export/import in apisix-dashboard? [apisix-dashboard]

Posted by "juzhiyuan (via GitHub)" <gi...@apache.org>.
juzhiyuan commented on issue #2728:
URL: https://github.com/apache/apisix-dashboard/issues/2728#issuecomment-2814445428

   Hi, we will release a new dashboard to address legacy issues. Refer to https://github.com/apache/apisix-dashboard/issues/2981


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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