apache / apisix-go-plugin-runner

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

register plugin success but do not match it when i visit the route #49

Closed hwyzleo closed 2 years ago

hwyzleo commented 2 years ago

I have got the go-runner and put it in the apisix container. when i restart the apisix, i can see the log in console like register plugin fault-injection register plugin limit-req register plugin say register plugin sign-verify (mine) and i try to set the route with mine plugin like

{
  "uri": "/message/header",
  "name": "show header",
  "methods": [
    "POST"
  ],
  "host": "mp.test.com",
  "plugins": {
    "ext-plugin-pre-req": {
      "conf": [
        {
          "name": "sign-verify",
          "value": "{\"verify_endpoint\":\"http://service.message:8080/signVerify\"}"
        },
        {
          "name": "say",
          "value": "{\"body\":\"say something\"}"
        }
      ]
    },
    "proxy-rewrite": {
      "uri": "/header"
    }
  },
  "upstream_id": "382988546614493882",
  "labels": {
    "API_VERSION": "V1"
  },
  "status": 1
}

when i visit the route, upstream can response, but plugin sign-verify and say do not trigger. how it happen?

spacewander commented 2 years ago

Could you run the runner with -m dev and see if it has received the RPC from the APISIX during the request?

hwyzleo commented 2 years ago

Could you run the runner with -m dev and see if it has received the RPC from the APISIX during the request?

do you mean use running mode with that argument like this? cmd: ["/path/to/apisix-go-plugin-runner/go-runner", "run", "-m", "dev"] or use debugging mode? in order to confirm the issue, i used debugging mode locally with apisix docker and go-runner through /tmp/runner.sock file, after set the route and plugin, i found nothing in apisix log or go-runner log like 'register plugin say', and the plugin still did not trigger.

hwyzleo commented 2 years ago

Could you run the runner with -m dev and see if it has received the RPC from the APISIX during the request?

by the go-runner log, i thought the handleConn function is not be called, but i didn't find any error in apisix log during the request, how to troubleshoot?

spacewander commented 2 years ago

Any interesting log in the APISIX? You can add more logs to this function: https://github.com/apache/apisix/blob/b8daf65b3c0690138feccb2ce399fc58349ac7ee/apisix/plugins/ext-plugin/init.lua#L435.

hwyzleo commented 2 years ago

My fault, because I set the route and plug-in through the apisix dashboard before, it did not have any error response after i set, so I did not think that the plugin did not take effect. Yesterday I tried to use REST API to set up, the console directly told me that ext-plugin-pre-req plugin did not work, I found the key reason. Please close the current issue.