apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
167 stars 69 forks source link

当前5.0版本Go Plugin在最新的apisix:3.6.0上无法运行 #145

Closed thinkdb1 closed 8 months ago

thinkdb1 commented 8 months ago

Issue description

我在docker中运行最新版本的apisix:3.6.0-debian,在路由上配置默认插件say:

{
  "uri": "/*",
  "name": "测路2",
  "methods": [
    "GET",
    "POST",
    "PUT",
    "DELETE",
    "PATCH",
    "HEAD",
    "OPTIONS",
    "CONNECT",
    "TRACE",
    "PURGE"
  ],
  "plugins": {
    "ext-plugin-pre-req": {
      "_meta": {
        "disable": false
      },
      "name": "say",
      "value": "{\"body\":\"hello\"}"
    }
  },
  "upstream_id": "484626149452809097",
  "status": 1
}

但执行时发现虽然ext-plugin-pre-req运行但say插件RequestFilter方法并没有调用,经过打点追踪发现/internal/plugin/conf.go中的PrepareConf方法的cache.Set成功了但GetRuleConf时cache.Get获取到空,导致HTTPReqCall中调用(ph *requestPhase) filter没有()执行。在之前版本可以正常使用,不知是哪里问题,请求帮忙看看

apisix配置文件

apisix:
  node_listen: 9080              # APISIX listening port
  enable_ipv6: false

  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

deployment:
  admin:
    allow_admin:               # https://nginx.org/en/docs/http/ngx_http_access_module.html#allow
      - 0.0.0.0/0              # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.

    admin_key:
      - name: "admin"
        key: edd1c9f034335f136f87ad84b625c8f1
        role: admin                 # admin: manage all configuration data

      - name: "viewer"
        key: 4054f7cf07e344346cd3f287985e76a2
        role: viewer

  etcd:
    host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
      - "http://127.0.0.1:2380"          # multiple etcd address
    prefix: "/myapisix"               # apisix configurations prefix
    timeout: 30                     # 30 seconds

plugin_attr:
  prometheus:
    export_addr:
      ip: "0.0.0.0"
      port: 9091

ext-plugin:
  cmd: ["/usr/local/apisix/go-runner", "run"]

下面是部分日志PrepareConf是set,当时获取有值、err是nil,GetRuleConf是后面获取里面是空、err是nil

2023/10/27 07:29:37 [warn] 62#62: *117 [lua] init.lua:961: ^^^^^^^^^PrepareConf$$$$$$$ token: 1 PrepareConf 
                                                                                                         /route#484626227450086281#ext-plugin-pre-req#518 <nil>
, context: ngx.timer
2023/10/27 07:29:37 [warn] 62#62: *117 [lua] init.lua:961: 2023-10-27T07:29:37.178Z     INFO    server/server.go:132    receive rpc type: 2 data length: 580     {"SW_CTX": "[,,N/A,N/A,-1]"}
, context: ngx.timer
2023/10/27 07:29:37 [warn] 62#62: *117 [lua] init.lua:961: ^^^^^^^^^in$$$$$$$RPCHTTPReqCall RPCHTTPReqCall
^^^^^^^^^$$$$$$$GetRuleConf token: 1
[] <nil>
2023/10/27 07:29:37 [warn] 62#62: *117 [lua] init.lua:961: ^^^^^^^^^$$$$$$$filter0 filterConfig 0
, context: ngx.timer
2023/10/27 07:29:37 [warn] 62#62: *117 [lua] init.lua:961: ######req: &{0xc0002040c0 0xc000206000 [] [] <nil> map[] map[] 

Environment