Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_ssl_message receives 6 arguments but only expects 1~5 #1720

Closed
LouisKottmann opened this issue Oct 7, 2016 · 8 comments
Closed

send_ssl_message receives 6 arguments but only expects 1~5 #1720

LouisKottmann opened this issue Oct 7, 2016 · 8 comments
Assignees
Labels
Milestone

Comments

@LouisKottmann
Copy link

LouisKottmann commented Oct 7, 2016

Summary

Running kong from the official docker image generates 2 periodic error in error.log:

Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors: 2016/10/07 15:08:29 [error] 100#0: lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: ngx.socket connect: expecting 1 ~ 5 arguments (including the object), but seen 6
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors: stack traceback:
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors: coroutine 0:
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors:   [C]: in function 'send_ssl_message'
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: in function 'connect'
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:142: in function 'query'
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:285: in function 'clear_expired_ttl'
Oct  7 17:08:30 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:39: in function </usr/local/share/lua/5.1/kong/dao/postgres_db.lua:36>, context: ngx.timer
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors: 2016/10/07 15:08:34 [error] 104#0: lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: ngx.socket connect: expectin
g 1 ~ 5 arguments (including the object), but seen 6
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors: stack traceback:
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors: coroutine 0:
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   [C]: in function 'send_ssl_message'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: in function 'connect'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:142: in function 'query'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:171: in function 'retrieve_primary_key_type'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:189: in function 'get_select_query'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:360: in function 'find_all'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/dao/dao.lua:174: in function 'find_all'
Oct  7 17:08:35 eac60fa9c016 api-preprod-kong-errors:   /usr/local/share/lua/5.1/kong/core/cluster.lua:78: in function </usr/local/share/lua/5.1/kong/core/cluster.lua:69>, context: ngx.timer

It still works though.

Steps To Reproduce

  1. Use the official kong docker image

Additional Details & Logs

  • Kong version: 0.9.2
  • Kong debug-level startup logs
    kong_start.txt
  • Kong error logs (<KONG_PREFIX>/logs/error.log)
    kong_error.txt
  • Kong configuration (registered APIs/Plugins & configuration file): nothing register yet, configuration is done via env vars:
- KONG_SSL: off 
- KONG_DATABASE: postgres
- KONG_PG_SSL: on
- KONG_PG_SSL_VERIFY: off
- KONG_PG_PORT: 5432
- KONG_PG_DATABASE: kong_non_prod
- KONG_PG_HOST: <redacted>
- KONG_PG_USER: kong_non_prod
- KONG_PG_PASSWORD: <redacted>
- KONG_PROXY_LISTEN: 0.0.0.0:5300
- KONG_ADMIN_LISTEN: 0.0.0.0:5301
  • Operating System: CentOS inside docker (your official docker image + some basic packages like cron)
@thibaultcha thibaultcha self-assigned this Oct 9, 2016
@thibaultcha
Copy link
Member

Thanks for the report

@nguilford
Copy link

I also see this error when trying to connect connect to postgres using ssl and the official mashape docker image. However, this also results in 500 errors when making requests to any endpoint in either the admin api or a proxy api. It is accompanied by other errors as well:

        [C]: in function 'resume'
        /usr/local/share/lua/5.1/lapis/application.lua:393: in function 'handler'
        /usr/local/share/lua/5.1/lapis/application.lua:130: in function 'resolve'
        /usr/local/share/lua/5.1/lapis/application.lua:161: in function </usr/local/share/lua/5.1/lapis/application.lua:159>
        [C]: in function 'xpcall'
        /usr/local/share/lua/5.1/lapis/application.lua:159: in function 'dispatch'
        /usr/local/share/lua/5.1/lapis/nginx.lua:214: in function 'serve'
        content_by_lua(nginx-kong.conf:111):10: in function <content_by_lua(nginx-kong.conf:111):1>, client: 10.18.8.12, server: kong_admin, request: "GET /status HTTP/1.0"
2016/10/13 21:15:46 [error] 117#0: *2427 [lua] init.lua:62: handle_error(): /usr/local/share/lua/5.1/lapis/application.lua:396: /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: ngx.socket connect:
 expecting 1 ~ 5 arguments (including the object), but seen 6
stack traceback:
        [C]: in function 'send_ssl_message'
        /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:172: in function 'connect'
        /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:142: in function 'query'
        /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:171: in function 'retrieve_primary_key_type'
        /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:189: in function 'get_select_query'
        /usr/local/share/lua/5.1/kong/dao/postgres_db.lua:398: in function 'count'
        /usr/local/share/lua/5.1/kong/dao/dao.lua:222: in function 'count'
        /usr/local/share/lua/5.1/kong/api/routes/kong.lua:74: in function </usr/local/share/lua/5.1/kong/api/routes/kong.lua:51>

stack traceback:
        [C]: in function 'error'
        /usr/local/share/lua/5.1/lapis/application.lua:396: in function 'handler'
        /usr/local/share/lua/5.1/lapis/application.lua:130: in function 'resolve'
        /usr/local/share/lua/5.1/lapis/application.lua:161: in function </usr/local/share/lua/5.1/lapis/application.lua:159>

Additional Details

  • Kong Database Configuration:
database = postgres
pg_host = <redacted>
pg_port = 5432
pg_user = kongtest
pg_password = <redacted>
pg_database = kongtest
pg_ssl = on
pg_ssl_verify = off
  • Database Info:
    Postgres db version 9.5.2, running in Amazon RDS with rds.force_ssl set to on (also tested with it set to off)

If it looks like my issue is unrelated, let me know and I will file a separate issue.

@thibaultcha
Copy link
Member

Here is the fix for our pgmoon fork: Kong/pgmoon@c16d2d4

I released pgmoon-mashape 2.0.1 which you can install with:

$ luarocks install pgmoon-mashape 2.0.1

This should override the 2.0.0 version installed by Kong.

This fix will also be pushed to leafo/pgmoon.

I believe that ideally, ngx_lua should be updated to discard additional arguments to sslhandshake() (and other tcp/udp socket methods), so that it follows usual Lua idioms and would be a more elegant fix for this.

thibaultcha added a commit that referenced this issue Oct 17, 2016
Resolves Postgres SSL connections error being thrown by ngx_lua

Fix #1720
@thibaultcha thibaultcha added this to the 0.10 RC milestone Oct 18, 2016
@nguilford
Copy link

Fix verified. Thank you!

@thibaultcha
Copy link
Member

Great, thanks for testing it out!

@sheerun
Copy link

sheerun commented Nov 24, 2016

@thibaultcha master branch and 0.9.5 don't include version bump, and because of it postgres with ssl fails. shoudn't it be released as 0.9.6?

@thibaultcha
Copy link
Member

@sheerun Hey, sorry for the delay on our side. I just released 0.9.6:
https://github.com/Mashape/kong/releases/tag/0.9.6

Which takes care of bumping the pgmoon-mashape dependency. This definitely warrants a hotfix. It can already be installed over an existing Kong install via:

$ luarocks install kong 0.9.6

We we be releasing the updated distribution packages by the end of the day.

Thanks again!

@gavinlove
Copy link

Any update on when the distribution packages are going to be released, we have just ran into this problem while moving to postgres.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants