@Ming

This logic is quite simple, so I think it is ok to control the risk.
And if it is in the production system, it will not be able to test on the
true product env.


On Sun, Sep 27, 2020 at 11:02 AM JunXu Chen <[email protected]> wrote:

> @Zhiyuan
> 1. disabled could be used as an option
> 2. I originally used two fields `status` and `enable` for choosing, but to
> avoid confusion, I deleted `status`, but I forgot to change it in the
> example
>
> Thanks!
>
> On Sun, Sep 27, 2020 at 9:31 AM Ming Wen <[email protected]> wrote:
>
>> I have a concern. The debug/disabled state routera are also in the
>> production system. If there is a bug, it will be very serious.
>>
>> Thanks,
>> Ming Wen, Apache APISIX & Apache SkyWalking
>> Twitter: _WenMing
>>
>>
>> JunXu Chen <[email protected]> 于2020年9月26日周六 下午11:50写道:
>>
>> > Hi, community,
>> >
>> > @liuxiran previously submitted a nice PR that implements route publish
>> and
>> > offline feature [1].
>> >
>> > We hope that instead of releasing a route immediately, we can test it
>> > first, and release it after the test result is OK.
>> >
>> > So we think it is more suitable to implement this feature directly in
>> > `Apache APISIX` instead of dashboard.
>> >
>> > Here is the implementation steps in my mind:
>> >
>> > 1. Add an `enable` field, or another more suitable field to the route
>> > configuration, and the default value of the field is false when adding a
>> > route. Which means the route is not released.
>> >
>> > 2. Add a matching item `enable` similar to `host` or `method` in the
>> > `lua-resty-radixtree` library.
>> > When matching a route for client request, If the value of `enable` is
>> > false, skip the route directly.
>> > But when there is `X-APISIX-ROUTE-DEBUG` in the http header and the
>> value
>> > is true, routes which `enable` are false can be matched according to
>> other
>> > conditions.
>> >
>> > 3. Now, normal client requests will skip routes not released, and
>> requests
>> > for testing by specifying the http header `X-APISIX-ROUTE-DEBUG` can
>> match
>> > routes not released, thus realizing our needs.
>> >
>> > Example:
>> >
>> > 1. Create a route (it's not released by default)
>> >
>> > ```shell
>> > $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY:
>> > edd1c9f034335f136f87ad84b625c8f1'-X PUT -i -d'
>> > {
>> >     "Uri": "/route-debug-test",
>> >     "Upstream": {
>> >         "Type": "roundrobin",
>> >         "node":{
>> >             "127.0.0.1:80": 1
>> >         }
>> >     }
>> > }'
>> > ```
>> > 2. Normal request (404 not found)
>> > ```
>> > curl 127.0.0.1:9080/route-debug-test
>> > ```
>> >
>> > 3. Debugging (200)
>> > ```
>> > curl 127.0.0.1:9080/route-debug-test -H "X-APISIX-ROUTE-DEBUG: true"
>> > ```
>> >
>> > 4. Release the route
>> > ```
>> > $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY:
>> > edd1c9f034335f136f87ad84b625c8f1'-X PATCH -i -d'
>> > {
>> >     "Status": 0
>> > }'
>> > ```
>> >
>> > 5. Normal access (200)
>> > ```
>> > curl 127.0.0.1:9080/route-debug-test
>> > ```
>> >
>> >
>> > [1] https://github.com/apache/apisix-dashboard/pull/451
>> >
>>
>

Reply via email to