Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/
Apache License 2.0
39.33k stars 4.82k forks source link

Kong docker alpine version fails to reload with nginx not running in prefix error. #2873

Closed Allu2 closed 7 years ago

Allu2 commented 7 years ago

NOTE: GitHub issues are reserved for bug reports only.

Please read the CONTRIBUTING.md guidelines to learn on which channels you can seek for help and ask general questions:

https://github.com/Mashape/kong/blob/master/CONTRIBUTING.md#where-to-seek-for-help

Summary

Using kong's docker version 0.11.0-alpine "kong reload" and other commands in container fail.

Steps To Reproduce

  1. Pull kong 0.11.0-alpine image with docker and create a container
  2. Try run "kong reload" inside container
  3. Expected: Kong should reload
  4. Happened:
/ # kong reload --vv
2017/09/08 10:49:08 [verbose] Kong: 0.11.0
2017/09/08 10:49:08 [debug] ngx_lua: 10008
2017/09/08 10:49:08 [debug] nginx: 1011002
2017/09/08 10:49:08 [debug] Lua: LuaJIT 2.1.0-beta2
2017/09/08 10:49:08 [verbose] reading config file at /usr/local/kong/.kong_env
2017/09/08 10:49:08 [debug] KONG_PREFIX ENV found with "/usr/local/kong"
2017/09/08 10:49:08 [debug] KONG_PG_HOST ENV found with "kong-database"
2017/09/08 10:49:08 [debug] KONG_PROXY_LISTEN ENV found with "0.0.0.0:8000"
2017/09/08 10:49:08 [debug] KONG_DATABASE ENV found with "postgres"
2017/09/08 10:49:08 [debug] KONG_SSL ENV found with "off"
2017/09/08 10:49:08 [debug] KONG_PROXY_LISTEN_SSL ENV found with "0.0.0.0:8443"
2017/09/08 10:49:08 [debug] KONG_NGINX_DAEMON ENV found with "off"
2017/09/08 10:49:08 [debug] KONG_ANONYMOUS_REPORTS ENV found with "off"
2017/09/08 10:49:08 [debug] KONG_LOG_LEVEL ENV found with "notice"
2017/09/08 10:49:08 [debug] admin_access_log = "logs/admin_access.log"
2017/09/08 10:49:08 [debug] admin_error_log = "logs/error.log"
2017/09/08 10:49:08 [debug] admin_http2 = false
2017/09/08 10:49:08 [debug] admin_listen = "0.0.0.0:8001"
2017/09/08 10:49:08 [debug] admin_listen_ssl = "0.0.0.0:8444"
2017/09/08 10:49:08 [debug] admin_ssl = true
2017/09/08 10:49:08 [debug] admin_ssl_cert = "/usr/local/kong/ssl/admin-kong-default.crt"
2017/09/08 10:49:08 [debug] admin_ssl_cert_key = "/usr/local/kong/ssl/admin-kong-default.key"
2017/09/08 10:49:08 [debug] anonymous_reports = false
2017/09/08 10:49:08 [debug] cassandra_consistency = "ONE"
2017/09/08 10:49:08 [debug] cassandra_contact_points = {"127.0.0.1"}
2017/09/08 10:49:08 [debug] cassandra_data_centers = {"dc1:2","dc2:3"}
2017/09/08 10:49:08 [debug] cassandra_keyspace = "kong"
2017/09/08 10:49:08 [debug] cassandra_lb_policy = "RoundRobin"
2017/09/08 10:49:08 [debug] cassandra_port = 9042
2017/09/08 10:49:08 [debug] cassandra_repl_factor = 1
2017/09/08 10:49:08 [debug] cassandra_repl_strategy = "SimpleStrategy"
2017/09/08 10:49:08 [debug] cassandra_schema_consensus_timeout = 10000
2017/09/08 10:49:08 [debug] cassandra_ssl = false
2017/09/08 10:49:08 [debug] cassandra_ssl_verify = false
2017/09/08 10:49:08 [debug] cassandra_timeout = 5000
2017/09/08 10:49:08 [debug] cassandra_username = "kong"
2017/09/08 10:49:08 [debug] client_body_buffer_size = "8k"
2017/09/08 10:49:08 [debug] client_max_body_size = "0"
2017/09/08 10:49:08 [debug] client_ssl = false
2017/09/08 10:49:08 [debug] custom_plugins = {}
2017/09/08 10:49:08 [debug] database = "postgres"
2017/09/08 10:49:08 [debug] db_cache_ttl = 3600
2017/09/08 10:49:08 [debug] db_update_frequency = 5
2017/09/08 10:49:08 [debug] db_update_propagation = 0
2017/09/08 10:49:08 [debug] dns_error_ttl = 1
2017/09/08 10:49:08 [debug] dns_hostsfile = "/etc/hosts"
2017/09/08 10:49:08 [debug] dns_no_sync = false
2017/09/08 10:49:08 [debug] dns_not_found_ttl = 30
2017/09/08 10:49:08 [debug] dns_order = {"LAST","SRV","A","CNAME"}
2017/09/08 10:49:08 [debug] dns_resolver = {}
2017/09/08 10:49:08 [debug] dns_stale_ttl = 4
2017/09/08 10:49:08 [debug] error_default_type = "text/plain"
2017/09/08 10:49:08 [debug] http2 = false
2017/09/08 10:49:08 [debug] latency_tokens = true
2017/09/08 10:49:08 [debug] log_level = "notice"
2017/09/08 10:49:08 [debug] lua_code_cache = "on"
2017/09/08 10:49:08 [debug] lua_package_cpath = ""
2017/09/08 10:49:08 [debug] lua_package_path = "?/init.lua;./kong/?.lua"
2017/09/08 10:49:08 [debug] lua_socket_pool_size = 30
2017/09/08 10:49:08 [debug] lua_ssl_verify_depth = 1
2017/09/08 10:49:08 [debug] mem_cache_size = "128m"
2017/09/08 10:49:08 [debug] nginx_daemon = "off"
2017/09/08 10:49:08 [debug] nginx_optimizations = true
2017/09/08 10:49:08 [debug] nginx_user = "nobody nobody"
2017/09/08 10:49:08 [debug] nginx_worker_processes = "auto"
2017/09/08 10:49:08 [debug] pg_database = "kong"
2017/09/08 10:49:08 [debug] pg_host = "kong-database"
2017/09/08 10:49:08 [debug] pg_port = 5432
2017/09/08 10:49:08 [debug] pg_ssl = false
2017/09/08 10:49:08 [debug] pg_ssl_verify = false
2017/09/08 10:49:08 [debug] pg_user = "kong"
2017/09/08 10:49:08 [debug] prefix = "/usr/local/kong"
2017/09/08 10:49:08 [debug] proxy_access_log = "logs/access.log"
2017/09/08 10:49:08 [debug] proxy_error_log = "logs/error.log"
2017/09/08 10:49:08 [debug] proxy_listen = "0.0.0.0:8000"
2017/09/08 10:49:08 [debug] proxy_listen_ssl = "0.0.0.0:8443"
2017/09/08 10:49:08 [debug] real_ip_header = "X-Real-IP"
2017/09/08 10:49:08 [debug] real_ip_recursive = "off"
2017/09/08 10:49:08 [debug] server_tokens = true
2017/09/08 10:49:08 [debug] ssl = false
2017/09/08 10:49:08 [debug] ssl_cipher_suite = "modern"
2017/09/08 10:49:08 [debug] ssl_ciphers = "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
2017/09/08 10:49:08 [debug] trusted_ips = {}
2017/09/08 10:49:08 [debug] upstream_keepalive = 60
2017/09/08 10:49:08 [verbose] prefix in use: /usr/local/kong
2017/09/08 10:49:08 [verbose] preparing nginx prefix directory at /usr/local/kong
Error: 
/usr/local/share/lua/5.1/kong/cmd/reload.lua:23: nginx not running in prefix: /usr/local/kong
stack traceback:
    [C]: in function 'assert'
    /usr/local/share/lua/5.1/kong/cmd/reload.lua:23: in function 'cmd_exec'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
    [C]: in function 'xpcall'
    /usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
    /usr/local/bin/kong:7: in function 'file_gen'
    init_worker_by_lua:38: in function <init_worker_by_lua:36>
    [C]: in function 'xpcall'
    init_worker_by_lua:45: in function <init_worker_by_lua:43>
/ # 

Additional Details & Logs


- Kong error logs (`<KONG_PREFIX>/logs/error.log`)

/ # cat usr/local/kong/logs/error.log 2017/09/08 10:47:22 [notice] 43#0: using the "epoll" event method 2017/09/08 10:47:22 [notice] 43#0: openresty/1.11.2.4 2017/09/08 10:47:22 [notice] 43#0: built by gcc 6.3.0 (Alpine 6.3.0) 2017/09/08 10:47:22 [notice] 43#0: OS: Linux 4.4.0-92-generic 2017/09/08 10:47:22 [notice] 43#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2017/09/08 10:47:22 [notice] 43#0: start worker processes 2017/09/08 10:47:22 [notice] 43#0: start worker process 51 2017/09/08 10:47:36 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:36 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:36 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:36 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:36 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:36 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:38 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:38 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:39 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:39 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:39 [notice] 43#0: signal 28 (SIGWINCH) received 2017/09/08 10:47:39 [notice] 51#0: signal 28 (SIGWINCH) received 2017/09/08 10:48:38 [notice] 43#0: signal 2 (SIGINT) received, exiting 2017/09/08 10:48:38 [notice] 51#0: signal 2 (SIGINT) received, exiting 2017/09/08 10:48:38 [notice] 51#0: exiting 2017/09/08 10:48:38 [notice] 51#0: exit 2017/09/08 10:48:38 [notice] 43#0: signal 17 (SIGCHLD) received 2017/09/08 10:48:38 [notice] 43#0: worker process 51 exited with code 0 2017/09/08 10:48:38 [notice] 43#0: exit / #



- Kong configuration (registered APIs/Plugins & configuration file)
    Haven't touched these so what ever is shipped with the container.
- Operating System
    Docker running on Ubuntu 16.04.2 LTS on AWS VPS.
Allu2 commented 7 years ago

Hmm seems my problems came from running everything from docker-compose run

Originally I did this because I couldn't run kong migrations up from docker exec, but after running that with docker-compose run, I can reload with docker exec -it kong reload without problems.

kikito commented 7 years ago

Thanks for reporting this, and I am glad you found a solution. I am closing the issue now.