Skip to content

Add regression test for Lua panicking #7116

@PiotrSikora

Description

@PiotrSikora

Description:
Add regression test for Lua panicking (Fixed in #6994).

Repro steps:
Start Envoy:

$ bazel-bin/source/exe/envoy-static -c /tmp/lua.yaml --concurrency 1 -l debug

Send a few requests and wait for refused connections:

$ for i in `seq 30`; do curl http://127.0.0.1:8888; done
upstream connect error or disconnect/reset before headers. reset reason: connection failureupstream connect error or disconnect/reset before headers. reset reason: connection failureupstream connect error or disconnect/reset before headers. reset reason: connection failureupstream connect error or disconnect/reset before headers. reset reason: connection failureupstream connect error or disconnect/reset before headers. reset reason: connection failureupstream connect error or disconnect/reset before headers. reset reason: connection failurecurl: (52) Empty reply from server
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused
curl: (7) Failed to connect to 127.0.0.1 port 8888: Connection refused

Config:

$ cat /tmp/lua.yaml
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

static_resources:
  listeners:
  - name: local_listener
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 8888
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          stat_prefix: ingress_http
          codec_type: auto
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: local_service
          http_filters:
          - name: envoy.lua
            config:
              inline_code: |
                function envoy_on_request(request_handle)
                  local copy = {}
                  for k,v in pairs(request_handle:headers()) do
                      copy[k] = v
                  end
                end
          - name: envoy.router
            config: {}
  clusters:
  - name: local_service
    connect_timeout: 1s
    type: static
    lb_policy: round_robin
    hosts:
    - socket_address:
        address: 127.0.0.1
        port_value: 9999

Logs and Call Stack:

[2019-05-30 22:40:11.234][5372][debug][main] [source/server/connection_handler_impl.cc:280] [C12] new connection
[2019-05-30 22:40:11.234][5372][debug][http] [source/common/http/conn_manager_impl.cc:243] [C12] new stream
[2019-05-30 22:40:11.234][5372][debug][http] [source/common/http/conn_manager_impl.cc:583] [C12][S1478173203629700862] request headers complete (end_stream=true):
':authority', '127.0.0.1:8888'
':path', '/'
':method', 'GET'
'user-agent', 'curl/7.52.1'
'accept', '*/*'

[2019-05-30 22:40:11.234][5372][debug][http] [source/common/http/conn_manager_impl.cc:1069] [C12][S1478173203629700862] request end stream
PANIC: unprotected error in call to Lua API (8)
[2019-05-30 22:40:11.234][5372][debug][upstream] [source/common/upstream/cluster_manager_impl.cc:832] shutting down thread local cluster manager
[2019-05-30 22:40:11.234][5372][debug][grpc] [source/common/grpc/google_async_client_impl.cc:31] Joining completionThread
[2019-05-30 22:40:11.234][5373][debug][grpc] [source/common/grpc/google_async_client_impl.cc:64] completionThread exiting
[2019-05-30 22:40:11.234][5372][debug][grpc] [source/common/grpc/google_async_client_impl.cc:33] Joined completionThread

Metadata

Metadata

Assignees

No one assigned

    Labels

    stalestalebot believes this issue/PR has not been touched recentlytech debt

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions