Kong / go-pdk

Write Kong plugins in Go! 🦍
https://pkg.go.dev/github.com/Kong/go-pdk
Apache License 2.0
151 stars 49 forks source link

Config loading #28

Closed r3dsm0k3 closed 4 years ago

r3dsm0k3 commented 4 years ago

Im trying to write a config schema which looks like this

type Config struct {
  ApiEndPoint    string
  AuthModules    []Module
}

type Module struct {
  Name   string  
  Routes []string
}

and trying to load the configuration from a declarative config file.

config: 
    apiendpoint: "http://localhost:5050/api/v1/permission/validate"
    authmodules: 
       - 
         name: application_mgmt
         routes: 
           - /api/v1/random

This configuration is resulting in an error

docker-compose up                                                                                                   ✔  17:19:32
Recreating plugin_kong-demo_1 ... done
Attaching to plugin_kong-demo_1
kong-demo_1  | 2020/03/23 16:19:35 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:431: error parsing declarative config file /home/kong/config.yml:
kong-demo_1  | in 'services':
kong-demo_1  |   - in entry 1 of 'services':
kong-demo_1  |     in 'plugins':
kong-demo_1  |       - in entry 1 of 'plugins':
kong-demo_1  |         in 'config':
kong-demo_1  |           in 'authmodules': unknown field

I made sure the yaml is valid so there's no issue there. I'm able to parse the other fields though.

Can anyone help me explain what am I doing wrong here or if it is a bug in the go-pdk itself?

At this point I'm stuck and any help would be appreciated. Thanks

r3dsm0k3 commented 4 years ago

This PR on the go plugin server should fix the it, hopefully.

gszr commented 4 years ago

Hey @r3dsm0k3 - the PR you linked above has been merged; thanks for reporting. I'm closing this for now, but feel free to reopen or create a new issue.

gszr commented 4 years ago

A new version of the pluginserver will be tagged shortly!

westwin commented 4 years ago

I'm still suffering this issue. I'm pretty sure the go-pluginserver I'm using has the fix.

type Config struct { Test []string json:"test" }

kong.yml config: test:

But kong(alpine latest version) reports another error: elements = { type = "expected a string" } } } }) stack traceback: [C]: in function 'assert' /usr/local/share/lua/5.1/kong/init.lua:427: in function 'init' init_by_lua:3: in main chunk

SkippyZA commented 4 years ago

I am having the same issue.

type Config struct {
  Claims []string
}

Logs from the wait-for-db container:

init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'jwt-claim-headers': [postgres] schema violation (fields.1: {
  fields = {                                                        
    {                                                                
      elements = {                                                    
        type = "expected a string"                                     
      }                                                                 
    }                                                                    
  }                                                                       
})                                                                         
stack traceback:                                                            
    [C]: in function 'assert'                                                
    /usr/local/share/lua/5.1/kong/init.lua:427: in function 'init'            
    init_by_lua:3: in main chunk
  Run with --v (verbose) or --vv (debug) for more details
waiting for db

Here are some verbose debug logs:

DEBUG LOGS ```sh 2020/06/15 20:32:21 [verbose] Kong: 2.0.4 2020/06/15 20:32:21 [debug] ngx_lua: 10015 2020/06/15 20:32:21 [debug] nginx: 1015008 2020/06/15 20:32:21 [debug] Lua: LuaJIT 2.1.0-beta3 2020/06/15 20:32:21 [verbose] no config file found at /etc/kong/kong.conf 2020/06/15 20:32:21 [verbose] no config file found at /etc/kong.conf 2020/06/15 20:32:21 [verbose] no config file, skip loading 2020/06/15 20:32:21 [debug] reading environment variables 2020/06/15 20:32:21 [debug] KONG_PLUGINS ENV found with "bundled,jwt-claim-headers" 2020/06/15 20:32:21 [debug] KONG_NGINX_PROXY_PROXY_BUFFER_SIZE ENV found with "128k" 2020/06/15 20:32:21 [debug] KONG_ADMIN_LISTEN ENV found with "0.0.0.0:8001" 2020/06/15 20:32:21 [debug] KONG_PG_HOST ENV found with "pgsql-postgresql.default" 2020/06/15 20:32:21 [debug] KONG_PROXY_LISTEN ENV found with "0.0.0.0:8000" 2020/06/15 20:32:21 [debug] KONG_GO_PLUGINS_DIR ENV found with "/usr/local/kong/" 2020/06/15 20:32:21 [debug] KONG_NGINX_PROXY_PROXY_BUFFERS ENV found with "4 256k" 2020/06/15 20:32:21 [debug] KONG_STREAM_LISTEN ENV found with "off" 2020/06/15 20:32:21 [debug] KONG_STATUS_LISTEN ENV found with "0.0.0.0:8100" 2020/06/15 20:32:21 [debug] KONG_DATABASE ENV found with "postgres" 2020/06/15 20:32:21 [debug] KONG_NGINX_WORKER_PROCESSES ENV found with "1" 2020/06/15 20:32:21 [debug] KONG_LOG_LEVEL ENV found with "debug" 2020/06/15 20:32:21 [debug] KONG_ADMIN_ACCESS_LOG ENV found with "/dev/stdout" 2020/06/15 20:32:21 [debug] KONG_PG_USER ENV found with "postgres" 2020/06/15 20:32:21 [debug] KONG_LUA_PACKAGE_PATH ENV found with "/opt/?.lua;/opt/?/init.lua;;" 2020/06/15 20:32:21 [debug] KONG_NGINX_PROXY_PROXY_BUSY_BUFFERS_SIZE ENV found with "256k" 2020/06/15 20:32:21 [debug] KONG_NGINX_HTTP_INCLUDE ENV found with "/kong/servers.conf" 2020/06/15 20:32:21 [debug] KONG_PROXY_ERROR_LOG ENV found with "/dev/stderr" 2020/06/15 20:32:21 [debug] KONG_PG_PASSWORD ENV found with "******" 2020/06/15 20:32:21 [debug] KONG_ADMIN_ERROR_LOG ENV found with "/dev/stderr" 2020/06/15 20:32:21 [debug] KONG_PG_PORT ENV found with "5432" 2020/06/15 20:32:21 [debug] KONG_PROXY_ACCESS_LOG ENV found with "/dev/stdout" 2020/06/15 20:32:21 [debug] KONG_PREFIX ENV found with "/kong_prefix/" 2020/06/15 20:32:21 [debug] admin_access_log = "/dev/stdout" 2020/06/15 20:32:21 [debug] admin_error_log = "/dev/stderr" 2020/06/15 20:32:21 [debug] admin_listen = {"0.0.0.0:8001"} 2020/06/15 20:32:21 [debug] anonymous_reports = true 2020/06/15 20:32:21 [debug] cassandra_consistency = "ONE" 2020/06/15 20:32:21 [debug] cassandra_contact_points = {"127.0.0.1"} 2020/06/15 20:32:21 [debug] cassandra_data_centers = {"dc1:2","dc2:3"} 2020/06/15 20:32:21 [debug] cassandra_keyspace = "kong" 2020/06/15 20:32:21 [debug] cassandra_lb_policy = "RequestRoundRobin" 2020/06/15 20:32:21 [debug] cassandra_port = 9042 2020/06/15 20:32:21 [debug] cassandra_refresh_frequency = 60 2020/06/15 20:32:21 [debug] cassandra_repl_factor = 1 2020/06/15 20:32:21 [debug] cassandra_repl_strategy = "SimpleStrategy" 2020/06/15 20:32:21 [debug] cassandra_schema_consensus_timeout = 10000 2020/06/15 20:32:21 [debug] cassandra_ssl = false 2020/06/15 20:32:21 [debug] cassandra_ssl_verify = false 2020/06/15 20:32:21 [debug] cassandra_timeout = 5000 2020/06/15 20:32:21 [debug] cassandra_username = "kong" 2020/06/15 20:32:21 [debug] client_body_buffer_size = "8k" 2020/06/15 20:32:21 [debug] client_max_body_size = "0" 2020/06/15 20:32:21 [debug] client_ssl = false 2020/06/15 20:32:21 [debug] cluster_control_plane = "127.0.0.1:8005" 2020/06/15 20:32:21 [debug] cluster_listen = {"0.0.0.0:8005"} 2020/06/15 20:32:21 [debug] database = "postgres" 2020/06/15 20:32:21 [debug] db_cache_ttl = 0 2020/06/15 20:32:21 [debug] db_cache_warmup_entities = {"services","plugins"} 2020/06/15 20:32:21 [debug] db_resurrect_ttl = 30 2020/06/15 20:32:21 [debug] db_update_frequency = 5 2020/06/15 20:32:21 [debug] db_update_propagation = 0 2020/06/15 20:32:21 [debug] dns_error_ttl = 1 2020/06/15 20:32:21 [debug] dns_hostsfile = "/etc/hosts" 2020/06/15 20:32:21 [debug] dns_no_sync = false 2020/06/15 20:32:21 [debug] dns_not_found_ttl = 30 2020/06/15 20:32:21 [debug] dns_order = {"LAST","SRV","A","CNAME"} 2020/06/15 20:32:21 [debug] dns_resolver = {} 2020/06/15 20:32:21 [debug] dns_stale_ttl = 4 2020/06/15 20:32:21 [debug] error_default_type = "text/plain" 2020/06/15 20:32:21 [debug] go_plugins_dir = "/usr/local/kong/" 2020/06/15 20:32:21 [debug] go_pluginserver_exe = "/usr/local/bin/go-pluginserver" 2020/06/15 20:32:21 [debug] headers = {"server_tokens","latency_tokens"} 2020/06/15 20:32:21 [debug] kic = false 2020/06/15 20:32:21 [debug] log_level = "debug" 2020/06/15 20:32:21 [debug] lua_package_cpath = "" 2020/06/15 20:32:21 [debug] lua_package_path = "/opt/?.lua;/opt/?/init.lua;;" 2020/06/15 20:32:21 [debug] lua_socket_pool_size = 30 2020/06/15 20:32:21 [debug] lua_ssl_verify_depth = 1 2020/06/15 20:32:21 [debug] mem_cache_size = "128m" 2020/06/15 20:32:21 [debug] nginx_admin_directives = {} 2020/06/15 20:32:21 [debug] nginx_daemon = "on" 2020/06/15 20:32:21 [debug] nginx_events_directives = {{name="worker_connections",value="auto"},{name="multi_accept",value="on"}} 2020/06/15 20:32:21 [debug] nginx_events_multi_accept = "on" 2020/06/15 20:32:21 [debug] nginx_events_worker_connections = "auto" 2020/06/15 20:32:21 [debug] nginx_http_client_body_buffer_size = "8k" 2020/06/15 20:32:21 [debug] nginx_http_client_max_body_size = "0" 2020/06/15 20:32:21 [debug] nginx_http_directives = {{name="client_max_body_size",value="0"},{name="ssl_prefer_server_ciphers",value="off"},{name="client_body_buffer_size",value="8k"},{name="include",value="/kong/servers.conf"},{name="ssl_protocols",value="TLSv1.2 TLSv1.3"},{name="ssl_session_tickets",value="on"},{name="ssl_session_timeout",value="1d"}} 2020/06/15 20:32:21 [debug] nginx_http_include = "/kong/servers.conf" 2020/06/15 20:32:21 [debug] nginx_http_ssl_prefer_server_ciphers = "off" 2020/06/15 20:32:21 [debug] nginx_http_ssl_protocols = "TLSv1.2 TLSv1.3" 2020/06/15 20:32:21 [debug] nginx_http_ssl_session_tickets = "on" 2020/06/15 20:32:21 [debug] nginx_http_ssl_session_timeout = "1d" 2020/06/15 20:32:21 [debug] nginx_http_status_directives = {} 2020/06/15 20:32:21 [debug] nginx_http_upstream_directives = {{name="keepalive_timeout",value="60s"},{name="keepalive",value="60"},{name="keepalive_requests",value="100"}} 2020/06/15 20:32:21 [debug] nginx_http_upstream_keepalive = "60" 2020/06/15 20:32:21 [debug] nginx_http_upstream_keepalive_requests = "100" 2020/06/15 20:32:21 [debug] nginx_http_upstream_keepalive_timeout = "60s" 2020/06/15 20:32:21 [debug] nginx_main_daemon = "on" 2020/06/15 20:32:21 [debug] nginx_main_directives = {{name="daemon",value="on"},{name="worker_rlimit_nofile",value="auto"},{name="worker_processes",value="1"}} 2020/06/15 20:32:21 [debug] nginx_main_worker_processes = "1" 2020/06/15 20:32:21 [debug] nginx_main_worker_rlimit_nofile = "auto" 2020/06/15 20:32:21 [debug] nginx_optimizations = true 2020/06/15 20:32:21 [debug] nginx_proxy_directives = {{name="proxy_buffer_size",value="128k"},{name="proxy_buffers",value="4 256k"},{name="proxy_busy_buffers_size",value="256k"},{name="real_ip_recursive",value="off"},{name="real_ip_header",value="X-Real-IP"}} 2020/06/15 20:32:21 [debug] nginx_proxy_proxy_buffer_size = "128k" 2020/06/15 20:32:21 [debug] nginx_proxy_proxy_buffers = "4 256k" 2020/06/15 20:32:21 [debug] nginx_proxy_proxy_busy_buffers_size = "256k" 2020/06/15 20:32:21 [debug] nginx_proxy_real_ip_header = "X-Real-IP" 2020/06/15 20:32:21 [debug] nginx_proxy_real_ip_recursive = "off" 2020/06/15 20:32:21 [debug] nginx_sproxy_directives = {} 2020/06/15 20:32:21 [debug] nginx_status_directives = {} 2020/06/15 20:32:21 [debug] nginx_stream_directives = {} 2020/06/15 20:32:21 [debug] nginx_supstream_directives = {} 2020/06/15 20:32:21 [debug] nginx_upstream_directives = {{name="keepalive_timeout",value="60s"},{name="keepalive",value="60"},{name="keepalive_requests",value="100"}} 2020/06/15 20:32:21 [debug] nginx_upstream_keepalive = "60" 2020/06/15 20:32:21 [debug] nginx_upstream_keepalive_requests = "100" 2020/06/15 20:32:21 [debug] nginx_upstream_keepalive_timeout = "60s" 2020/06/15 20:32:21 [debug] nginx_worker_processes = "1" 2020/06/15 20:32:21 [debug] pg_database = "kong" 2020/06/15 20:32:21 [debug] pg_host = "pgsql-postgresql.default" 2020/06/15 20:32:21 [debug] pg_max_concurrent_queries = 0 2020/06/15 20:32:21 [debug] pg_password = "******" 2020/06/15 20:32:21 [debug] pg_port = 5432 2020/06/15 20:32:21 [debug] pg_semaphore_timeout = 60000 2020/06/15 20:32:21 [debug] pg_ssl = false 2020/06/15 20:32:21 [debug] pg_ssl_verify = false 2020/06/15 20:32:21 [debug] pg_timeout = 5000 2020/06/15 20:32:21 [debug] pg_user = "postgres" 2020/06/15 20:32:21 [debug] plugins = {"bundled","jwt-claim-headers"} 2020/06/15 20:32:21 [debug] prefix = "/kong_prefix/" 2020/06/15 20:32:21 [debug] proxy_access_log = "/dev/stdout" 2020/06/15 20:32:21 [debug] proxy_error_log = "/dev/stderr" 2020/06/15 20:32:21 [debug] proxy_listen = {"0.0.0.0:8000"} 2020/06/15 20:32:21 [debug] real_ip_header = "X-Real-IP" 2020/06/15 20:32:21 [debug] real_ip_recursive = "off" 2020/06/15 20:32:21 [debug] role = "traditional" 2020/06/15 20:32:21 [debug] router_consistency = "strict" 2020/06/15 20:32:21 [debug] router_update_frequency = 1 2020/06/15 20:32:21 [debug] ssl_cipher_suite = "intermediate" 2020/06/15 20:32:21 [debug] ssl_ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" 2020/06/15 20:32:21 [debug] status_access_log = "off" 2020/06/15 20:32:21 [debug] status_error_log = "logs/status_error.log" 2020/06/15 20:32:21 [debug] status_listen = {"0.0.0.0:8100"} 2020/06/15 20:32:21 [debug] stream_listen = {"off"} 2020/06/15 20:32:21 [debug] trusted_ips = {} 2020/06/15 20:32:21 [debug] upstream_keepalive = 60 2020/06/15 20:32:21 [verbose] prefix in use: /kong_prefix 2020/06/15 20:32:21 [debug] sending signal to pid at: /kong_prefix/pids/nginx.pid 2020/06/15 20:32:21 [debug] kill -0 `cat /kong_prefix/pids/nginx.pid` >/dev/null 2>&1 2020/06/15 20:32:21 [debug] loading subsystems migrations... 2020/06/15 20:32:21 [verbose] retrieving database schema state... 2020/06/15 20:32:21 [verbose] schema state retrieved 2020/06/15 20:32:21 [verbose] preparing nginx prefix directory at /kong_prefix 2020/06/15 20:32:21 [debug] searching for OpenResty 'nginx' executable 2020/06/15 20:32:21 [debug] /usr/local/openresty/nginx/sbin/nginx -v: 'nginx version: openresty/1.15.8.3' 2020/06/15 20:32:21 [debug] found OpenResty 'nginx' executable at /usr/local/openresty/nginx/sbin/nginx 2020/06/15 20:32:21 [debug] testing nginx configuration: KONG_NGINX_CONF_CHECK=true /usr/local/openresty/nginx/sbin/nginx -t -p /kong_prefix -c nginx.conf 2020/06/15 20:32:21 [debug] searching for OpenResty 'nginx' executable 2020/06/15 20:32:21 [debug] /usr/local/openresty/nginx/sbin/nginx -v: 'nginx version: openresty/1.15.8.3' 2020/06/15 20:32:21 [debug] found OpenResty 'nginx' executable at /usr/local/openresty/nginx/sbin/nginx 2020/06/15 20:32:21 [debug] sending signal to pid at: /kong_prefix/pids/nginx.pid 2020/06/15 20:32:21 [debug] kill -0 `cat /kong_prefix/pids/nginx.pid` >/dev/null 2>&1 2020/06/15 20:32:21 [debug] starting nginx: /usr/local/openresty/nginx/sbin/nginx -p /kong_prefix -c nginx.conf 2020/06/15 20:32:21 [verbose] could not start Kong, stopping services 2020/06/15 20:32:21 [debug] sending signal to pid at: /kong_prefix/pids/nginx.pid 2020/06/15 20:32:21 [debug] kill -0 `cat /kong_prefix/pids/nginx.pid` >/dev/null 2>&1 2020/06/15 20:32:21 [verbose] stopped services Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:75: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'jwt-claim-headers': [postgres] schema violation (fields.1: { fields = { { elements = { type = "expected a string" } } } }) stack traceback: [C]: in function 'assert' /usr/local/share/lua/5.1/kong/init.lua:427: in function 'init' init_by_lua:3: in main chunk re)configuring dns client 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:454: init(): [dns-client] staleTtl = 4 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:457: init(): [dns-client] validTtl = nil 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:461: init(): [dns-client] noSynchronisation = false 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:480: init(): [dns-client] query order = LAST, SRV, A, CNAME 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:520: init(): [dns-client] adding A-record from 'hosts' file: api-gateway-kong-64fc5cdfd8-tlxg2 = 172.17.0.10 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-mcastprefix = [fe00::0] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-localnet = [fe00::0] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:520: init(): [dns-client] adding A-record from 'hosts' file: localhost = 127.0.0.1 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: localhost = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-localhost = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-loopback = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-allnodes = [fe00::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-allrouters = [fe00::2] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:579: init(): [dns-client] nameserver 10.96.0.10 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:584: init(): [dns-client] attempts = 5 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:593: init(): [dns-client] timeout = 2000 ms 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:597: init(): [dns-client] ndots = 5 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:599: init(): [dns-client] search = default.svc.cluster.local, svc.cluster.local, cluster.local 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:605: init(): [dns-client] badTtl = 1 s 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:607: init(): [dns-client] emptyTtl = 30 s 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:125: check_db_against_config(): Discovering used plugins 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:449: init(): [dns-client] (re)configuring dns client 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:454: init(): [dns-client] staleTtl = 4 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:457: init(): [dns-client] validTtl = nil 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:461: init(): [dns-client] noSynchronisation = false 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:480: init(): [dns-client] query order = LAST, SRV, A, CNAME 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:520: init(): [dns-client] adding A-record from 'hosts' file: api-gateway-kong-64fc5cdfd8-tlxg2 = 172.17.0.10 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-mcastprefix = [fe00::0] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-localnet = [fe00::0] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:520: init(): [dns-client] adding A-record from 'hosts' file: localhost = 127.0.0.1 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: localhost = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-localhost = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-loopback = [::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-allnodes = [fe00::1] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:535: init(): [dns-client] adding AAAA-record from 'hosts' file: ip6-allrouters = [fe00::2] 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:579: init(): [dns-client] nameserver 10.96.0.10 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:584: init(): [dns-client] attempts = 5 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:593: init(): [dns-client] timeout = 2000 ms 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:597: init(): [dns-client] ndots = 5 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:599: init(): [dns-client] search = default.svc.cluster.local, svc.cluster.local, cluster.local 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:605: init(): [dns-client] badTtl = 1 s 2020/06/15 20:32:21 [debug] 9374#0: [lua] client.lua:607: init(): [dns-client] emptyTtl = 30 s 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: correlation-id 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: pre-function 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: cors 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: ldap-auth 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: loggly 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: hmac-auth 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'hmac-auth.hmacauth_credentials' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: zipkin 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: request-size-limiting 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: azure-functions 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: request-transformer 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: oauth2 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'oauth2.oauth2_credentials' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'oauth2.oauth2_authorization_codes' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'oauth2.oauth2_tokens' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: response-transformer 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: ip-restriction 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: statsd 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: jwt 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'jwt.jwt_secrets' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: proxy-cache 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: basic-auth 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'basic-auth.basicauth_credentials' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: key-auth 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'key-auth.keyauth_credentials' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: http-log 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: datadog 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: tcp-log 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: rate-limiting 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: post-function 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: prometheus 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: acl 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'acl.acls' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: syslog 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: file-log 2020/06/15 20:32:21 [info] 9374#0: [lua] openssl.lua:5: using ffi, OpenSSL version linked: 1010106f 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: acme 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'acme.acme_storage' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: udp-log 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: response-ratelimiting 2020/06/15 20:32:21 [debug] 9374#0: [kong] iam-ecs-credentials.lua:31 No ECS environment variables found for IAM 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: aws-lambda 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: session 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:209: loader_fn(): Loading custom plugin entity: 'session.sessions' 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: bot-detection 2020/06/15 20:32:21 [debug] 9374#0: [lua] plugins.lua:247: load_plugin(): Loading plugin: request-termination 2020/06/15 20:32:21 [error] 9374#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'jwt-claim-headers': [postgres] schema violation (fields.1: { fields = { { elements = { type = "expected a string" } } } }) stack traceback: [C]: in function 'assert' /usr/local/share/lua/5.1/kong/init.lua:427: in function 'init' init_by_lua:3: in main chunk stack traceback: [C]: in function 'error' /usr/local/share/lua/5.1/kong/cmd/start.lua:75: in function 'cmd_exec' /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function [C]: in function 'xpcall' /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function /usr/local/bin/kong:9: in function 'file_gen' init_worker_by_lua:47: in function [C]: in function 'xpcall' init_worker_by_lua:54: in function ```
gszr commented 4 years ago

@westwin @SkippyZA what version of pluginserver are you using? Could you Retry with the latest version available and report back?

SkippyZA commented 4 years ago

@gszr I am using the latest from master.

Here is my dockerfile I use to build my kong image with plugins:

#####################
## Go plugins
#####################
FROM kong:2.0-ubuntu as compiler

USER root

# Install build tools
RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git

# Download and configure Go compiler
RUN curl -s https://storage.googleapis.com/golang/go1.13.5.linux-amd64.tar.gz | tar -v -C /usr/local -xz
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PATH $PATH:/usr/local/go/bin

# Copy and compile go-plugins

RUN mkdir /tmp/go-plugins
WORKDIR /tmp/go-plugins

COPY plugins/ /tmp/go-plugins/

RUN go get github.com/Kong/go-pluginserver
RUN make deps

RUN make all

#####################
## Release image
#####################
FROM kong:2.0-ubuntu

RUN mkdir -p /usr/local/kong \
    && chown -R kong:0 /usr/local/kong \
    && chmod -R g=u /usr/local/kong

USER kong

# Copy Go files
COPY --chown=kong --from=compiler /tmp/go-plugins/build/*.so /usr/local/kong/
COPY --chown=kong --from=compiler /go/bin/go-pluginserver /usr/local/bin/go-pluginserver
gszr commented 4 years ago

Thanks @SkippyZA. Could you retry with this proposed patch: https://github.com/Kong/go-pluginserver/pull/20

SkippyZA commented 4 years ago

What would be the easiest way to do that @gszr ?

gszr commented 4 years ago

You could, for example, clone the repo rather than doing a go get and do make (the pluginserver repo has a Makefile).

SkippyZA commented 4 years ago

I have it compiled, but now it is failing to start because of a version issue

Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: 2020/06/15 21:06:36 failed to open plugin jwt-claim-headers: plugin.Open("/usr/local/kong/jwt-claim-headers"): plugin was built with a different version of package github.com/Kong/go-pdk/bridge
gszr commented 4 years ago

@SkippyZA make sure to recompile your plugin with the same version of the go-pdk used in that branch - which I just looked and is v0.3.0 (if your plugin has a go mod file, it's just a matter of changing the version number)

SkippyZA commented 4 years ago

Great, got it to compile and the plugin loads and works as expected now.

gszr commented 4 years ago

Thank you so much for verifying, @SkippyZA! I will re-review the fix and get it merged ASAP!

SkippyZA commented 4 years ago

Thanks @gszr