apache / apisix-go-plugin-runner

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

request help: Fail with 503 on sample plugin say #56

Closed ericsyh closed 2 years ago

ericsyh commented 2 years ago

Issue description

I followed the step to install the APISIX, build the go-plugin-runner and create the route with plugin say. But the response is 503 Service Temporarily Unavailable when i execute curl 127.0.0.1:9080/get.

Step to reproduce:

  1. Install the APISIX, build the go-plugin-runner
  2. Change the APISIX config:
    apisix:
    admin_key:
    - name: admin
      key: edd1c9f034335f136f87ad84b625c8f1 
      role: admin
    ext-plugin:
    cmd: ["/home/ericsyh/apisix-go-plugin-runner-master/go-runner","run"]
  3. start the APISIX, and check the process
    
    ps -ef | grep apisix

root 1127 1 0 16:51 ? 00:00:00 nginx: master process openresty -p /usr/local/apisix -c /usr/local/apisix/conf/nginx.conf root 3208 934 0 17:03 pts/0 00:00:00 grep --color=auto apisix

4. Create the route

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/get", "plugins": { "ext-plugin-pre-req": { "conf": [ {"name":"say", "value":"{\"body\":\"hello\"}"} ] } }, "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }'

{"action":"set","node":{"key":"\/apisix\/routes\/1","value":{"status":1,"update_time":1640451895,"upstream":{"pass_host":"pass","nodes":{"127.0.0.1:1980":1},"type":"roundrobin","scheme":"http","hash_on":"vars"},"create_time":1640451895,"id":"1","plugins":{"ext-plugin-pre-req":{"conf":[{"name":"say","value":"{\"body\":\"hello\"}"}]}},"priority":0,"uri":"\/get"}}}

5. Test the plugin say:

curl 127.0.0.1:9080/get

503 Service Temporarily Unavailable

503 Service Temporarily Unavailable


openresty


### Environment

* APISIX Go Plugin Runner's version: master/latest
* APISIX version: 2.11.0
* Go version: go1.17.5 and go1.15.14 both tested
* OS (cmd: `uname -a`): CentOS7
spacewander commented 2 years ago

Does any error log in the error.log? We can check if the go plugin runner is running, and the ./conf/apisix-xxx.sock is connectable by APISIX. Note that the APISIX & the plugin runner should run in the same network namespace, if you run them inside docker.

ericsyh commented 2 years ago

Does any error log in the error.log? We can check if the go plugin runner is running, and the ./conf/apisix-xxx.sock is connectable by APISIX. Note that the APISIX & the plugin runner should run in the same network namespace, if you run them inside docker.

Thanks a lot, it should be the permission issue. I installed the apisix by RPM, and clone and build the go-plugin-runner under /home directory.

As i check the error.log, i found this error and seems apisix coud not create the sock file under the go-runner directory.

2021-12-27T02:08:44.908Z    WARN    server/server.go:190    listening to /home/ericsyh/apisix-go-plugin-runner-master/conf/apisix-17338.sock
2021-12-27T02:08:44.908Z    FATAL   server/server.go:205    listen /home/ericsyh/apisix-go-plugin-runner-master/conf/apisix-17338.sock: listen unix /home/ericsyh/apisix-go-plugin-runner-master/conf/apisix-17338.sock: bind: no such file or directory
github.com/apache/apisix-go-plugin-runner/internal/server.Run
    /home/ericsyh/apisix-go-plugin-runner-master/internal/server/server.go:205
github.com/apache/apisix-go-plugin-runner/pkg/runner.Run
    /home/ericsyh/apisix-go-plugin-runner-master/pkg/runner/runner.go:43
main.newRunCommand.func1
    /home/ericsyh/apisix-go-plugin-runner-master/cmd/go-runner/main.go:134
github.com/spf13/cobra.(*Command).execute
    /root/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
    /root/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960
github.com/spf13/cobra.(*Command).Execute
    /root/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.main
    /home/ericsyh/apisix-go-plugin-runner-master/cmd/go-runner/main.go:160
runtime.main
    /usr/lib/golang/src/runtime/proc.go:204
, context: ngx.timer

After moving the go-runner binary to the /usr/local/apisix/apisix, it works now. I can see the socket file under /usr/local/apisix/conf.

spacewander commented 2 years ago

Good. Consider solved. Feel free to reopen it if need.