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

0.9.0 conf does not seem to recognize pg_host #1543

Closed
plukevdh opened this issue Aug 24, 2016 · 13 comments
Closed

0.9.0 conf does not seem to recognize pg_host #1543

plukevdh opened this issue Aug 24, 2016 · 13 comments

Comments

@plukevdh
Copy link
Contributor

Summary

Trying to start a new Kong instance with a PG backend on 0.9.0 with the following conf file (all commented lines removed:

database = postgres             # Determines which of PostgreSQL or Cassandra
                                 # this node will use as its datastore.
                                 # Accepted values are `postgres` and
                                 # `cassandra`.

pg_host = db                   # The PostgreSQL host to connect to.
pg_port = 5432                  # The port to connect to.
pg_user = postgres                  # The username to authenticate if required.
#pg_password = kong              # The password to authenticate if required.
pg_database = postgres              # The database name to connect to.

pg_ssl = off                    # Toggles client-server TLS connections
                                 # between Kong and PostgreSQL.

Starting up with the -vv flag shows the following:

# ...
app_1  | 2016/08/24 19:05:09 [debug] pg_database = "postgres"
app_1  | 2016/08/24 19:05:09 [debug] pg_host = "kong-database"
app_1  | 2016/08/24 19:05:09 [debug] pg_ssl = false
app_1  | 2016/08/24 19:05:09 [debug] pg_ssl_verify = false
app_1  | 2016/08/24 19:05:09 [debug] pg_user = "postgres"
app_1  | 2016/08/24 19:05:09 [debug] prefix = "/usr/local/kong/"
#...

Steps To Reproduce

Reusable repo exhibiting this behavior can be found here

Additional Details & Logs

  • Kong version 0.9.0
  • Kong configuration (see above)
  • Kong error logs
app_1            | Error:
app_1            | /usr/local/share/lua/5.1/kong/cmd/start.lua:15: connection refused
app_1            | stack traceback:
app_1            |      [C]: in function 'assert'
app_1            |      /usr/local/share/lua/5.1/kong/cmd/start.lua:15: in function 'cmd_exec'
app_1            |      /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:81>
app_1            |      [C]: in function 'xpcall'
app_1            |      /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:42>
app_1            |      /usr/local/bin/kong:11: in function 'file_gen'
app_1            |      init_worker_by_lua:40: in function <init_worker_by_lua:38>
app_1            |      [C]: in function 'pcall'
app_1            |      init_worker_by_lua:47: in function <init_worker_by_lua:45>
  • Operating System: Docker/Linux
@thibaultcha
Copy link
Member

Could you provide the full debug output?

@thibaultcha
Copy link
Member

"kong-database" is not a value inserted by Kong's defaults so this value could come from some other configuration file or environment variable in your system.

@subnetmarco
Copy link
Member

@plukevdh if you are using Docker, please set the PG_HOST an ENV variable, ie:

docker run ... -e "KONG_PG_HOST=1.1.1.1"

@plukevdh
Copy link
Contributor Author

@thefosk Why does it not retrieve it from the config?

@thibaultcha full dump looks like this repeating:

app_1  | Error:
app_1  | /usr/local/share/lua/5.1/kong/cmd/start.lua:15: host or service not provided, or not known
app_1  | stack traceback:
app_1  |        [C]: in function 'assert'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/start.lua:15: in function 'cmd_exec'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:81>
app_1  |        [C]: in function 'xpcall'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:42>
app_1  |        /usr/local/bin/kong:11: in function 'file_gen'
app_1  |        init_worker_by_lua:40: in function <init_worker_by_lua:38>
app_1  |        [C]: in function 'pcall'
app_1  |        init_worker_by_lua:47: in function <init_worker_by_lua:45>
app_1  | 2016/08/24 20:41:41 [verbose] no config file found at /etc/kong.conf
app_1  | 2016/08/24 20:41:41 [verbose] reading config file at /etc/kong/kong.conf
app_1  | 2016/08/24 20:41:41 [debug] KONG_CASSANDRA_CONTACT_POINTS ENV found with "kong-database"
app_1  | 2016/08/24 20:41:41 [debug] KONG_PG_HOST ENV found with "kong-database"
app_1  | 2016/08/24 20:41:41 [debug] KONG_NGINX_DAEMON ENV found with "off"
app_1  | 2016/08/24 20:41:41 [debug] admin_listen = "0.0.0.0:8001"
app_1  | 2016/08/24 20:41:41 [debug] anonymous_reports = true
app_1  | 2016/08/24 20:41:41 [debug] cassandra_consistency = "ONE"
app_1  | 2016/08/24 20:41:41 [debug] cassandra_contact_points = {"kong-database"}
app_1  | 2016/08/24 20:41:41 [debug] cassandra_data_centers = {"dc1:2","dc2:3"}
app_1  | 2016/08/24 20:41:41 [debug] cassandra_keyspace = "kong"
app_1  | 2016/08/24 20:41:41 [debug] cassandra_port = 9042
app_1  | 2016/08/24 20:41:41 [debug] cassandra_repl_factor = 1
app_1  | 2016/08/24 20:41:41 [debug] cassandra_repl_strategy = "SimpleStrategy"
app_1  | 2016/08/24 20:41:41 [debug] cassandra_ssl = false
app_1  | 2016/08/24 20:41:41 [debug] cassandra_ssl_verify = false
app_1  | 2016/08/24 20:41:41 [debug] cassandra_timeout = 5000
app_1  | 2016/08/24 20:41:41 [debug] cassandra_username = "kong"
app_1  | 2016/08/24 20:41:41 [debug] cluster_listen = "0.0.0.0:7946"
app_1  | 2016/08/24 20:41:41 [debug] cluster_listen_rpc = "127.0.0.1:7373"
app_1  | 2016/08/24 20:41:41 [debug] cluster_profile = "wan"
app_1  | 2016/08/24 20:41:41 [debug] cluster_ttl_on_failure = 3600
app_1  | 2016/08/24 20:41:41 [debug] custom_plugins = {}
app_1  | 2016/08/24 20:41:41 [debug] database = "postgres"
app_1  | 2016/08/24 20:41:41 [debug] dnsmasq = true
app_1  | 2016/08/24 20:41:41 [debug] dnsmasq_port = 8053
app_1  | 2016/08/24 20:41:41 [debug] log_level = "notice"
app_1  | 2016/08/24 20:41:41 [debug] lua_code_cache = "on"
app_1  | 2016/08/24 20:41:41 [debug] lua_package_cpath = ""
app_1  | 2016/08/24 20:41:41 [debug] lua_package_path = "?/init.lua;./kong/?.lua"
app_1  | 2016/08/24 20:41:41 [debug] lua_ssl_verify_depth = 1
app_1  | 2016/08/24 20:41:41 [debug] mem_cache_size = "128m"
app_1  | 2016/08/24 20:41:41 [debug] nginx_daemon = "off"
app_1  | 2016/08/24 20:41:41 [debug] nginx_optimizations = true
app_1  | 2016/08/24 20:41:41 [debug] nginx_worker_processes = "auto"
app_1  | 2016/08/24 20:41:41 [debug] pg_database = "postgres"
app_1  | 2016/08/24 20:41:41 [debug] pg_host = "kong-database"
app_1  | 2016/08/24 20:41:41 [debug] pg_ssl = false
app_1  | 2016/08/24 20:41:41 [debug] pg_ssl_verify = false
app_1  | 2016/08/24 20:41:41 [debug] pg_user = "postgres"
app_1  | 2016/08/24 20:41:41 [debug] prefix = "/usr/local/kong/"
app_1  | 2016/08/24 20:41:41 [debug] proxy_listen = "0.0.0.0:8000"
app_1  | 2016/08/24 20:41:41 [debug] proxy_listen_ssl = "0.0.0.0:8443"
app_1  | 2016/08/24 20:41:41 [debug] serf_path = "serf"
app_1  | 2016/08/24 20:41:41 [debug] ssl = true
app_1  | 2016/08/24 20:41:41 [verbose] prefix in use: /usr/local/kong
app_1  | 2016/08/24 20:41:41 [verbose] running datastore migrations
app_1  | Error:
app_1  | /usr/local/share/lua/5.1/kong/cmd/start.lua:15: host or service not provided, or not known
app_1  | stack traceback:
app_1  |        [C]: in function 'assert'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/start.lua:15: in function 'cmd_exec'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:81>
app_1  |        [C]: in function 'xpcall'
app_1  |        /usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:42>
app_1  |        /usr/local/bin/kong:11: in function 'file_gen'
app_1  |        init_worker_by_lua:40: in function <init_worker_by_lua:38>
app_1  |        [C]: in function 'pcall'
app_1  |        init_worker_by_lua:47: in function <init_worker_by_lua:45>
kongfail_app_1 exited with code 1

@plukevdh
Copy link
Contributor Author

Ah, may be this:

app_1  | 2016/08/24 20:41:41 [debug] KONG_CASSANDRA_CONTACT_POINTS ENV found with "kong-database"
app_1  | 2016/08/24 20:41:41 [debug] KONG_PG_HOST ENV found with "kong-database"
app_1  | 2016/08/24 20:41:41 [debug] KONG_NGINX_DAEMON ENV found with "off"

Are these defaults built into the mashape/kong:0.9.0 image?

@plukevdh
Copy link
Contributor Author

@plukevdh
Copy link
Contributor Author

Seems like a bad idea to set those as defaults and ignore the config if set... Is this documented anywhere?

@thibaultcha
Copy link
Member

thibaultcha commented Aug 24, 2016

Environment variables do override the configuration file's properties (yes, this is documented pretty much everywhere). I had no idea the docker image was setting those defaults. It probably shouldn't, and only propose a configuration file, and let users override some settings with their own environment variables instead.

@plukevdh
Copy link
Contributor Author

That makes sense. Would be nice if these defaults were dropped. Do you want me to close this issue or leave open for action regarding the unexpected defaults from the image?

@subnetmarco
Copy link
Member

subnetmarco commented Aug 24, 2016

The Docker image for 0.9 allows to override those values by specifying your own KONG_PG_HOST or KONG_CASSANDRA_CONTACT_POINTS variables. The reasoning was that by default it expects a datastore at kong-database (to keep the default installation instructions working), which can be overwritten by specifying a different ENV variable with the same name.

@thibaultcha
Copy link
Member

A better behavior maybe would be to still provide those default values but in a config file. This way, if someone specifies its own file, those values are not overridden by "invisible" environment variables.

@subnetmarco
Copy link
Member

I have updated the 0.9 image to now set those values by default @thibaultcha @plukevdh

You need to pull the image again.

@plukevdh
Copy link
Contributor Author

🤘 thanks much

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

No branches or pull requests

3 participants