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 2022/02/21 08:45:40 UTC

[GitHub] [apisix] zhukexingkong opened a new issue #6397: request help: How can I get the "modifiedIndex" of a route?

zhukexingkong opened a new issue #6397:
URL: https://github.com/apache/apisix/issues/6397


   ### Issue description
   
   My API bindings limit-count, I want get the count of redis key, the redis key  consists of "plugin-limit-countroute" and "modifiedIndex" and $server_addr.
   
   if I use "curl http://127.0.0.1:9080/apisix/admin/routes/10338 -H 'X-API-KEY: admin' -i", can't get "modifiedIndex":
   {
   	"count": 1,
   	"node": {
   		"value": {
   			"create_time": 1645082682,
   			"status": 1,
   			"name": "10338",
   			"uri": "\/resource\/mng\/group",
   			"id": "10338",
   			"plugins": {
   				"limit-count": {
   					"rejected_code": 503,
   					"redis_database": 0,
   					"key_type": "var",
   					"policy": "redis",
   					"time_window": 86400,
   					"redis_host": "175.27.157.12",
   					"count": 2,
   					"key": "$server_addr",
   					"redis_password": "Cv!#cloud2021",
   					"redis_port": 36379,
   					"disable": false,
   					"redis_timeout": 1000
   				},
   				"limit-req": {
   					"rejected_code": 503,
   					"burst": 0,
   					"key": "$server_addr",
   					"rate": 1,
   					"allow_degradation": false,
   					"key_type": "var",
   					"nodelay": false
   				}
   			},
   			"upstream": {
   				"scheme": "http",
   				"pass_host": "pass",
   				"discovery_args": {
   					"namespace_id": "test",
   					"group_name": "test_group"
   				},
   				"timeout": {
   					"connect": 6,
   					"send": 6,
   					"read": 6
   				},
   				"service_name": "resource-service",
   				"type": "roundrobin",
   				"keepalive_pool": {
   					"idle_timeout": 60,
   					"requests": 1000,
   					"size": 320
   				},
   				"discovery_type": "nacos"
   			},
   			"update_time": 1645430458
   		},
   		"key": "\/apisix\/routes\/10338"
   	},
   	"action": "get"
   }
   
   if I use "curl http://localhost:9080/apisix/admin/routes?api_key=admin -i", infomation is too much:
   {
   	"count": 3,
   	"node": {
   		"dir": true,
   		"nodes": [{
   			"value": {
   				"create_time": 1644949847,
   				"name": "10327",
   				"id": "10327",
   				"plugins": {
   					"limit-req": {
   						"key": "server_addr",
   						"burst": 0,
   						"nodelay": false,
   						"rate": 1,
   						"allow_degradation": false,
   						"key_type": "var",
   						"rejected_code": 503
   					},
   					"limit-count": {
   						"rejected_code": 503,
   						"show_limit_quota_header": true,
   						"redis_database": 0,
   						"allow_degradation": false,
   						"key_type": "var",
   						"policy": "redis",
   						"redis_host": "175.27.157.12",
   						"count": 2,
   						"time_window": 86400,
   						"redis_password": "Cv!#cloud2021",
   						"key": "server_addr",
   						"redis_port": 36379,
   						"redis_timeout": 1000
   					},
   					"ext-plugin-pre-req": {
   						"conf": [{
   							"name": "BlackWhiteCheckPlugin",
   							"value": "{\"rejected_code\":\"401\"}"
   						}]
   					}
   				},
   				"update_time": 1645410962,
   				"status": 0,
   				"uri": "\/1\/1\/1",
   				"upstream": {
   					"scheme": "http",
   					"pass_host": "pass",
   					"service_name": "ww",
   					"timeout": {
   						"read": 6,
   						"send": 6,
   						"connect": 6
   					},
   					"discovery_type": "nacos",
   					"type": "roundrobin",
   					"discovery_args": {
   						"group_name": "xuwen",
   						"namespace_id": "ww"
   					},
   					"hash_on": "vars"
   				},
   				"priority": 0
   			},
   			"modifiedIndex": 11481,
   			"createdIndex": 3612,
   			"key": "\/apisix\/routes\/10327"
   		}, {
   			"value": {
   				"create_time": 1645082682,
   				"name": "10338",
   				"id": "10338",
   				"plugins": {
   					"limit-count": {
   						"rejected_code": 503,
   						"show_limit_quota_header": true,
   						"count": 2,
   						"allow_degradation": false,
   						"key_type": "var",
   						"policy": "redis",
   						"redis_host": "175.27.157.12",
   						"key": "server_addr",
   						"time_window": 86400,
   						"redis_password": "Cv!#cloud2021",
   						"redis_database": 0,
   						"redis_port": 36379,
   						"redis_timeout": 1000
   					},
   					"limit-req": {
   						"burst": 0,
   						"rejected_code": 503,
   						"key": "server_addr",
   						"rate": 1,
   						"allow_degradation": false,
   						"key_type": "var",
   						"nodelay": false
   					}
   				},
   				"update_time": 1645428888,
   				"status": 1,
   				"uri": "\/resource\/mng\/group",
   				"priority": 0,
   				"upstream": {
   					"discovery_type": "nacos",
   					"discovery_args": {
   						"namespace_id": "test",
   						"group_name": "test_group"
   					},
   					"service_name": "resource-service",
   					"timeout": {
   						"read": 6,
   						"send": 6,
   						"connect": 6
   					},
   					"scheme": "http",
   					"pass_host": "pass",
   					"type": "roundrobin",
   					"hash_on": "vars"
   				}
   			},
   			"modifiedIndex": 11702,
   			"createdIndex": 5868,
   			"key": "\/apisix\/routes\/10338"
   		}, 
           ...
           ],
   		"key": "\/apisix\/routes"
   	},
   	"action": "get"
   }
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.12.1
   - OS (cmd: `uname -a`): Centos7
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks --version`):
   


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



[GitHub] [apisix] shuaijinchao edited a comment on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
shuaijinchao edited a comment on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058867143


   @zhukexingkong  If you really need it in actual work, you can remove https://github.com/apache/apisix/blob/master/apisix/admin/init.lua#L108-L111 code to get this information, but APISIX does not guarantee the field compatibility.


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



[GitHub] [apisix] zhukexingkong commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1053805995


   Hope to improve /apisix/admin/route/{id} to get modifiedIndex and createdIndex


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



[GitHub] [apisix] zhukexingkong commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1054968571


   I think "Add a configuration to config-default.yaml to indicate whether to expose modifiedIndex and createdIndex" is good.


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



[GitHub] [apisix] spacewander commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1057728827


   Maybe we can have a discussion in the maillist? Those two fields are removed before because there is an idea that we needed to make the response from Admin API less like etcd, see https://github.com/apache/apisix/issues/2759.
   
   Not sure people's opinion has been changed.


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



[GitHub] [apisix] tzssangglass commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1050444572


   > still hope to improve /apisix/admin/route/{id}
   
   In fact, all routes configurations exist as a whole. Any modification to a route will cause the entire radixtree to be rebuilt.


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



[GitHub] [apisix] zhukexingkong commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1049449044


   Yes, I later used /apisix/admin/routes to fix the problem, but this will get the full routes each time, still hope to improve /apisix/admin/route/{id} to get modifiedIndex and createdIndex


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



[GitHub] [apisix] tokers commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1057568604


   > I think "Add a configuration to config-default.yaml to indicate whether to expose modifiedIndex and createdIndex" is good.
   
   I'm afraid that it's not a common question, I prefer to add more descriptions for the Admin API response, and of course, we'll expose this field first.


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



[GitHub] [apisix] zhukexingkong commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058756430


   > An alternative solution is to fetch the route via control API, which is expected to expose the raw data. Or even communicate with the etcd directly.
   > 
   > Not sure about exposing the created/modification version of the configuration is a leaky abstraction or necessary.
   
   I think created/modification version is neccessry.


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



[GitHub] [apisix] shuaijinchao commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
shuaijinchao commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1056907407


   It might be better if it could be added directly to the data of a single route response, which is already exposed when fetching the full data. the switch if has lost its meaning?


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



[GitHub] [apisix] jwrookie commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
jwrookie commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1047401475


   Currently it's only via `/apisix/admin/routes`, but I think we can add `modifiedIndex createdIndex` to the response of `/apisix/admin/route/{id}`


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



[GitHub] [apisix] shuaijinchao commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
shuaijinchao commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058867143


   If you really need it in actual work, you can remove https://github.com/apache/apisix/blob/master/apisix/admin/init.lua#L108-L111 code to get this information, but APISIX does not guarantee the field compatibility.


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



[GitHub] [apisix] tokers commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1057568308


   > It might be better if it could be added directly to the data of a single route response, which is already exposed when fetching the full data. the switch if has lost its meaning?
   
   Agree.


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



[GitHub] [apisix] zhukexingkong removed a comment on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong removed a comment on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058756210


   I think created/modification version  is neccessry.


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



[GitHub] [apisix] tokers commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1050696329


   > > still hope to improve /apisix/admin/route/{id}
   > 
   > In fact, all routes configurations exist as a whole. Any modification to a route will cause the entire radixtree to be rebuilt.
   
   Not related to the radix tree, but exposing the modified index and create index for the route in ETCD.


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



[GitHub] [apisix] tzssangglass commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1054060188


   > Hope to improve /apisix/admin/route/{id} to get modifiedIndex and createdIndex
   
   I see, you want to splice the redis key by expose modifiedIndex and then the other services look up the value in redis based on the key?
   
   Perhaps we could add a configuration to `config-default.yaml` to indicate whether to expose modifiedIndex and createdIndex, which is disabledby default.


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



[GitHub] [apisix] spacewander commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1057748832


   An alternative solution is to fetch the route via control API, which is expected to expose the raw data. Or even communicate with the etcd directly.
   
   Not sure about exposing the created/modification version of the configuration is a leaky abstraction or necessary.


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



[GitHub] [apisix] zhukexingkong commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
zhukexingkong commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058756210


   I think created/modification version  is neccessry.


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



[GitHub] [apisix] tzssangglass commented on issue #6397: request help: How can I get the "modifiedIndex" of a route?

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6397:
URL: https://github.com/apache/apisix/issues/6397#issuecomment-1058795562


   > I see, you want to splice the redis key by expose modifiedIndex and then the other services look up the value in redis based on the key?
   
   @zhukexingkong If this is what you need, unfortunately, APISIX does not promise consistency between the key you generate by stitching the modifiedIndex from the admin api and the key stored in redis.


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