zzzyuan0 opened a new issue, #10080:
URL: https://github.com/apache/apisix/issues/10080

   ### Description
   
   The version I'm using is github.com/apache/apisix-go-plugin-runner v0.5.0
   ---
   Plugin directory structure
   ```
   plugins
   - plugin
   -- say.go
   - go.mod
   - main.go
   ```
   main.go
   ```
   package main
   
   import (
        "github.com/apache/apisix-go-plugin-runner/pkg/runner"
        _ "skeiam/plugin"
   )
   
   func main() {
        cfg := runner.RunnerConfig{}
   
        runner.Run(cfg)
   }
   
   ```
   say.go
   ```
   /*
    * 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/json"
        "net/http"
   
        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"
   )
   
   func init() {
        err := plugin.RegisterPlugin(&Say{})
        if err != nil {
                log.Fatalf("failed to register plugin say: %s", err)
        }
   }
   
   // Say is a demo to show how to return data directly instead of proxying
   // it to the upstream.
   type Say struct {
        // Embed the default plugin here,
        // so that we don't need to reimplement all the methods.
        plugin.DefaultPlugin
   }
   
   type SayConf struct {
        Body string `json:"body"`
   }
   
   func (p *Say) Name() string {
        return "say"
   }
   
   func (p *Say) ParseConf(in []byte) (interface{}, error) {
        conf := SayConf{}
        err := json.Unmarshal(in, &conf)
        return conf, err
   }
   
   func (p *Say) RequestFilter(conf interface{}, w http.ResponseWriter, r 
pkgHTTP.Request) {
        body := conf.(SayConf).Body
        if len(body) == 0 {
                return
        }
   
        w.Header().Add("X-Resp-A6-Runner", "Go")
        log.Infof("%+v --- %+v ---- %+v", conf, w, r)
   
        _, err := w.Write([]byte(body))
        if err != nil {
                log.Errorf("failed to write: %s", err)
        }
   }
   
   ```
   
   values.yaml
   ```
   extPlugin:
     # -- Enable External Plugins. See [external 
plugin](https://apisix.apache.org/docs/apisix/next/external-plugin/)
     enabled: true
     # -- the command and its arguements to run as a subprocess
     cmd: ["/usr/local/main", "run"]
   ```
   * I can see that my runner is running through `ps -ef`
   * I can see the following output in apisix's log
   ```
   2023/08/23 11:26:29 [warn] 53#53: *92 [lua] init.lua:953: 
2023-08-23T11:26:29.085Z      INFO    plugin/plugin.go:73     register plugin 
say
   2023-08-23T11:26:29.093Z        WARN    server/server.go:192    conf cache 
ttl is 1h12m0s
   2023-08-23T11:26:29.093Z        WARN    server/server.go:200    listening to 
/usr/local/apisix/conf/apisix-1.sock
   , context: ngx.timer
   ```
   * I try to enter the container through `kubectl exec -it` and I can see the 
corresponding socket
   * But I can't see the corresponding `say` plugin in `/plugins/list`
   * And there will be a 400 error code when accessing 
apisix/admin/plugin_configs/say
   * and some other errors
   ```
   2023/08/23 11:26:27 [error] 50#50: *3 [lua] plugin.lua:135: load_plugin(): 
failed to load plugin [say] err: module 'apisix.plugins.say' not found:
           no field package.preload['apisix.plugins.say']
           no file 
'/usr/local/apisix//deps/share/lua/5.1/apisix/plugins/say.lua'
           no file 
'/usr/local/apisix//deps/share/lua/5.1/apisix/plugins/say/init.lua'
           no file '/usr/local/apisix/apisix/plugins/say.lua'
           no file '/usr/local/apisix/apisix/plugins/say/init.lua'
           no file '/usr/local/openresty/site/lualib/apisix/plugins/say.ljbc'
           no file 
'/usr/local/openresty/site/lualib/apisix/plugins/say/init.ljbc'
           no file '/usr/local/openresty/lualib/apisix/plugins/say.ljbc'
           no file '/usr/local/openresty/lualib/apisix/plugins/say/init.ljbc'
           no file '/usr/local/openresty/site/lualib/apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/site/lualib/apisix/plugins/say/init.lua'
           no file '/usr/local/openresty/lualib/apisix/plugins/say.lua'
           no file '/usr/local/openresty/lualib/apisix/plugins/say/init.lua'
           no file './apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say/init.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say/init.lua'
           no file '/usr/local/apisix/apisix/plugins/say.lua'
           no file './apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say/init.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say/init.lua'
           no file '/usr/local/openresty/site/lualib/apisix/plugins/say.ljbc'
           no file 
'/usr/local/openresty/site/lualib/apisix/plugins/say/init.ljbc'
           no file '/usr/local/openresty/lualib/apisix/plugins/say.ljbc'
           no file '/usr/local/openresty/lualib/apisix/plugins/say/init.ljbc'
           no file '/usr/local/openresty/site/lualib/apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/site/lualib/apisix/plugins/say/init.lua'
           no file '/usr/local/openresty/lualib/apisix/plugins/say.lua'
           no file '/usr/local/openresty/lualib/apisix/plugins/say/init.lua'
           no file './apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say.lua'
           no file '/usr/local/share/lua/5.1/apisix/plugins/say/init.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say.lua'
           no file 
'/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/say/init.lua'
           no file '/usr/local/apisix//deps/lib64/lua/5.1/apisix/plugins/say.so'
           no file '/usr/local/apisix//deps/lib/lua/5.1/apisix/plugins/say.so'
           no file '/usr/local/openresty/site/lualib/apisix/plugins/say.so'
           no file '/usr/local/openresty/lualib/apisix/plugins/say.so'
           no file './apisix/plugins/say.so'
           no file '/usr/local/lib/lua/5.1/apisix/plugins/say.so'
           no file 
'/usr/local/openresty/luajit/lib/lua/5.1/apisix/plugins/say.so'
           no file '/usr/local/lib/lua/5.1/loadall.so'
           no file './apisix/plugins/say.so'
           no file '/usr/local/lib/lua/5.1/apisix/plugins/say.so'
           no file 
'/usr/local/openresty/luajit/lib/lua/5.1/apisix/plugins/say.so'
           no file '/usr/local/lib/lua/5.1/loadall.so'
           no file '/usr/local/apisix//deps/lib64/lua/5.1/apisix.so'
           no file '/usr/local/apisix//deps/lib/lua/5.1/apisix.so'
   ```
   
   
   
   ### Environment
   
   - APISIX version 3.2.0
   - Plugin runner version : 0.5
   - I am running on k8s version 1.25 through the chart package
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to