Skip to content

bug: using HTTP PATCH method to modify plugin pemeters return 405 #4763

Description

Issue description

on apisx 2.1, it supports using Http PATCH to modify plugin pemeters,for example

[root@qizhendong-dev2 /]# curl  http://127.0.0.1:9080/apisix/admin/global_rules/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -s | python -m json.tool
{
    "action": "get",
    "count": "1",
    "node": {
        "key": "/apisix/global_rules/1",
        "value": {
            "create_time": 1628162770,
            "id": "1",
            "plugins": {
                "http-logger": {
                    "auth_header": "",
                    "batch_max_size": 1,
                    "buffer_duration": 60,
                    "concat_method": "new_line",
                    "inactive_timeout": 5,
                    "include_req_body": false,
                    "max_retry_count": 0,
                    "name": "http logger",
                    "retry_delay": 1,
                    "send_prometheus_data": false,
                    "timeout": 3,
                    "uri": "http://10.181.159.72:15151",
                    "use_tcp_transmission": true
                },
                "limit-conn": {
                    "burst": 0,
                    "conn": 10001,
                    "default_conn_delay": 0.1,
                    "key": "remote_addr",
                    "rejected_code": 503
                }
            },
            "update_time": 1628162770
        }
    }
}
[root@qizhendong-dev2 /]# curl -i -X PATCH  http://127.0.0.1:9080/apisix/admin/global_rules/1/plugins/limit-conn/conn -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d "10000"
HTTP/1.1 405 Not Allowed
Date: Thu, 05 Aug 2021 11:26:21 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 154
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
Server: APISIX/2.7

<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>openresty</center>
</body>
</html>

error.log

2021/08/05 19:26:21 [error] 4705#4705: *1582 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/admin/utils.lua:37: attempt to index local 'patch_conf' (a number value)
stack traceback:
coroutine 0:
        /usr/local/apisix/apisix/admin/utils.lua: in function 'inject_timestamp'
        /usr/local/apisix/apisix/admin/global_rules.lua:159: in function </usr/local/apisix/apisix/admin/global_rules.lua:116>
        /usr/local/apisix/apisix/admin/init.lua:176: in function 'handler'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:721: in function 'dispatch'
        /usr/local/apisix/apisix/init.lua:757: in function 'http_admin'
        content_by_lua(nginx.conf:232):2: in main chunk, client: 127.0.0.1, server: _, request: "PATCH /apisix/admin/global_rules/1/plugins/limit-conn/conn HTTP/1.1", host: "127.0.0.1:9080"

Now, I use 2.1 which can work, but on 2.7 I got this error. We have many deploy scripts to manage our cluter and use a lot of http PATCH method

Environment

Bug report without environment information will be ignored or closed.

  • apisix version (cmd: apisix version):
    /usr/local/openresty/luajit/bin/luajit /usr/local/apisix/apisix/cli/apisix.lua version
    2.7
  • OS (cmd: uname -a):
    inux qizhendong-dev2 3.10.0-514.el7.x86_64 change: added doc of how to load plugin. #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):

nginx version: openresty/1.19.3.2
built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
built with OpenSSL 1.1.1k 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-

  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API):
    {"id":"47dd2614-0fe2-49ba-956a-f1e1ba707f03","version":"2.7","up_time":708,"boot_time":1628162758,"etcd_version":"3.4.0","hostname":"qizhendong-dev2","last_report_time":1628163418}

etcdctl version: 3.4.13
API version: 3.4

  • apisix-dashboard version, if have: no
  • luarocks version, if the issue is about installation (cmd: luarocks --version):
    luarocks 3.7.0
    LuaRocks main command-line interface

Minimal test code / Steps to reproduce the issue

Bug report without steps to reproduce will be ignored or closed.

What's the actual result? (including assertion message & call stack if applicable)

What's the expected result?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions