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

Envoy crashes when ext_authz is reconfigured while under load #8025

Closed
iNoahNothing opened this issue Aug 23, 2019 · 12 comments · Fixed by #8144
Closed

Envoy crashes when ext_authz is reconfigured while under load #8025

iNoahNothing opened this issue Aug 23, 2019 · 12 comments · Fixed by #8144
Labels

Comments

@iNoahNothing
Copy link

Title: Envoy crashes when ext_authz is reconfigured while under load

Description:

When a steady load of approximately > 10 requests per second is sent through Envoy, a reload of the ext_authz filter will cause envoy to appropriately return a 403 but then unexpectedly crash.

This has been tested on master as well as the v1.11.1 release.

Repro steps:

  1. Stand up envoy with the ext_authz using a controller (in this case Ambassador)
  2. Send a stream of requests through envoy
  3. Reconfigure ext_authz
  4. See envoy crash

Config:

{
    "@type": "/envoy.config.bootstrap.v2.Bootstrap",
    "static_resources": {
        "clusters": [
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_127_0_0_1_8877",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "127.0.0.1",
                                                "port_value": 8877,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_127_0_0_1_8877",
                "type": "STRICT_DNS"
            },
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_extauth_example_auth2_3000",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "example-auth2",
                                                "port_value": 3000,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_extauth_example_auth2_3000",
                "type": "STRICT_DNS"
            },
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_tour_8080",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "tour",
                                                "port_value": 8080,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_tour_8080",
                "type": "STRICT_DNS"
            }
        ],
        "listeners": [
            {
                "address": {
                    "socket_address": {
                        "address": "0.0.0.0",
                        "port_value": 8080,
                        "protocol": "TCP"
                    }
                },
                "filter_chains": [
                    {
                        "filters": [
                            {
                                "config": {
                                    "access_log": [
                                        {
                                            "config": {
                                                "format": "ACCESS [%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n",
                                                "path": "/dev/fd/1"
                                            },
                                            "name": "envoy.file_access_log"
                                        }
                                    ],
                                    "http_filters": [
                                        {
                                            "config": {
                                                "http_service": {
                                                    "authorization_request": {
                                                        "allowed_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "cookie"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-for"
                                                                },
                                                                {
                                                                    "exact": "from"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-host"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-proto"
                                                                },
                                                                {
                                                                    "exact": "user-agent"
                                                                },
                                                                {
                                                                    "exact": "proxy-authorization"
                                                                }
                                                            ]
                                                        },
                                                        "headers_to_add": []
                                                    },
                                                    "authorization_response": {
                                                        "allowed_client_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                },
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                }
                                                            ]
                                                        },
                                                        "allowed_upstream_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                },
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                }
                                                            ]
                                                        }
                                                    },
                                                    "path_prefix": "/extauth",
                                                    "server_uri": {
                                                        "cluster": "cluster_extauth_example_auth2_3000",
                                                        "timeout": "5.000s",
                                                        "uri": "http://extauth"
                                                    }
                                                }
                                            },
                                            "name": "envoy.ext_authz"
                                        },
                                        {
                                            "name": "envoy.cors"
                                        },
                                        {
                                            "name": "envoy.router"
                                        }
                                    ],
                                    "http_protocol_options": {
                                        "accept_http_10": false
                                    },
                                    "normalize_path": true,
                                    "route_config": {
                                        "virtual_hosts": [
                                            {
                                                "domains": [
                                                    "*"
                                                ],
                                                "name": "backend",
                                                "routes": [
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/ambassador/v0/check_ready",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_127_0_0_1_8877"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_127_0_0_1_8877",
                                                            "prefix_rewrite": "/ambassador/v0/check_ready",
                                                            "priority": null,
                                                            "timeout": "10.000s"
                                                        }
                                                    },
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/ambassador/v0/check_alive",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_127_0_0_1_8877"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_127_0_0_1_8877",
                                                            "prefix_rewrite": "/ambassador/v0/check_alive",
                                                            "priority": null,
                                                            "timeout": "10.000s"
                                                        }
                                                    },
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/ambassador/v0/",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_127_0_0_1_8877"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_127_0_0_1_8877",
                                                            "prefix_rewrite": "/ambassador/v0/",
                                                            "priority": null,
                                                            "timeout": "10.000s"
                                                        }
                                                    },
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/backend/",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_tour_8080"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_tour_8080",
                                                            "prefix_rewrite": "/",
                                                            "priority": null,
                                                            "timeout": "3.000s"
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    "server_name": "envoy",
                                    "stat_prefix": "ingress_http",
                                    "use_remote_address": true,
                                    "xff_num_trusted_hops": 0
                                },
                                "name": "envoy.http_connection_manager"
                            }
                        ],
                        "use_proxy_proto": false
                    }
                ],
                "name": "ambassador-listener-8080"
            }
        ]
    }
}

Logs:

[2019-08-23 14:04:48.715][198][trace][connection] [source/common/network/connection_impl.cc:394] [C1136] writing 178 bytes, end_stream false
[2019-08-23 14:04:48.715][195][debug][client] [source/common/http/codec_client.cc:82] [C885] disconnect. resetting 0 pending requests
[2019-08-23 14:04:48.715][195][debug][pool] [source/common/http/http1/conn_pool.cc:130] [C885] client disconnected, failure reason: 
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=9)
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:101] [C272] closing data_to_write=0 type=1
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:190] [C272] closing socket: 1
[2019-08-23 14:04:48.715][195][debug][client] [source/common/http/codec_client.cc:82] [C272] disconnect. resetting 0 pending requests
[2019-08-23 14:04:48.715][195][debug][pool] [source/common/http/http1/conn_pool.cc:130] [C272] client disconnected, failure reason: 
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=10)
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:101] [C274] closing data_to_write=0 type=1
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:190] [C274] closing socket: 1
[2019-08-23 14:04:48.715][195][debug][client] [source/common/http/codec_client.cc:82] [C274] disconnect. resetting 0 pending requests
[2019-08-23 14:04:48.715][195][debug][pool] [source/common/http/http1/conn_pool.cc:130] [C274] client disconnected, failure reason: 
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=11)
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:101] [C863] closing data_to_write=0 type=1
[2019-08-23 14:04:48.715][195][debug][connection] [source/common/network/connection_impl.cc:190] [C863] closing socket: 1
[2019-08-23 14:04:48.715][195][debug][client] [source/common/http/codec_client.cc:82] [C863] disconnect. resetting 0 pending requests
[2019-08-23 14:04:48.715][195][debug][pool] [source/common/http/http1/conn_pool.cc:130] [C863] client disconnected, failure reason: 
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=12)
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=13)
[2019-08-23 14:04:48.715][195][trace][main] [source/common/event/dispatcher_impl.cc:76] clearing deferred deletion list (size=13)
[2019-08-23 14:04:48.715][195][trace][connection] [source/common/network/connection_impl.cc:458] [C1134] socket event: 3
[2019-08-23 14:04:48.715][195][trace][connection] [source/common/network/connection_impl.cc:543] [C1134] write ready
[2019-08-23 14:04:48.715][195][trace][connection] [source/common/network/connection_impl.cc:496] [C1134] read ready
[2019-08-23 14:04:48.715][195][trace][connection] [source/common/network/raw_buffer_socket.cc:23] [C1134] read returns: 284
[2019-08-23 14:04:48.715][195][trace][connection] [source/common/network/raw_buffer_socket.cc:37] [C1134] read error: Resource temporarily unavailable
[2019-08-23 14:04:48.715][195][trace][http] [source/common/http/http1/codec_impl.cc:375] [C1134] parsing 284 bytes
[2019-08-23 14:04:48.715][195][trace][http] [source/common/http/http1/codec_impl.cc:498] [C1134] message begin
[2019-08-23 14:04:48.715][195][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1134] completed header: key=Content-Type value=application/json
[2019-08-23 14:04:48.715][198][trace][http] [source/common/http/conn_manager_impl.cc:1569] [C1136][S2563810555345383804] encode data called: filter=0x2dae0a0 status=0
[2019-08-23 14:04:48.715][191][debug][connection] [source/common/network/connection_impl.cc:101] [C1143] closing data_to_write=326 type=2
[2019-08-23 14:04:48.715][191][debug][connection] [source/common/network/connection_impl.cc:653] [C1143] setting delayed close timer with timeout 1000 ms
[2019-08-23 14:04:48.715][198][trace][http] [source/common/http/conn_manager_impl.cc:1582] [C1136][S2563810555345383804] encoding data via codec (size=144 end_stream=false)
[2019-08-23 14:04:48.715][195][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1134] completed header: key=Date value=Fri, 23 Aug 2019 14:04:48 GMT
[2019-08-23 14:04:48.715][194][trace][connection] [source/common/network/raw_buffer_socket.cc:66] [C1144] write returns: 351
[2019-08-23 14:04:48.715][194][debug][connection] [source/common/network/connection_impl.cc:582] [C1144] write flush complete
[2019-08-23 14:04:48.715][194][trace][connection] [source/common/network/connection_impl.cc:458] [C1144] socket event: 6
[2019-08-23 14:04:48.715][194][debug][connection] [source/common/network/connection_impl.cc:479] [C1144] remote early close
[2019-08-23 14:04:48.716][194][debug][connection] [source/common/network/connection_impl.cc:190] [C1144] closing socket: 0
[2019-08-23 14:04:48.716][194][debug][main] [source/server/connection_handler_impl.cc:80] [C1144] adding to cleanup list
[2019-08-23 14:04:48.716][194][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=1)
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:458] [C379] socket event: 3
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:543] [C379] write ready
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:496] [C379] read ready
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/raw_buffer_socket.cc:23] [C379] read returns: 285
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/raw_buffer_socket.cc:37] [C379] read error: Resource temporarily unavailable
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:375] [C379] parsing 285 bytes
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:498] [C379] message begin
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C379] completed header: key=Content-Type value=application/json
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C379] completed header: key=Date value=Fri, 23 Aug 2019 14:04:48 GMT
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:464] [C379] headers complete
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C379] completed header: key=Content-Length value=176
[2019-08-23 14:04:48.716][194][debug][router] [source/common/router/router.cc:1002] [C1145][S1885932356023518673] upstream headers complete: end_stream=false
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/conn_manager_impl.cc:1329] [C1145][S1885932356023518673] encode headers called: filter=0x2c66e10 status=0
[2019-08-23 14:04:48.716][194][debug][http] [source/common/http/conn_manager_impl.cc:1373] [C1145][S1885932356023518673] closing connection due to connection close header
[2019-08-23 14:04:48.716][194][debug][http] [source/common/http/conn_manager_impl.cc:1435] [C1145][S1885932356023518673] encoding headers via codec (end_stream=false):
':status', '200'
'content-type', 'application/json'
'date', 'Fri, 23 Aug 2019 14:04:48 GMT'
'content-length', '176'
'x-envoy-upstream-service-time', '1'
'server', 'envoy'
'connection', 'close'

[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:394] [C1145] writing 177 bytes, end_stream false
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/conn_manager_impl.cc:1569] [C1145][S1885932356023518673] encode data called: filter=0x2c66e10 status=0
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/conn_manager_impl.cc:1582] [C1145][S1885932356023518673] encoding data via codec (size=176 end_stream=false)
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:394] [C1145] writing 176 bytes, end_stream false
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:485] [C379] message complete
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:760] [C379] message complete
[2019-08-23 14:04:48.716][194][debug][client] [source/common/http/codec_client.cc:95] [C379] response complete
[2019-08-23 14:04:48.716][194][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=2)
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/conn_manager_impl.cc:1569] [C1145][S1885932356023518673] encode data called: filter=0x2c66e10 status=0
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/conn_manager_impl.cc:1582] [C1145][S1885932356023518673] encoding data via codec (size=0 end_stream=true)
[2019-08-23 14:04:48.716][194][trace][main] [source/common/event/dispatcher_impl.cc:158] item added to deferred deletion list (size=3)
[2019-08-23 14:04:48.716][194][debug][connection] [source/common/network/connection_impl.cc:101] [C1145] closing data_to_write=353 type=2
[2019-08-23 14:04:48.716][194][debug][connection] [source/common/network/connection_impl.cc:653] [C1145] setting delayed close timer with timeout 1000 ms
[2019-08-23 14:04:48.716][194][debug][pool] [source/common/http/http1/conn_pool.cc:199] [C379] response complete
[2019-08-23 14:04:48.716][194][debug][pool] [source/common/http/http1/conn_pool.cc:237] [C379] moving to ready
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:396] [C379] parsed 285 bytes
[2019-08-23 14:04:48.716][194][trace][main] [source/common/event/dispatcher_impl.cc:76] clearing deferred deletion list (size=3)
[2019-08-23 14:04:48.716][194][debug][main] [source/server/connection_handler_impl.cc:287] [C1164] new connection
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:458] [C1145] socket event: 2
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:543] [C1145] write ready
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/raw_buffer_socket.cc:66] [C1145] write returns: 353
[2019-08-23 14:04:48.716][194][debug][connection] [source/common/network/connection_impl.cc:582] [C1145] write flush complete
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:458] [C1164] socket event: 3
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:543] [C1164] write ready
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/connection_impl.cc:496] [C1164] read ready
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/raw_buffer_socket.cc:23] [C1164] read returns: 238
[2019-08-23 14:04:48.716][194][trace][connection] [source/common/network/raw_buffer_socket.cc:37] [C1164] read error: Resource temporarily unavailable
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:375] [C1164] parsing 238 bytes
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:498] [C1164] message begin
[2019-08-23 14:04:48.716][194][debug][http] [source/common/http/conn_manager_impl.cc:247] [C1164] new stream
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=Host value=192.168.39.204:30116
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=Accept value=*/*
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=Accept-Encoding value=gzip, deflate
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=User-Agent value=Mozilla/5.0 (redhat-x86_64-linux-gnu) Siege/4.0.4
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=Authorization value=Basic dXNlcm5hbWU6cGFzc3dvcmQ=
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:464] [C1164] headers complete
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:343] [C1164] completed header: key=Connection value=close
[2019-08-23 14:04:48.716][194][trace][http] [source/common/http/http1/codec_impl.cc:485] [C1164] message complete
[2019-08-23 14:04:48.716][194][debug][http] [source/common/http/conn_manager_impl.cc:620] [C1164][S697422797895800214] request headers complete (end_stream=true):
':authority', '192.168.39.204:30116'
':path', '/backend/get-quote/'
':method', 'GET'
'accept', '*/*'
'accept-encoding', 'gzip, deflate'
'user-agent', 'Mozilla/5.0 (redhat-x86_64-linux-gnu) Siege/4.0.4'
'authorization', 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='
'connection', 'close'

[2019-08-23 14:04:48.716][194][debug][http] [source/common/http/conn_manager_impl.cc:1167] [C1164][S697422797895800214] request end stream
[2019-08-23 14:04:48.716][194][trace][filter] [source/extensions/filters/http/ext_authz/ext_authz.cc:83] [C1164][S697422797895800214] ext_authz filter calling authorization server
[2019-08-23 14:04:48.716][194][critical][main] [source/exe/terminate_handler.cc:13] std::terminate called! (possible uncaught exception, see trace)
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:69] Backtrace (use tools/stack_decode.py to get line numbers):
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #0: [0x12d45c8]
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #1: [0x12d44d9]
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #2: [0x14974c6]
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:81] Caught Aborted, suspect faulting address 0x22b8000000b5
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:69] Backtrace (use tools/stack_decode.py to get line numbers):
[2019-08-23 14:04:48.716][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #0: [0x7f60606d64b0]
[2019-08-23 14:04:48.717][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #1: [0x12d44d9]
[2019-08-23 14:04:48.717][194][critical][backtrace] [bazel-out/k8-opt/bin/source/server/_virtual_includes/backtrace_lib/server/backtrace.h:75] #2: [0x14974c6]
ActiveStream 0x2d62880, stream_id_: 697422797895800214, has_continue_headers_: 0, is_head_request_: 0, decoding_headers_only_: 0, encoding_headers_only_: 0
request_headers_: 
  ':authority', '192.168.39.204:30116'
  ':path', '/backend/get-quote/'
  ':method', 'GET'
  'accept', '*/*'
  'accept-encoding', 'pt-encoding4:04:48.717][181][debug][config] [source/extensions/filters/network/http_connection_manager/config.cc:351]       name: envoy.ext_authz
', 'gzip, deflate'
  'user-agent', 'Mozilla/5.0 (redhat-x86_64-linux-gnu) Siege/4.0.4'
  'authorization', 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='
  'x-forwarded-for', '192.168.39.1'
  'x-forwarded-proto', 'http'
  'x-envoy-internal', 'true'
  'x-request-id', 'd984b0dc-92d6-4e5f-a00e-bcfe3f885f00'
request_trailers_: null
response_headers_: null
response_trailers_: null
&stream_info_: 
  StreamInfoImpl 0x2d629b8, protocol_: 1, response_code_: null, response_code_details_: null, health_check_request_: 0, route_name_: 
./entrypoint.sh: line 22: warning: run_pending_traps: bad value in trap_list[17]: 0x55f053dd8dd3
./entrypoint.sh: line 19: warning: run_pending_traps: bad value in trap_list[17]: 0x55f053dd8dd3
2019-08-23 14:04:48 AMBASSADOR INFO envoy exited with status 134
./entrypoint.sh: line 19: warning: run_pending_traps: bad value in trap_list[17]: 0x55f053dd8dd3
2019-08-23 14:04:48 AMBASSADOR INFO killing extant processes
kill: can't kill pid 181: No such process
./entrypoint.sh: line 192: warning: run_pending_traps: bad value in trap_list[17]: 0x55f053dd8dd3
[2019-08-23 14:04:48 +0000] [125] [INFO] Handling signal: term
time="2019-08-23T14:04:48Z" level=info msg=Done
./entrypoint.sh: line 19: warning: run_pending_traps: bad value in trap_list[17]: 0x55f053dd8dd3
2019-08-23 14:04:48 AMBASSADOR INFO shutting down (1)
@mattklein123
Copy link
Member

Please provide a core dump or at least a back trace with fully resolved symbols. Thank you!

@concaf
Copy link

concaf commented Aug 26, 2019

Hey @mattklein123, I was trying to get a back trace with fully resolved symbols using https://github.com/envoyproxy/envoy/tree/master/bazel#stack-trace-symbol-resolution

I think the docs are for stack traces produced while running tests via bazel - while what I have is an envoy binary with no test for this behavior. Can you help me with how can I provide you back trace with resolved symbols?

@concaf
Copy link

concaf commented Aug 26, 2019

Okay, I didn't have much luck with using stack_decode.py, but I did change my envoy image to envoy-alpine-debug-dev which has some symbols in place in the logs (IIUC).

Here is the tail of the logs when Envoy started crashing - https://paste.fedoraproject.org/paste/gnQJR9yI9ri5n9TwXbmFpg/raw

Here are the entire logs - https://drive.google.com/file/d/17lp120Rk1AfLrqnbOqfQSM-QavoLyFkF/view

@mattklein123 let me know if you need something else, thanks 👍

@mattklein123 mattklein123 added the help wanted Needs help! label Aug 26, 2019
@mattklein123
Copy link
Member

@containscafeine unfortunately that stack trace is not giving me useful info. I would work on potentially getting a core dump, or if you can't do that, a self contained repro.

@concaf
Copy link

concaf commented Aug 26, 2019

@mattklein123 okay, let me get something useful for you tomorrow. In the meantime, can you point me to how to get a core dump? Skimmed the docs but couldn't find anything.

Thanks for the help :)

@concaf
Copy link

concaf commented Aug 28, 2019

Hey @mattklein123, so I tried again with getting a fresh build with bazel and tried to decode the logs with stack_decode.py but still no luck.

Anyway, here is the repro that you asked for -

  1. We update all the configs via XDS. Here is our bootstrap config -
{
    "admin": {
        "access_log_path": "/tmp/admin_access_log",
        "address": {
            "socket_address": {
                "address": "127.0.0.1",
                "port_value": 8001
            }
        }
    },
    "dynamic_resources": {
        "ads_config": {
            "api_type": "GRPC",
            "grpc_services": [
                {
                    "envoy_grpc": {
                        "cluster_name": "xds_cluster"
                    }
                }
            ]
        },
        "cds_config": {
            "ads": {}
        },
        "lds_config": {
            "ads": {}
        }
    },
    "node": {
        "cluster": "ambassador-default",
        "id": "test-id"
    },
    "static_resources": {
        "clusters": [
            {
                "connect_timeout": "1s",
                "hosts": [
                    {
                        "socket_address": {
                            "address": "127.0.0.1",
                            "port_value": 8003
                        }
                    }
                ],
                "http2_protocol_options": {},
                "name": "xds_cluster"
            }
        ]
    }
}
  1. Run 2 auth services and the backend service like the following -
    docker run -d --rm --name example-auth -p 3000:3000 datawire/ambassador-auth-service:2.0.0
    docker run -d --rm --name example-auth2 -p 3000:3000 datawire/ambassador-auth-service:2.0.0
    docker run --rm --name tour -p 8080:8080 -d quay.io/datawire/tour:backend-0.2.4

Make sure you update /etc/hosts so envoy could reach these services by name. Mine looks like -

172.17.0.3      example-auth
172.17.0.4      example-auth2
172.17.0.5      tour
  1. Apply this configuration via XDS -
{
    "@type": "/envoy.config.bootstrap.v2.Bootstrap",
    "static_resources": {
        "clusters": [
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_extauth_example_auth_3000",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "example-auth",
                                                "port_value": 3000,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_extauth_example_auth_3000",
                "type": "STRICT_DNS"
            },
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_tour_8080",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "tour",
                                                "port_value": 8080,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_tour_8080",
                "type": "STRICT_DNS"
            }
        ],
        "listeners": [
            {
                "address": {
                    "socket_address": {
                        "address": "0.0.0.0",
                        "port_value": 8080,
                        "protocol": "TCP"
                    }
                },
                "filter_chains": [
                    {
                        "filters": [
                            {
                                "config": {
                                    "access_log": [
                                        {
                                            "config": {
                                                "format": "ACCESS [%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n",
                                                "path": "/dev/fd/1"
                                            },
                                            "name": "envoy.file_access_log"
                                        }
                                    ],
                                    "http_filters": [
                                        {
                                            "config": {
                                                "http_service": {
                                                    "authorization_request": {
                                                        "allowed_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "cookie"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-for"
                                                                },
                                                                {
                                                                    "exact": "user-agent"
                                                                },
                                                                {
                                                                    "exact": "proxy-authorization"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "from"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-proto"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-host"
                                                                }
                                                            ]
                                                        },
                                                        "headers_to_add": []
                                                    },
                                                    "authorization_response": {
                                                        "allowed_client_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                }
                                                            ]
                                                        },
                                                        "allowed_upstream_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                }
                                                            ]
                                                        }
                                                    },
                                                    "path_prefix": "/extauth",
                                                    "server_uri": {
                                                        "cluster": "cluster_extauth_example_auth_3000",
                                                        "timeout": "5.000s",
                                                        "uri": "http://extauth"
                                                    }
                                                }
                                            },
                                            "name": "envoy.ext_authz"
                                        },
                                        {
                                            "name": "envoy.cors"
                                        },
                                        {
                                            "name": "envoy.router"
                                        }
                                    ],
                                    "http_protocol_options": {
                                        "accept_http_10": false
                                    },
                                    "normalize_path": true,
                                    "route_config": {
                                        "virtual_hosts": [
                                            {
                                                "domains": [
                                                    "*"
                                                ],
                                                "name": "backend",
                                                "routes": [
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/backend/",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_tour_8080"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_tour_8080",
                                                            "prefix_rewrite": "/",
                                                            "priority": null,
                                                            "timeout": "3.000s"
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    "server_name": "envoy",
                                    "stat_prefix": "ingress_http",
                                    "use_remote_address": true,
                                    "xff_num_trusted_hops": 0
                                },
                                "name": "envoy.http_connection_manager"
                            }
                        ],
                        "use_proxy_proto": false
                    }
                ],
                "name": "ambassador-listener-8080"
            }
        ]
    }
}

Note that this refers to auth-service and not to auth-service2.

  1. Now generate some HTTP traffic to envoy (ideally more than 20 requests per second). I use the command -
    siege -H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" minikube ip:31668/backend/get-quote/

Note that you get 200 OK with this request.

  1. While the server is under load (this is the key point), update the configuration to point to another auth service via ADS -
{
    "@type": "/envoy.config.bootstrap.v2.Bootstrap",
    "static_resources": {
        "clusters": [
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_extauth_example_auth2_3000",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "example-auth2",
                                                "port_value": 3000,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_extauth_example_auth2_3000",
                "type": "STRICT_DNS"
            },
            {
                "connect_timeout": "3.000s",
                "dns_lookup_family": "V4_ONLY",
                "lb_policy": "ROUND_ROBIN",
                "load_assignment": {
                    "cluster_name": "cluster_tour_8080",
                    "endpoints": [
                        {
                            "lb_endpoints": [
                                {
                                    "endpoint": {
                                        "address": {
                                            "socket_address": {
                                                "address": "tour",
                                                "port_value": 8080,
                                                "protocol": "TCP"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                },
                "name": "cluster_tour_8080",
                "type": "STRICT_DNS"
            }
        ],
        "listeners": [
            {
                "address": {
                    "socket_address": {
                        "address": "0.0.0.0",
                        "port_value": 8080,
                        "protocol": "TCP"
                    }
                },
                "filter_chains": [
                    {
                        "filters": [
                            {
                                "config": {
                                    "access_log": [
                                        {
                                            "config": {
                                                "format": "ACCESS [%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n",
                                                "path": "/dev/fd/1"
                                            },
                                            "name": "envoy.file_access_log"
                                        }
                                    ],
                                    "http_filters": [
                                        {
                                            "config": {
                                                "http_service": {
                                                    "authorization_request": {
                                                        "allowed_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "cookie"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-for"
                                                                },
                                                                {
                                                                    "exact": "user-agent"
                                                                },
                                                                {
                                                                    "exact": "proxy-authorization"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "from"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-proto"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "x-forwarded-host"
                                                                }
                                                            ]
                                                        },
                                                        "headers_to_add": []
                                                    },
                                                    "authorization_response": {
                                                        "allowed_client_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                }
                                                            ]
                                                        },
                                                        "allowed_upstream_headers": {
                                                            "patterns": [
                                                                {
                                                                    "exact": "location"
                                                                },
                                                                {
                                                                    "exact": "www-authenticate"
                                                                },
                                                                {
                                                                    "exact": "x-qotm-session"
                                                                },
                                                                {
                                                                    "exact": "proxy-authenticate"
                                                                },
                                                                {
                                                                    "exact": "authorization"
                                                                },
                                                                {
                                                                    "exact": "set-cookie"
                                                                }
                                                            ]
                                                        }
                                                    },
                                                    "path_prefix": "/extauth",
                                                    "server_uri": {
                                                        "cluster": "cluster_extauth_example_auth2_3000",
                                                        "timeout": "5.000s",
                                                        "uri": "http://extauth"
                                                    }
                                                }
                                            },
                                            "name": "envoy.ext_authz"
                                        },
                                        {
                                            "name": "envoy.cors"
                                        },
                                        {
                                            "name": "envoy.router"
                                        }
                                    ],
                                    "http_protocol_options": {
                                        "accept_http_10": false
                                    },
                                    "normalize_path": true,
                                    "route_config": {
                                        "virtual_hosts": [
                                            {
                                                "domains": [
                                                    "*"
                                                ],
                                                "name": "backend",
                                                "routes": [
                                                    {
                                                        "match": {
                                                            "case_sensitive": true,
                                                            "prefix": "/backend/",
                                                            "runtime_fraction": {
                                                                "default_value": {
                                                                    "denominator": "HUNDRED",
                                                                    "numerator": 100
                                                                },
                                                                "runtime_key": "routing.traffic_shift.cluster_tour_8080"
                                                            }
                                                        },
                                                        "route": {
                                                            "cluster": "cluster_tour_8080",
                                                            "prefix_rewrite": "/",
                                                            "priority": null,
                                                            "timeout": "3.000s"
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    "server_name": "envoy",
                                    "stat_prefix": "ingress_http",
                                    "use_remote_address": true,
                                    "xff_num_trusted_hops": 0
                                },
                                "name": "envoy.http_connection_manager"
                            }
                        ],
                        "use_proxy_proto": false
                    }
                ],
                "name": "ambassador-listener-8080"
            }
        ]
    }
}

It is now that Envoy will crash upon updating the auth service config.


Let me know if you need something else! Thanks! 👍

@dio
Copy link
Member

dio commented Sep 2, 2019

I think it's because there is a request (initiated by ext_authz) here:

request_ = cm_.httpAsyncClientForCluster(config_->cluster())
.send(std::move(message), *this,
Http::AsyncClient::RequestOptions().setTimeout(config_->timeout()));
that tries to find a removed cluster, hence throwing this:
throw EnvoyException(fmt::format("unknown cluster '{}'", cluster));

I tried to add a try-catch block around the request,

diff --git a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc
index b40a927fd..ff44a716a 100644
--- a/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc
+++ b/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc
@@ -202,9 +202,14 @@ void RawHttpClientImpl::check(RequestCallbacks& callbacks,
         std::make_unique<Buffer::OwnedImpl>(request.attributes().request().http().body());
   }

-  request_ = cm_.httpAsyncClientForCluster(config_->cluster())
-                 .send(std::move(message), *this,
-                       Http::AsyncClient::RequestOptions().setTimeout(config_->timeout()));
+  try {
+    request_ = cm_.httpAsyncClientForCluster(config_->cluster())
+                   .send(std::move(message), *this,
+                         Http::AsyncClient::RequestOptions().setTimeout(config_->timeout()));
+  } catch (const EnvoyException&) {
+    callbacks_->onComplete(std::make_unique<Response>(errorResponse()));
+    callbacks_ = nullptr;
+  }
 }

 void RawHttpClientImpl::onSuccess(Http::MessagePtr&& message) {

It seems it can remedy the issue, as demonstrated here: https://github.com/dio/update-lds-cds-when-under-load.

While this is clearly a hack, I think the right fix will be using the "dynamic_forward_proxy"-way of resolving upstream "cluster".

@dio
Copy link
Member

dio commented Sep 2, 2019

@containscafeine if you can try to replace your envoy image with this image defined in https://github.com/dio/update-lds-cds-when-under-load/blob/6d9ef4998becf9760177cbbd7bd1eb3b78bfcb64/fixed/docker-compose.yaml#L4 That will give us more ideas. Thank you!

@concaf
Copy link

concaf commented Sep 3, 2019

@dio just tried the binary from that image, and it works perfect - no more crashes! Thanks for looking into this ;)

@dio
Copy link
Member

dio commented Sep 3, 2019

@containscafeine yeah, we need to put a proper fix for this. Do you want to take this?

Since today, for the ext_authz's http_service the server_uri,

envoy.api.v2.core.HttpUri server_uri = 1;
it is not directly being used, but rather it uses the cluster defined in the HTTP URI.

I see this comment here is interesting:

// Specify how `uri` is to be fetched. Today, this requires an explicit
// cluster, but in the future we may support dynamic cluster creation or
// inline DNS resolution. See `issue
// <https://github.com/envoyproxy/envoy/issues/1606>`_.

@mattklein123 do yo have suggestions on this?

@mattklein123
Copy link
Member

@mattklein123 do yo have suggestions on this?

There are a bunch of examples like this. The general pattern is to get the thread local cluster from the CM. If it doesn't exist, handle, otherwise it should be safe to make an async client call.

@dio
Copy link
Member

dio commented Sep 3, 2019

@mattklein123 Cool. That will be relatively easy to fix. I mixed the the thing in my head with this issue: #6099 😅

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

Successfully merging a pull request may close this issue.

4 participants