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

fix(balancer) do not send body from balancer ctx #2327

Merged
merged 1 commit into from
Apr 6, 2017

Commits on Apr 3, 2017

  1. fix(balancer) do not send body from balancer ctx

    The `kong.tools.responses` module sends a body with `ngx.say` when
    calling `responses.send_HTTP_SERVER_ERROR()`. This produces an error on
    top of a previous error, as in:
    
    ```
    2017/04/03 23:42:00 [error] 11076#0: *29 [lua] kong.lua:239: balancer(): failed to set the current peer (address:'2400:cb00:2048:1:0:0:681c:767' port:80): invalid port while connecting to upstream, client: 127.0.0.1, server: kong, request: "GET /status/200?apikey=secret123 HTTP/1.1", host: "acl_test1.com"
    
    2017/04/03 23:42:00 [error] 11076#0: *29 failed to run balancer_by_lua*: ...he/luarocks-2.4.2/share/lua/5.1/kong/tools/responses.lua:127: API disabled in the context of balancer_by_lua*
    
    stack traceback:
    	[C]: in function 'say'
    	...he/luarocks-2.4.2/share/lua/5.1/kong/tools/responses.lua:127: in function 'balancer'
    	balancer_by_lua:2: in function <balancer_by_lua:1> while connecting to upstream, client: 127.0.0.1, server: kong, request: "GET /status/200?apikey=secret123 HTTP/1.1", host: "acl_test1.com"'
    ```
    
    This is because, as pointed out in the error, `ngx.say` is not supported
    in the `balancer_by_lua` context.
    
    This logs the errors directly from the balancer context and simply sends
    the `500` status to the client.
    thibaultcha committed Apr 3, 2017
    Configuration menu
    Copy the full SHA
    233e984 View commit details
    Browse the repository at this point in the history