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

tls inspector makes mysql connection using tcp proxy timeout #21044

Closed
ferjjp opened this issue Apr 27, 2022 · 6 comments
Closed

tls inspector makes mysql connection using tcp proxy timeout #21044

ferjjp opened this issue Apr 27, 2022 · 6 comments
Labels
bug question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently

Comments

@ferjjp
Copy link

ferjjp commented Apr 27, 2022

Hi, this is my first issue on envoy!

I am using envoy as a sidecar transparent proxy and I have set up a rule that adds an envoy.filters.network.tcp_proxy that allows a container running a mysql client in the pod to access a mysql server. I was also using this listener for outgoing HTTP connections using HCM, and now a change in requirements requires me to have the tls inspector filter enabled on this listener.

After making the configuration changes we discovered that the outgoing mysql connections that we previously had were not working correctly:

[2022-04-25 19:09:44.960][26][debug][filter] [source/extensions/filters/listener/original_dst/original_dst.cc:20] original_dst: new connection accepted
[2022-04-25 19:09:44.960][26][debug][filter] [source/extensions/filters/listener/tls_inspector/tls_inspector.cc:88] tls inspector: new connection accepted
[2022-04-25 19:09:45.013][1][debug][main] [source/server/server.cc:251] flushing stats
[2022-04-25 19:09:50.013][1][debug][main] [source/server/server.cc:251] flushing stats
[2022-04-25 19:09:55.013][1][debug][main] [source/server/server.cc:251] flushing stats
[2022-04-25 19:09:59.963][26][debug][conn_handler] [source/server/active_tcp_socket.cc:45] listener filter times out after 15000 ms
[2022-04-25 19:09:59.964][31][debug][filter] [source/extensions/filters/listener/original_dst/original_dst.cc:20] original_dst: new connection accepted
[2022-04-25 19:09:59.964][31][debug][filter] [source/extensions/filters/listener/tls_inspector/tls_inspector.cc:88] tls inspector: new connection accepted

This is an extract of a mini-lab (using envoy 1.22) we used to isolate the problem. We discovered a timeout after 15000ms on the mysql connection. This timeout does not occur if the tls inspector listener filter is not used.

I looked around for any similar issues and found a few:

In this last issue, the problem was that mysql starts sending data to the client first. It seems to me that this is what's happening here, or something similar.

Simplified config that reproduces this:

admin:
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 12345
static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    listener_filters:
    - name: "envoy.filters.listener.tls_inspector"
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector
    filter_chains:
    - filter_chain_match:
      filters:
      - name: envoy.filters.network.tcp_proxy
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
          cluster: mysql
          stat_prefix: mysql

  clusters:
  - name: mysql
    type: STRICT_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: mysql
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: mysql
                port_value: 3306

I'm creating this as a bug, but the thing is, I'm not sure if tls inspector should be working for this particular use case or not...Any input is appreciated, thanks.

@ferjjp ferjjp added bug triage Issue requires triage labels Apr 27, 2022
@lambdai
Copy link
Contributor

lambdai commented Apr 27, 2022

This case is the motivation of continue_on_listener_filters_timeout.

You can disable tls_inspector using filter_disabled. In your case, the filter_dsiabled should be configured to match mysql traffic but not match HCM traffic.

See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#envoy-v3-api-msg-config-listener-v3-listenerfilter

@ferjjp
Copy link
Author

ferjjp commented Apr 28, 2022

I hadn't noticed the continue_on_listener_filters_timeout option at all. I'll try out the filter disabled option to see if I can make it match correctly, thank you!

@alyssawilk alyssawilk added question Questions that are neither investigations, bugs, nor enhancements and removed triage Issue requires triage labels Apr 29, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label May 29, 2022
@github-actions
Copy link

github-actions bot commented Jun 5, 2022

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as completed Jun 5, 2022
@deveshkandpal1224
Copy link
Contributor

deveshkandpal1224 commented Sep 11, 2023

@lambdai @alyssawilk - if you have a TCP tunneling usecase for mysql ( client -> envoy -> squid -> database ) where the tunneling_config depends on TLS inspector being present ( requested_server_name ) - is there a way to make this work still ?

@deveshkandpal1224
Copy link
Contributor

it definitely works without tls_inspector but in that case I had to use %DOWNSTREAM_LOCAL_ADDRESS% in my tunneling_config to make this work. But would be nicer to get it to work with the reqested_server_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

4 participants