bcgov / gwa-kong-endpoint

GWA (DataBC Gateway Administration Interface, plugin for Kong)
Other
1 stars 0 forks source link

error when using kong 0.14.1 #6

Closed ll911 closed 5 years ago

ll911 commented 6 years ago

getting following error with latest luarocks when running kong migrations up

018/08/27 22:27:09 [info] migrating bcgov-gwa-endpoint for database kong
Error:
.../kong/plugins/bcgov-gwa-endpoint/migrations/postgres.lua:26: attempt to index field 'acls' (a nil value)
stack traceback:
        .../kong/plugins/bcgov-gwa-endpoint/migrations/postgres.lua:26: in function 'up'
        /usr/local/share/lua/5.1/kong/dao/factory.lua:416: in function 'migrate'
        /usr/local/share/lua/5.1/kong/dao/factory.lua:534: in function 'run_migrations'
        /usr/local/share/lua/5.1/kong/cmd/migrations.lua:37: in function 'cmd_exec'
        /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:87>
        [C]: in function 'xpcall'
        /usr/local/share/lua/5.1/kong/cmd/init.lua:87: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:44>
        /usr/local/bin/kong:7: in function 'file_gen'
        init_worker_by_lua:48: in function <init_worker_by_lua:46>
        [C]: in function 'xpcall'
        init_worker_by_lua:55: in function <init_worker_by_lua:53>
pauldaustin commented 6 years ago

Updated the migrations file to work with 0.14.1. The migrations have a new name, so they will be forced to run. It doesn't matter that the old migrations failed.

Deployed 1.3.1-0 to luarocks

ll911 commented 6 years ago

kong migrations up success adding plugin to service/route success just realize success for none gwa managed nodes, getting following on gwa managed nodes

2018/09/24 09:44:19 [info] migrating bcgov-gwa-endpoint for keyspace kong
Error:
...kong/plugins/bcgov-gwa-endpoint/migrations/cassandra.lua:24: attempt to index global 'app_helpers' (a nil value)
stack traceback:
    ...kong/plugins/bcgov-gwa-endpoint/migrations/cassandra.lua:24: in function 'up'
    ...kong/openresty/luajit/share/lua/5.1/kong/dao/factory.lua:416: in function 'migrate'
    ...kong/openresty/luajit/share/lua/5.1/kong/dao/factory.lua:534: in function 'run_migrations'
    ...g/openresty/luajit/share/lua/5.1/kong/cmd/migrations.lua:37: in function 'cmd_exec'
    /apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87: in function </apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87>
    [C]: in function 'xpcall'
    /apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87: in function </apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:44>
    /apps/kong/bin/kong:7: in function 'file_gen'
    init_worker_by_lua:50: in function <init_worker_by_lua:48>
    [C]: in function 'xpcall'
    init_worker_by_lua:57: in function <init_worker_by_lua:55>
ll911 commented 6 years ago

gwa 1.2.3-1 admin app still works for kong-0.14.1, however, all gwa created endpoint has groups/acl enabled getting 403 error, e.g. https://applogs-d.apps.gov.bc.ca/int/cpf/

pauldaustin commented 6 years ago

I just confirmed by default when you create an API it didn't enable the acls plugin. If you enabled the acls plugin then you have to make sure there is a group that the user is a member of.

The gwa plugin should auto add an acl for a user using the 'sm_authdirname' header set by the reverse proxy. For example the group idir is created for all internal users.

FYI it would be helpful if you included the full kong configuration of the api and the associated plugins in the error reports.

ll911 commented 6 years ago

conf file sent your email

pauldaustin commented 6 years ago

The config of the api and plugin, not the kong.conf.

For example result of

curl http://localhost:8001/apis/mytest/ curl http://localhost:8001/apis/mytest/plugins/

ll911 commented 6 years ago

added, same location to get the both json

pauldaustin commented 6 years ago

Any chance you can dump the headers that are being sent from the reverse proxy to kong for that request?

pauldaustin commented 6 years ago

Just a heads up the Kong API is completely unstable, is under a re-organization and isn't fully documented.

This means what works in one release isn't likely to work in the next until they stabilize at 1.0.0.

I'll have a look at it again tomorrow and see if I can figure out how to get it to work again.

ll911 commented 6 years ago

K, btw, here is the test url you can check headers https://test.apps.gov.bc.ca/ext/httpbin/headers

pauldaustin commented 6 years ago

I have release 1.3.2-0 of the gwa-kong-endpoint plugin.

This version is only valid with Kong 0.14.1.

As the Kong API is still pre 1.0.0 it seems to change every release. Don't upgrade to a new release without fully testing.

pauldaustin commented 6 years ago

Actually 1.3.2-1 the other version still had a log statement on every request

pauldaustin commented 6 years ago

Try 1.3.2-2

Again this is due to the unstable pre-release kong API's constantly changing

ll911 commented 6 years ago

same error

luarocks remove gwa-kong-endpoint
Checking stability of dependencies in the absence of
gwa-kong-endpoint 1.2.3-2...

Removing gwa-kong-endpoint 1.2.3-2...

luarocks install gwa-kong-endpoint 1.3.2-2
Installing https://luarocks.org/gwa-kong-endpoint-1.3.2-2.src.rock
gwa-kong-endpoint 1.3.2-2 is now installed in /apps/kong/openresty/luajit (license: Apache-2.0)

kong migrations up -c kong.conf --vv
Error:
...kong/plugins/bcgov-gwa-endpoint/migrations/cassandra.lua:24: attempt to index global 'app_helpers' (a nil value)
stack traceback:
    ...kong/plugins/bcgov-gwa-endpoint/migrations/cassandra.lua:24: in function 'up'
    ...kong/openresty/luajit/share/lua/5.1/kong/dao/factory.lua:416: in function 'migrate'
    ...kong/openresty/luajit/share/lua/5.1/kong/dao/factory.lua:534: in function 'run_migrations'
    ...g/openresty/luajit/share/lua/5.1/kong/cmd/migrations.lua:37: in function 'cmd_exec'
    /apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87: in function </apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87>
    [C]: in function 'xpcall'
    /apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:87: in function </apps/kong/openresty/luajit/share/lua/5.1/kong/cmd/init.lua:44>
    /apps/kong/bin/kong:7: in function 'file_gen'
    init_worker_by_lua:50: in function <init_worker_by_lua:48>
    [C]: in function 'xpcall'
    init_worker_by_lua:57: in function <init_worker_by_lua:55>
pauldaustin commented 6 years ago

Deployed new version.

I keep getting caught out by not merging a pull request. Slightly different workflow from other projects where my repository is the master.

ll911 commented 6 years ago

1.3.2-3 install success