Giter Site home page Giter Site logo

apisix-go-plugin-runner's Introduction

Go Plugin Runner for Apache APISIX

Go Report Card Build Status Codecov Godoc

Runs Apache APISIX plugins written in Go. Implemented as a sidecar that accompanies APISIX.

Status

This project is generally available.

Why apisix-go-plugin-runner

Apache APISIX offers many full-featured plugins covering areas such as authentication, security, traffic control, serverless, analytics & monitoring, transformations, logging.

It also provides highly extensible API, allowing common phases to be mounted, and users can use these API to develop their own plugins.

This project is APISIX Go side implementation that supports writing plugins in Go.

Currently, Go Plugin Runner is provided as a library. This is because the convention of Go is to compile all the code into an executable file.

Although there is a mechanism for Go Plugin to compile the plugin code into a dynamic link library and then load it into the binary. But as far as experience is concerned, there are still some imperfections that are not so simple and direct to use.

The structure of the apache/apisix-go-plugin-runner repository on GitHub is as follows:

.
├── cmd
├── internal
├── pkg

internal is responsible for the internal implementation, pkg displays the external interface, and cmd provides examples of the demonstration. There is a subdirectory of go-runner under the cmd directory. By reading the code in this section, you can learn how to use Go Plugin Runner in practical applications.

How it Works

At present, the communication between Go Plugin Runner and Apache APISIX is an RPC based on Unix socket. So Go Plugin Runner and Apache APISIX need to be deployed on the same machine.

Enable Go Plugin Runner

As mentioned earlier, Go Plugin Runner is managed by Apache APISIX, which runs as a child process of APISIX. So we have to configure and run this Runner in Apache APISIX.

The following configuration process will take the code cmd/go-runner in the apisix-go-plugin-runner project as an example.

  1. Compile the sample code. Executing make build generates the executable file go-runner.
  2. Make the following configuration in the conf/config.yaml file of Apache APISIX:
ext-plugin:
  cmd: ["/path/to/apisix-go-plugin-runner/go-runner", "run"]

With the above configuration, Apache APISIX pulls up go-runner when it starts and closes go-runner when it stops.

In view of the fact that apisix-go-plugin-runner is used in the form of a library in the actual development process, you need to replace the above example configuration with your own executable and startup instructions.

Finally, after the startup of Apache APISIX, go-runner will be started along with it.

Other configuration methods

Of course, if you need to take these three steps every time you verify the functionality in the development process, it is quite tedious. So we also provide another configuration that allows apisix-go-plugin-runner to run independently during development.

  1. The first thing to do is to compile the code.
  2. Configure the following in the conf/config.yaml file of Apache APISIX:
ext-plugin:
  path_for_test: /tmp/runner.sock
  1. Start go-runner with the following code.
APISIX_LISTEN_ADDRESS=unix:/tmp/runner.sock ./go-runner run

Notice that we specify the socket address to be used for go-runner communication through the environment variable APISIX_LISTEN_ADDRESS. This address needs to be consistent with the configuration in Apache APISIX.

License

Apache 2.0 LICENSE

apisix-go-plugin-runner's People

Contributors

an-dj avatar belyenochi avatar bzp2010 avatar chever-john avatar dependabot[bot] avatar guitu168 avatar kvii avatar mrlyc avatar ms2008 avatar rampagecong avatar reatang avatar ronething avatar shuaijinchao avatar soulbird avatar spacewander avatar sylviababy avatar tomcn0803 avatar tylitianrui avatar yunkunrao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apisix-go-plugin-runner's Issues

bug: 在K8S的Pod中无法获取K8S的配置

apisix-go-plugin-runner中使用了client-go作为K8S客户端,尝试从K8SConfigMaps中获取配置数据,用来初始化插件。

APISIX-SERVER部署在GKE中,并且配置文件中也指定了执行Go插件

ext-plugin:
        cmd: ["/plugins/go-runner", "run"]

但是在集群中启动时无法获取K8S的配置信息。

初始化代码如下:

config, err := rest.InClusterConfig()
2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: W1028 02:51:23.682992 1084 client_config.go:617] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.
--
Fri, Oct 28 2022 10:51:23 am | , context: ngx.timer
Fri, Oct 28 2022 10:51:23 am | 2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: W1028 02:51:23.683029 1084 client_config.go:622] error creating inClusterConfig, falling back to default config: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined
Fri, Oct 28 2022 10:51:23 am | , context: ngx.timer
Fri, Oct 28 2022 10:51:23 am | 2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: panic: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

Cannot setting response header and proxy to backend at the same time in go plugin

Issue description

I am developing a sso login plugin using apisix-go-plugin-runner. After setting response headers like cookies, the response will just return to client, what I expect is setting cookies in response header and sending request to backend service at the same time. Can anyone help solving this problem?

Environment

  • APISIX Go Plugin Runner's version: 0.2.0
  • APISIX version: 2.12.0
  • Go version: 1.17.4
  • OS (cmd: uname -a): macOS

bug: there is a typo while populating GITSHA

Issue description

There is a typo in this place:

GITSHA ?= $(shell git rev-parse --short=7 HEAD 2> /dev/null | echo '')

The pipeline here should be logical or operational, which is a double pipe symbol as ||.

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

Minimal test code / Steps to reproduce the issue

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

Version: latest
Git SHA: 
Go Version: go1.17.5
Building OS/Arch: linux/amd64
Running OS/Arch: linux/amd64

What's the expected result?

Version: latest
Git SHA: 0cfd47b
Go Version: go1.17.5
Building OS/Arch: linux/amd64
Running OS/Arch: linux/amd64

panic recovered: runtime error: invalid memory address or nil pointer dereference

Issue description

apisix-go-plugin-runner process will panic after running for a while,it works fine when the beginning

Environment

  • APISIX Go Plugin Runner's version:0.2.0
  • APISIX version:2.10.0
  • Go version:go1.15.5 darwin/amd64
  • OS (cmd: uname -a):mac os catalina 10.14.4

the apisix and runner are running in docker container,use unix:/tmp/x.sock

Minimal test code / Steps to reproduce the issue

1.run apisix-go-plugin-runner
2.waiting for a while
3.request apisix route

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

2021-10-11T09:01:28.801Z	INFO	server/server.go:94	Client connected (unix)
2021-10-11T09:01:28.807Z	INFO	server/server.go:110	receive rpc type: 2 data length: 572
2021-10-11T09:01:28.811Z	ERROR	server/server.go:60	panic recovered: runtime error: invalid memory address or nil pointer dereference
github.com/apache/apisix-go-plugin-runner/internal/server.recoverPanic
	/Users/Downloads/apisix-go-plugin-runner-0.2.0-src/internal/server/server.go:60
runtime.gopanic
	/usr/local/go/src/runtime/panic.go:969
runtime.panicmem
	/usr/local/go/src/runtime/panic.go:212
runtime.sigpanic
	/usr/local/go/src/runtime/signal_unix.go:742
github.com/google/flatbuffers/go.(*Builder).Reset
	/Users/go/pkg/mod/github.com/google/[email protected]+incompatible/go/builder.go:45
github.com/apache/apisix-go-plugin-runner/internal/util.PutBuilder
	/Users/Downloads/apisix-go-plugin-runner-0.2.0-src/internal/util/pool.go:37
github.com/apache/apisix-go-plugin-runner/internal/server.handleConn
	/Users/Downloads/apisix-go-plugin-runner-0.2.0-src/internal/server/server.go:121

request help: The upstream service cannot be invoked after the header is set in the Filter method

Issue description

w.Header().Set("trace_id",uuid.NewV4().String())
w.Header().Set("span_id",uuid.NewV4().String())

Add the above code to the Filter method, calling the registered route without returning anything and calling the upstream service.

Environment

  • APISIX Go Plugin Runner's version:v0.2.0
  • APISIX version:2.12.0
  • Go version:go version go1.16.13 linux/amd64
  • OS (cmd: uname -a):Linux localdev 3.10.0-1160.49.1.el7.x86_64 #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

request help: Fail with 503 on sample plugin say

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"]
  1. 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
  1. 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"}}}
  1. Test the plugin say:
curl 127.0.0.1:9080/get

<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>openresty</center>
</body>
</html>

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

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

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?

request help:

Issue description

Following is my plugin config. I find that the response-rewrite plugin is invalid because it will only call the plugin.HTTPReqCall(buf, conn). So the ResponseRewrite.ResponseFilter will not be executed. I don't know why ty (:= header[0]) equals 2.

"ext-plugin-post-req": {
      "conf": [
        {
          "name": "response-rewrite",
          "value": "{\"status\":200,\"headers\":{\"test\":\"t\"},\"body\":\"aaa\"}"
        }
      ],
      "disable": false
    }

Environment

  • APISIX Go Plugin Runner's version: master branch
  • APISIX version: 2.13.1
  • Go version: 1.17
  • OS (cmd: uname -a):

request help: rewrite the http request method,

Issue description

Environment

  • APISIX Go Plugin Runner's version: v0.3.0
  • APISIX version: 2.14.1
  • Go version: go1.17.9 darwin/arm64
  • OS (cmd: uname -a): Darwin x-Pro-2.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64

Question:
I need rewrite the http request method, can you add the method r.SetMethod() just like r.SetPath().

Why:

  • We have many apis using the PUT DELETE methods, and the client do not supported those methods, but only GET/POST methods.
  • We consider that put extra header named X-HTTP-Method-Override, then , rewrite the method to this in go runner plugin.

Example:
Client -> Method(POST) and X-HTTP-Method-Override: PUT -> Go Runner Plugin -> Method(PUT) -> Upstream

request help: Can a reverse proxy like proxy_pass be implemented in the Go Runner plugin?

Issue description

我想使用 Go Runner 来实现灰度策略的插件,所以需要反向代理的功能,所以在 Go Runner 插件中可以实现吗?

Environment

  • apisix version: 2.11.0
  • OS: Linux ccc8f2dba1bc 5.10.81.1-microsoft-standard-WSL2 SMP Mon Nov 22 18:52:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version: openresty/1.19.9.1
  • etcd version: 3.4.0
  • apisix-dashboard version: 2.10.1

bug: rpc error: code = Internal desc = server closed the stream without sending trailers

Current Behavior

apisix: apache/apisix:2.15.0-alpine
plugin-runner: apache/apisix-go-plugin-runner v0.4.0

run apisix-go-plugin-runner ,in func RequestFilter, WriteHeader then return, grpc client will report an error(code = Internal desc = server closed the stream without sending trailers)

I studied for a day and didn't know how to solve the problem. can anybody help solve the problem? thanks a lot!

Expected Behavior

grpc client not report error,and can get trailers

Error Logs

rpc error: code = Internal desc = server closed the stream without sending trailers

Steps to Reproduce

apisix: apache/apisix:2.15.0-alpine
plugin-runner: apache/apisix-go-plugin-runner v0.4.0

  1. modify code in apisix-go-plugin-runner-master\cmd\go-runner\plugins\say.go, as follows:
func (p *Say) RequestFilter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
	w.Header().Set("Content-Type", r.Header().Get("Content-Type"))
	num := rand.Int()
	if num%2 == 1 {
		w.WriteHeader(http.StatusOK)
		w.Header().Set("mykey", "test")
		w.Header().Set("Grpc-Status", "0")
		w.Header().Set("Grpc-Message", "ok")
		w.Header().Set("Grpc-Status-Details-Bin", "")
		return
	}
}

run a grpc server in 192.168.56.19:8301
2. then run apisix, config upstream in APISIX Dashboard,as follows:

{
  "nodes": [
    {
      "host": "192.168.56.19",
      "port": 8301,
      "weight": 1
    }
  ],
  "timeout": {
    "connect": 6,
    "send": 6,
    "read": 6
  },
  "type": "roundrobin",
  "scheme": "grpc",
  "pass_host": "pass",
  "name": "testa",
  "keepalive_pool": {
    "idle_timeout": 60,
    "requests": 1000,
    "size": 320
  }
}
  1. then add a route config, as follows:
{
  "uri": "/routeguide.RouteGuide/GetFeature",
  "name": "testa1",
  "methods": [
    "GET",
    "POST",
    "PUT",
    "DELETE",
    "PATCH",
    "HEAD",
    "OPTIONS",
    "CONNECT",
    "TRACE"
  ],
  "plugins": {
    "ext-plugin-post-req": {
      "conf": [
        {
          "name": "say",
          "value": "{\"body\":\"123\"}"
        }
      ],
      "disable": false
    }
  },
  "upstream_id": "425744995673178819",
  "status": 1
}
  1. then use client grpc call apisix, but have an error (rpc error: code = Internal desc = server closed the stream without sending trailers),as follows:
2022/09/21 19:45:47.860 [I] [main.go:59]  header: map[content-type:[application/grpc] date:[Wed, 21 Sep 2022 11:45:47 GMT] mykey:[test] server:[APISIX/2.15.0]]
2022/09/21 19:45:47.860 [I] [main.go:60]  trailer: map[]
2022/09/21 19:45:47.861 [E] [main.go:62]  rpc error: code = Internal desc = server closed the stream without sending trailers

Environment

os: win10
apisix: apache/apisix:2.15.0-alpine (use apisix-docker\example\docker-compose.yml docker-compose up)
plugin-runner: apache/apisix-go-plugin-runner v0.4.0

request help: Why apisix-go-plguin have performed very poorly

Issue description

use lua-fault-injection return message,its performance is normal,but, use go-plguin-say return message, which have performed very poorly

Environment

  • APISIX Go Plugin Runner's version: 0.2.0
  • APISIX version: 2.13
  • Go version: go 1.17
  • OS (cmd: uname -a):
    apisix deployed in CentOS 7.9 64, ali ecs 2C8G
    wrk deployed in CentOS 7.9 64,ali ecs 8C16G

path:/hello,lua-fault-injection
path:/get,go-plguin-say
H305ijmyYd

bug: failed to get large body

Issue description

我用request.Body来获取请求的body,但是当请求请求体过大时,该函数会提示获取失败,数据被截断。

Environment

  • APISIX Go Plugin Runner's version:
    v0.3.0
  • APISIX version:
    2.15.0
  • Go version:
    go version go1.15.1 linux/amd64
  • OS (cmd: uname -a):
    Linux fefcfe0549f3 4.18.0 #1 SMP Tue Sep 27 10:33:52 CST 2022 x86_64 x86_64 x86_64 GNU/Linux

Minimal test code / Steps to reproduce the issue

构造一个足够大的body,然后在go-runner中通过req.Body获取body

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

传入的body首先提示存入一个临时文件,然后在调用req.Body时获取body失败,提示被截断。
觉得是存入临时文件的数据没有正确传递给go-runner,但是在ext-plugin/init.lua查看body的长度好像没问题

2022/11/14 17:15:43 [warn] 85510#85510: *444 a client request body is buffered to a temporary file /usr/local/apisix/client_body_temp/0000000001, client: 10.131.115.28, server: _, request: "POST ******** HTTP/1.1", host: "127.0.0.1:9080"
2022/11/14 17:15:43 [warn] 85510#85510: *444 [lua] init.lua:319: handle_extra_info(): request body len 900938, client: 10.131.115.28, server: _, request: "POST ****** HTTP/1.1", host: "127.0.0.1:9080"
2022/11/14 17:15:43 [warn] 85514#85514: *49 [lua] init.lua:915: 2022-11-14T17:15:43.465+0800    INFO    http/request.go:390     receive rpc type: 3 data length: 900964
, context: ngx.timer
2022/11/14 17:15:43 [warn] 85514#85514: *49 [lua] init.lua:915: 2022-11-14T17:15:43.466+0800    ERROR   util/msg.go:55  read: truncated, only get the first 219260 bytes
github.com/apache/apisix-go-plugin-runner/internal/util.ReadErr
        /home/go/pkg/mod/github.com/apache/[email protected]/internal/util/msg.go:55
github.com/apache/apisix-go-plugin-runner/internal/http.(*Request).askExtraInfo
        /home/go/pkg/mod/github.com/apache/[email protected]/internal/http/request.go:394
github.com/apache/apisix-go-plugin-runner/internal/http.(*Request).Body
        /home/go/pkg/mod/github.com/apache/[email protected]/internal/http/request.go:183

What's the expected result?

获取body成功

request help: How to get request body in Filter?

Issue description

在写一个鉴权的自定义插件,需要获取请求参数进行加签校验,防止请求参数被篡改,但是从pkg/http/Request 中如何获取请求(POST)参数body?

Environment

  • APISIX Go Plugin Runner's version: v0.2.0
  • APISIX version:2.12.1
  • Go version:go1.16.5 linux/amd64
  • OS (cmd: uname -a):Linux e3191d6da83e 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 Linux

bug: limit-req plugin does not work

Issue description

"conf":[
        {
        "name":"limit-req",
        "value":"{\"rate\":5,\"burst\":1}"
        }
]

and add two requests

table.Entry("Test if limit-req plugin work.", tools.HttpTestCase{
			Object:       tools.GetA6Expect(),
			Method:       http.MethodGet,
			Path:         "/test/go/runner/limitreq",
			ExpectStatus: http.StatusOK,
		}),
table.Entry("Test if limit-req plugin work.", tools.HttpTestCase{
			Object:       tools.GetA6Expect(),
			Method:       http.MethodGet,
			Path:         "/test/go/runner/limitreq",
			ExpectStatus: http.StatusOK,
		}),

It does not work. Then I got:

Error:
    	 expected status equal to:
    	  "200 OK"

    	 but got:
    	  "503 Service Unavailable"

I tail the APISIX's log, find that "limit req rate exceeded".
And I try to solve this problem. I found that the code of limit-req in /apisix-go-plugin-runner/cmd/go-runner/plugins does not work.

Can someone help me?

Environment

  • APISIX Go Plugin Runner's version: version latest-d3fe333-go1.18( result after run APISIX_LISTEN_ADDRESS=unix:/tmp/runner.sock ./go-runner version
  • APISIX version: run docker-compose -f ci/docker-compose.yml up -d
  • Go version: 1.18
  • OS (cmd: uname -a): Darwin Johns-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:35:58 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T6000 arm64

Minimal test code / Steps to reproduce the issue

  1. git clone [email protected]:Chever-John/apisix-go-plugin-runner.git
  2. cd apisix-go-plugin-runner
  3. make build
  4. APISIX_LISTEN_ADDRESS=unix:/tmp/runner.sock APISIX_CONF_EXPIRE_TIME=3600 ./go-runner run &
  5. docker-compose -f ci/docker-compose.yml up -d
  6. go install github.com/onsi/ginkgo/[email protected]
  7. cd /tests/e2e
  8. You can modify the conf tests/e2e/plugins/plugins_limit_req_test.go
  9. ginkgo -r

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

I guess the file cmd/go-runner/plugins/limit_req.go

What's the expected result?

if conf is

"conf":[{"name":"limit-req","value":"{\"rate\":0,\"burst\":1}"}]

then

table.Entry("Test if limit-req plugin work.", tools.HttpTestCase{
			Object:       tools.GetA6Expect(),
			Method:       http.MethodGet,
			Path:         "/test/go/runner/limitreq",
			ExpectStatus: http.StatusOK,
		}),
table.Entry("Test if limit-req plugin work.", tools.HttpTestCase{
			Object:       tools.GetA6Expect(),
			Method:       http.MethodGet,
			Path:         "/test/go/runner/limitreq",
			ExpectStatus: http.StatusServiceUnavailable,
		}),

will work.

request help: running plugin runner with apisix - no socket file

Go Version: 1.17.6
APISIX Version: 2.11.0
APISIX-GO_PLUGIN_RUNNER: release/0.2.0

2022/01/24 00:07:05 [warn] 72671#72671: *68 [lua] init.lua:753: 2022-01-24T00:07:05.123-0600	INFO	plugin/plugin.go:66	register plugin limit-req
2022-01-24T00:07:05.123-0600	INFO	plugin/plugin.go:66	register plugin say
2022-01-24T00:07:05.123-0600	WARN	server/server.go:177	conf cache ttl is 1h0m0s
2022-01-24T00:07:05.123-0600	WARN	server/server.go:185	listening to /usr/local/apisix/logs/conf/apisix-72666.sock
2022-01-24T00:07:05.123-0600	FATAL	server/server.go:200	listen /usr/local/apisix/logs/conf/apisix-72666.sock: listen unix /usr/local/apisix/logs/conf/apisix-72666.sock: bind: no such file or directory
github.com/apache/apisix-go-plugin-runner/internal/server.Run
	/home/svmlp17/go-plugin-runner/apisix-go-plugin-runner/internal/server/server.go:200
github.com/apache/apisix-go-plugin-runner/pkg/runner.Run
	/home/svmlp17/go-plugin-runner/apisix-go-plugin-runner/pkg/runner/runner.go:43
main.newRunCommand.func1
	/home/svmlp17/go-plugin-runner/apisix-go-plugin-runner/cmd/go-runner/main.go:134
github.com/spf13/cobra.(*Command).execute
	/home/svmlp17/go/pkg/mod/github.com/spf13/[email protected]/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
	/home/svmlp17/go/pkg/mod/github.com/spf13/[email protected]/command.go:960
github.com/spf13/cobra.(*Command).Execute
	/home/svmlp17/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
main.main
	/home/svmlp17/go-plugin-runner/apisix-go-plugin-runner/cmd/go-runner/main.go:160
runtime.main
	/usr/local/go/src/runtime/proc.go:255
, context: ngx.timer
2022/01/24 00:07:05 [warn] 72671#72671: *68 [lua] init.lua:759: runner exited with reason: exit, status: 1, context: ngx.timer
2022/01/24 00:07:05 [warn] 72671#72671: *68 [lua] init.lua:329: flush_token(): flush conf token in shared dict, context: ngx.timer
2022/01/24 00:07:05 [warn] 72671#72671: *68 [lua] init.lua:664: flush conf token lrucache, context: ngx.timer
2022/01/24 00:07:05 [warn] 72671#72671: *68 [lua] init.lua:769: respawn runner 3 seconds later with cmd: ["\/home\/svmlp17\/go-plugin-runner\/apisix-go-plugin-runner\/go-runner","run"], context: ngx.timer
2022/01/24 00:07:05 [warn] 72667#72667: *23985 [lua] init.lua:329: flush_token(): flush conf token in shared dict, context: ngx.timer
2022/01/24 00:07:05 [warn] 72667#72667: *23985 [lua] init.lua:664: flush conf token lrucache, context: ngx.timer
2022/01/24 00:07:05 [warn] 72668#72668: *23986 [lua] init.lua:329: flush_token(): flush conf token in shared dict, context: ngx.timer
2022/01/24 00:07:05 [warn] 72668#72668: *23986 [lua] init.lua:664: flush conf token lrucache, context: ngx.timer
  • The plugin runner is not able to connect with the socket.
  • @RagavMaddali

request help: Introduce context to run plugin

Issue description

Currently, we have an implicit 60s timeout when running the Go plugin. The common way in Go is to use a Context that will time out after the 60s.

Therefore, we should find a way to introduce Context into plugin runner.

If you are interested in this issue, please discuss your design here before submitting any code. Thanks.

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

request help: control API for go plugin

Issue description

image
What should I do if I want to use the control API in the go plugin? Or is there any other solution to achieve similar functions

Environment

  • APISIX Go Plugin Runner's version:0.3.0
  • APISIX version: 2.14
  • Go version: 1.15
  • OS (cmd: uname -a): linux

Whether the apisix-go-plugin-runner can implement setCookie and then call the upstream service

Issue description

The current situation is that the http.setcookie is called directly in apisix and returns the result, and the upstream service cannot be called.

Environment

  • APISIX Go Plugin Runner's version:v0.2.0
  • APISIX version:2.12.0
  • Go version:go version go1.16.13 linux/amd64
  • OS (cmd: uname -a):Linux localdev 3.10.0-1160.49.1.el7.x86_64 ci: enable #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

request help: Whether the plugin is performant

Issue description

I use the official demo to directly return the html file, but its performance is not good

Environment

  • APISIX Go Plugin Runner's version: 0.2.0
  • APISIX version: apisix:2.11.0
  • Go version:1.。17
  • OS (cmd: uname -a): centos7.8
    I have 3 apisix instances 2c2g
    image
    some request rt is very high
    image
    code
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package plugins

import (
	"encoding/base64"
	"encoding/json"
	pkgHTTP "github.com/apache/apisix-go-plugin-runner/pkg/http"
	"github.com/apache/apisix-go-plugin-runner/pkg/log"
	"github.com/apache/apisix-go-plugin-runner/pkg/plugin"
	"net/http"
)

func init() {
	log.Infof("init开始...")
	err := plugin.RegisterPlugin(&Say{})
	if err != nil {
		log.Fatalf("注册插件失败 say: %s", err)
	}
}

// Say is a demo to show how to return data directly instead of proxying
// it to the upstream.
type Say struct {
}

type SayConf struct {
	Body   string `json:"body"`
}

func (p *Say) Name() string {
	return "say"
}

func (p *Say) ParseConf(in []byte) (interface{}, error) {
	log.Infof("解析配置开始...")
	conf := SayConf{}
	err := json.Unmarshal(in, &conf)
	return conf, err
}

func (p *Say) Filter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
	//获取配置文件对应值
	body := conf.(SayConf).Body


	if len(body) == 0 {
		log.Errorf("Body为空")
		return
	}
	resBody, err := base64.StdEncoding.DecodeString(body)
	if err != nil {
		log.Errorf("Base64解码不正确")
		return
	}
	w.Header().Set("Content-Type", "text/html")
	_, err = w.Write([]byte(resBody))
	if err != nil {
		log.Errorf("failed to write: %s", err)
	}
}

bug: 如果配置了plugin,前端调用的时候就会跨域

APISIX VERSION: 2.10
APISIX-GO-PLUGIN VERSION: 0.2.0

问题描述:
在配置了plugin的情况下,前端调用后端接口会导致跨域。
本来就是从不同的域访问过来的,可是在APISIX的配置中已经允许所有的来源访问了。
但是在加了go-plugin的情况下就会报跨域。

APISIX配置如下:
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"^/v1/admin/(.*)",
"/${1}"
],
"headers":{
"X-Forwarded-Prefix":"/v1/admin"
}
},
"cors": {},
"request-id": {
"include_in_response": true
},
"ext-plugin-pre-req": {
"conf": [
{
"name": "MicroserviceFilter",
"value": "{"strip_prefix":1}"
}
]
}
}

前端报错信息:
Access to fetch at 'xxxxx' from origin 'xxx' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

request help: support http proxy

Issue description

I want to support the forward-auth , but how does go-pugin-runner support me to proxy the current request directly to the url, and then process the response and pass it on?
I wrote a version in lua, but our technology stack is unified with go, so I want to use go to implement

    local core = require("apisix.core")
    local http = require("resty.http")
    local http_new = http.new()
    local res, err = http_new:request_uri("https://forward-auth.xxx.com", {
        ssl_verify = false,
        method = "GET",
        headers = {
            ["X-Forwarded-User"] = core.request.header(ctx, "X-Forwarded-User"),
            ["X-Forwarded-UID"] = core.request.header(ctx, "X-Forwarded-UID"),
            ["Cookie"]=core.request.header(ctx,"Cookie")
        },
    })
    if err ~= nil then
        core.log.error("==== Serverless Request Error: ", err)
        return
    end
    if (res ~= nil) then
        for k, v in pairs(res.headers) do
            core.response.set_header(k, v)
        end
    end
    if res.status == 302 then
        core.response.set_header("Location", res.headers.location)
        core.response.exit(302)
        return
    end

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

bug: invalid memory address or nil pointer dereference

Issue description

Environment

  • APISIX Go Plugin Runner's version: 0.0.2
  • APISIX version: 2.9
  • Go version: 1.16
  • OS (cmd: uname -a): Linux apisix-server-6c484454b4-gvgbt 5.14.1-1.el7.elrepo.x86_64 #1 SMP Wed Sep 1 18:34:12 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux(docker部署)

给某个路由定义好go-pre-plugin一段时间后(可能是因为长时间没有请求),go plugin会出错导致接口无法访问。异常信息:
2021/10/08 03:03:14 [warn] 56#56: *207 [lua] init.lua:681: 2021-10-08T03:03:14.440Z ERROR server/server.go:69 panic recovered: runtime error: invalid memory address or nil pointer dereference
2021/10/8 上午11:03:14 github.com/apache/apisix-go-plugin-runner/internal/server.recoverPanic
2021/10/8 上午11:03:14 /var/lib/jenkins/workspace/build-dev-apple-fuller-apisix-go-plugin-runner/apisix-go-plugin-runner/internal/server/server.go:69
2021/10/8 上午11:03:14 runtime.gopanic
2021/10/8 上午11:03:14 /root/go/src/runtime/panic.go:1038
2021/10/8 上午11:03:14 runtime.panicmem
2021/10/8 上午11:03:14 /root/go/src/runtime/panic.go:221
2021/10/8 上午11:03:14 runtime.sigpanic
2021/10/8 上午11:03:14 /root/go/src/runtime/signal_unix.go:735
2021/10/8 上午11:03:14 github.com/google/flatbuffers/go.(*Builder).Reset
2021/10/8 上午11:03:14 /root/go-path/pkg/mod/github.com/google/[email protected]+incompatible/go/builder.go:45
2021/10/8 上午11:03:14 github.com/apache/apisix-go-plugin-runner/internal/util.PutBuilder
2021/10/8 上午11:03:14 /var/lib/jenkins/workspace/build-dev-apple-fuller-apisix-go-plugin-runner/apisix-go-plugin-runner/internal/util/pool.go:37
2021/10/8 上午11:03:14 github.com/apache/apisix-go-plugin-runner/internal/server.handleConn
2021/10/8 上午11:03:14 /var/lib/jenkins/workspace/build-dev-apple-fuller-apisix-go-plugin-runner/apisix-go-plugin-runner/internal/server/server.go:122
2021/10/8 上午11:03:14 , context: ngx.timer

request help: error reporting when deploying plug-ins in running mode

Issue description

I use the official documents to deploy the go plug-in and mount the local address of the go runner into the docker. After starting apisix through the docker, I check the log and see that the plug-in execution fails.

My configured docker.yaml:
apisix:
image: apache/apisix:2.10.0-alpine
restart: always
privileged: true
volumes:
- ./apisix_log:/usr/local/apisix/logs
- ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
- /Users/yzy/Desktop/work/apisix-go-plugin-runner:/path/to/apisix-go-plugin-runner
depends_on:
- etcd
##network_mode: host
ports:
- "9080:9080/tcp"
- "9091:9091/tcp"
- "9443:9443/tcp"
- "9092:9092/tcp"
networks:
apisix:

External plug-in configuration in apifix configuration:
ext-plugin:
cmd: ["/path/to/apisix-go-plugin-runner/go-runner", "run"]

Error.log info:
2021/11/26 02:19:26 [warn] 49#49: *316 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:29 [warn] 53#53: *80 [lua] init.lua:699: respawning new runner..., context: ngx.timer
2021/11/26 02:19:29 [error] 53#61: lua pipe child execvp() failed while executing /path/to/apisix-go-plugin-runner/go-runner (8: Exec format error)
2021/11/26 02:19:29 [warn] 53#53: *80 [lua] init.lua:687: runner exited with reason: exit, status: 1, context: ngx.timer
2021/11/26 02:19:29 [warn] 53#53: *80 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:29 [warn] 53#53: *80 [lua] init.lua:697: respawn runner 3 seconds later with cmd: ["/path/to/apisix-go-plugin-runner/go-runner","run"], context: ngx.timer
2021/11/26 02:19:29 [warn] 49#49: *501 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:29 [warn] 47#47: *502 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:29 [warn] 50#50: *504 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:29 [warn] 48#48: *503 [lua] init.lua:592: flush conf token lrucache, context: ngx.timer
2021/11/26 02:19:32 [warn] 53#53: *80 [lua] init.lua:699: respawning new runner..., context: ngx.timer

Environment

  • APISIX Go Plugin Runner's version: 0.2.0
  • APISIX version: 2.10.0-alpine
  • Go version: go1.17.2 darwin/arm64
  • Docker version: 20.10.8
  • Operating system: MacBook Air (M1, 2020)

request help: pkgHttp.Request can't handle body data?

Issue description

I found that pkgHttp.Request does not support getting request body.
I tried to use hrc.GetRootAsStop(buf, 0).BodyBytes() to get the body data, but I got the following error:

ERROR   server/server.go:69     panic recovered: runtime error: slice bounds out of range [5153:864]
github.com/apache/apisix-go-plugin-runner/internal/server.recoverPanic
apisix-go-plugin-runner/internal/server/server.go:69
github.com/google/flatbuffers/go.(*Table).ByteVector
github.com/google/[email protected]+incompatible/go/table.go:37
ext-plugin-proto/go/A6/HTTPReqCall.(*Stop).BodyBytes
github.com/api7/[email protected]/go/A6/HTTPReqCall/Stop.go:90
github.com/apache/apisix-go-plugin-runner/internal/http.CreateRequest
apisix-go-plugin-runner/internal/http/request.go:351

will this function be added in the later version?

Environment

  • APISIX Go Plugin Runner's version: 0.2.0
  • APISIX version: 2.10
  • Go version: 1.16
  • OS (cmd: uname -a):

[Security] Workflow spell-checker.yml is using vulnerable action actions/checkout

The workflow spell-checker.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

docs: add CHANGELOG.md on the Go Plugin Runner repo

Issue description

can we add a CHANGELOG.md here?

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

Minimal test code / Steps to reproduce the issue

  1. Open Apisix website
  2. Go to download page > download card for go plugin runner > Changelog
  3. Open Changelog > broken(404)

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

What's the expected result?

CHANGELOG.md required so that in the download section or page does not break while going to changeling

help request: How to customize the log file path in apisix-go-plugin-runner

Description

As the documentation says I modified the LogOutput of runner.RunnerConfig{} by modifying LogFilePath, but no matter what path I modify LogFilePath to, the log of go-plugin will be printed in apisix_log/error.log in the end.So I want to know How can I customize the log file path in apisix-go-plugin-runner.Thanks

Environment

APISIX version (run apisix version):3.0.0
Operating system (run uname -a):Linux eee3e01b5631 4.19.76-linuxkit apache/apisix#1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux
OpenResty / Nginx version (run openresty -V or nginx -V):nginx version: openresty/1.21.4.1;built by gcc 10.2.1 20210110 (Debian 10.2.1-6);built with OpenSSL 1.1.1n 15 Mar 2022
etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
APISIX Dashboard version, if relevant:apache/apisix-dashboard:2.13-alpine
Plugin runner version, for issues related to plugin runners:apisix-go-plugin-runner(master)
LuaRocks version, for installation issues (run luarocks --version):

bug: key not found

系统中有大量的Key Not found日志,并且配置的plugin有概率不生效

2021-11-24T03:39:38.240Z WARN server/server.go:59 key not found
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.247Z INFO server/server.go:105 Client connected (unix)
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.247Z INFO server/server.go:121 receive rpc type: 2 data length: 1920
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.248Z WARN server/server.go:59 key not found
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.251Z INFO server/server.go:121 receive rpc type: 2 data length: 1924
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.251Z WARN server/server.go:59 key not found
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.295Z INFO server/server.go:121 receive rpc type: 2 data length: 1916
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.296Z WARN server/server.go:59 key not found
2021/11/24 上午11:39:38 , context: ngx.timer
2021/11/24 上午11:39:38 2021/11/24 03:39:38 [warn] 58#58: *203 [lua] init.lua:681: 2021-11-24T03:39:38.317Z INFO server/server.go:121 receive rpc type: 2 data length: 1916
2021/11/24 上午11:39:38 2021-11-24T03:39:38.317Z WARN server/server.go:59 key not found
2021/11/24 上午11:39:38 , context: ngx.timer

bug: WARN server/server.go:59 key not found

@envestcc

Could you log down the token & conf with the given patch?

diff --git internal/plugin/conf.go internal/plugin/conf.go
index 5758f0a..9f67c59 100644
--- internal/plugin/conf.go
+++ internal/plugin/conf.go
@@ -129,10 +129,12 @@ func (cc *ConfCache) SetInTest(token uint32, entries RuleConf) error {
 }

 func (cc *ConfCache) Get(token uint32) (RuleConf, error) {
+       log.Warnf("get conf with token %d", token)
        res, err := cc.tokenCache.Get(strconv.FormatInt(int64(token), 10))
        if err != nil {
                return nil, err
        }
+       log.Warnf("conf result with token %v", res.(RuleConf))
        return res.(RuleConf), err
 }

For apisix:

diff --git apisix/plugins/ext-plugin/init.lua apisix/plugins/ext-plugin/init.lua
index 6cb593c8..a43228c1 100644
--- apisix/plugins/ext-plugin/init.lua
+++ apisix/plugins/ext-plugin/init.lua
@@ -358,6 +358,8 @@ local rpc_handlers = {
             return nil, err
         end

+        core.log.warn("get conf token: ", token, " conf: ", core.json.delay_encode(conf.conf))
+
         builder:Clear()
         local var = ctx.var

And how to reproduce this issue?

request help: configure the plugin through dashboard does not work

Issue description

I want test apisix-go-plugin-runner whether can be used, it can be intercept by plugin when i used admin API create the Router, but it's not work when i create the Router by dashboard.

adminAPI request used apisix-go-plugin-runner docs example

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

The following is used for the configuration of the dashboard

{
  "uri": "/*",
  "name": "nginx-test",
  "desc": "nginx-test",
  "methods": [
    "GET",
    "POST",
    "PUT",
    "DELETE",
    "PATCH",
    "HEAD",
    "OPTIONS",
    "CONNECT",
    "TRACE"
  ],
  "plugins": {
    "ext-plugin-pre-req": {
      "disable": true,
      "name": "say",
      "value": "{\"body\":\"hello\"}"
    }
  },
  "upstream_id": "398094286752580298",
  "status": 1
}

upstream configuration

{
  "nodes": [
    {
      "host": "10.60.104.20",
      "port": 9081,
      "weight": 1
    },
    {
      "host": "10.60.104.20",
      "port": 9082,
      "weight": 1
    }
  ],
  "timeout": {
    "connect": 6,
    "send": 6,
    "read": 6
  },
  "type": "roundrobin",
  "scheme": "http",
  "pass_host": "pass",
  "name": "nginx-test",
  "desc": "nginx-test",
  "keepalive_pool": {
    "idle_timeout": 60,
    "requests": 1000,
    "size": 320
  }
}

Environment

  • APISIX Go Plugin Runner's version: latest-ade2e90-go1.16.2
  • APISIX version: 2.10.1-alpine
  • Go version: go version go1.16.2 linux/amd64
  • OS (cmd: uname -a): Linux f4b1f70a0825 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux (use docker-compose deployed)

request help: Remove the `util.RPCTest` hack

Issue description

The hack here is just for test. However, we can remove this hack if we use a map to store the type->handler mapping, instead of the case ... block.

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

feat: improve e2e test framework

This issue will solve two problems.

  1. Is it possible to let APISIX manage the go-runner in the e2e test runtime, just like the production environment?
  2. Remove unused HTTPS port.

Question #62 whether Apisix version 2.12 can be implemented?

Issue description

Can #62 be implemented if you rewrite apisix-go-plugin-runne yourself? The technical plan for the company project should be made. If it can't be realized, the technical plan can only be changed.

Environment

  • APISIX Go Plugin Runner's version:
  • APISIX version:
  • Go version:
  • OS (cmd: uname -a):

request help: How to pass headers from plugin runner to upstream

Issue description

We want to send custom headers from go plugin runner to the upstream. We have tried adding it to both request object and response object in custom plugin filter , but both are not working.

w http.ResponseWriter, r pkgHTTP.Request
r.Header().Set("x-team-info","abc")
w.Header().Add("x-team-info","abc)

Looking for a way to send headers from plugin runner filter to the upstream. We want to append new headers to the upstream.

Environment

  • APISIX Go Plugin Runner's version: master branch
  • APISIX version: 2.11.0
  • Go version: 1.6.2
  • OS (cmd: uname -a): centos (linux amd 64)

cc: @sudalaimuthu

request help: How to customize the log file path in apisix-go-plugin-runner

Issue description

As the documentation says I modified the LogOutput of runner.RunnerConfig{} by modifying LogFilePath, but no matter what path I modify LogFilePath to, the log of go-plugin will be printed in apisix_log/error.log in the end.So I want to know How can I customize the log file path in apisix-go-plugin-runner.Thanks

Environment

  • APISIX Go Plugin Runner's version:0.50
  • APISIX version:3.0.0
  • Go version:1.18
  • OS (cmd: uname -a):Linux eee3e01b5631 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux

bug: pkgHTTP.Request RespHeader() Add override previous value

Issue description

w http.ResponseWriter, r pkgHTTP.Request
r.RespHeader().Add("Set-Cookie","a=a; Expires=Wed, 21 Oct 2023 07:28:00 GMT; Secure; HttpOnly")
r.RespHeader().Add("Set-Cookie","b=b; Expires=Wed, 21 Oct 2023 07:28:00 GMT; Secure; HttpOnly")

Cookie a is missing in the response header

Environment

  • APISIX Go Plugin Runner's version: dee7fa0
  • APISIX version: 2.13.0
  • Go version: 1.18
  • OS (cmd: uname -a): centos

Minimal test code / Steps to reproduce the issue

  1. Start APISIX on docker
  2. Set Plugin filter codes
Filter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request)
{
  r.RespHeader().Add("Set-Cookie","a=a; Expires=Wed, 21 Oct 2023 07:28:00 GMT; Secure; HttpOnly")
  r.RespHeader().Add("Set-Cookie","b=b; Expires=Wed, 21 Oct 2023 07:28:00 GMT; Secure; HttpOnly")
  return
}

  1. Cookie a is missing in the response header

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

Cookie b can be found, Cookie a is missing

What's the expected result?

Both cookie a and b could be found

bug:

Issue description

Environment

  • APISIX Go Plugin Runner's version: 0.1.0
  • APISIX version: 2.6/2.7
  • Go version: 1.16.5
  • OS (cmd: uname -a): Linux 39446d29c7b6 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux (docker: apache/apisix:2.7-centos)

Minimal test code / Steps to reproduce the issue

1.set up a ext-plugin
2.do a request
3. got 503 response

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

2021/07/20 02:11:21 [warn] 46#46: *29715 [lua] plugin.lua:298: trace_plugins_info_for_debug(): Apisix-Plugins: ext-plugin-pre-req, prometheus, kafka-logger while logging request, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:39:28 [crit] 46#46: *75271 connect() to unix:/usr/local/apisix/conf/apisix-45.sock failed (13: Permission denied), client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:39:28 [error] 46#46: *75271 [lua] init.lua:553: phase_func(): failed to connect to the unix socket unix:/usr/local/apisix/conf/apisix-45.sock: permission denied, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:39:28 [warn] 46#46: *75271 [lua] plugin.lua:646: run_plugin(): ext-plugin-pre-req exits with http status code 503, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:39:28 [warn] 46#46: *75271 [lua] plugin.lua:298: trace_plugins_info_for_debug(): Apisix-Plugins: ext-plugin-pre-req, prometheus, kafka-logger, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:39:28 [warn] 46#46: *75271 [lua] plugin.lua:298: trace_plugins_info_for_debug(): Apisix-Plugins: ext-plugin-pre-req, prometheus, kafka-logger while logging request, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:48:31 [crit] 46#46: *89991 connect() to unix:/usr/local/apisix/conf/apisix-45.sock failed (13: Permission denied), client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:48:31 [error] 46#46: *89991 [lua] init.lua:553: phase_func(): failed to connect to the unix socket unix:/usr/local/apisix/conf/apisix-45.sock: permission denied, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:48:31 [warn] 46#46: *89991 [lua] plugin.lua:646: run_plugin(): ext-plugin-pre-req exits with http status code 503, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:48:31 [warn] 46#46: *89991 [lua] plugin.lua:298: trace_plugins_info_for_debug(): Apisix-Plugins: ext-plugin-pre-req, prometheus, kafka-logger, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"
2021/07/20 02:48:31 [warn] 46#46: *89991 [lua] plugin.lua:298: trace_plugins_info_for_debug(): Apisix-Plugins: ext-plugin-pre-req, prometheus, kafka-logger while logging request, client: 172.24.0.1, server: _, request: "GET /apis/dianshang/anchor/sales_info?platform_id=71&room_id=100533727735 HTTP/1.1", host: "localhost:9080"

What's the expected result?

ext plug works correctlly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.