Conversation
…XY enabled loadbalancer/proxy. It accept simultaneously connections that are prepended with PROXY line or not. We also don't issue warnings about unspecified PROXY protocol mode for this listener.
9a7ab44 to
0f358b8
Compare
espadolini
left a comment
There was a problem hiding this comment.
Can we at least gate this behind an option in metrics_service so we don't add load to the thing that's supposed to be used for super lightweight health checks and profiling?
|
@espadolini dedicated |
webvictim
left a comment
There was a problem hiding this comment.
LGTM, but will defer to more experienced reviewers!
|
@AntonAM I realized later that Can we put this behind a flag so in normal conditions the diag listener is only a regular OS stdlib listener handled by a plain |
|
@espadolini I apachebenched it and results were not that different, with 35k vs 40k reqs/sec (plain vs mux), memory consumption was relatively equal, with twice more garbage collections for the mux (125 vs 250). Considering that in real life that listener shouldn't see anywhere similar level of load, do you think it's worth it to introduce flag or something? |
|
The additional memory pressure and resource utilization is exactly what I'm worried about, considering that the pprof endpoints are generally used to diagnose situations where resource utilization is already exceeding the norm, but I suppose we'll just be able to rely on the unix socket for the |
|
Yep, but that's what I meant with ab-testing result, only twice memory overhead over the plain listener (under specifically loading just this listener with thousands reqs per second) seems negligible for the real world usage, especially for the pprof handlers. |
| } | ||
| }() | ||
|
|
||
| err = server.Serve(listenerHTTP) |
There was a problem hiding this comment.
With this change we close listenerHTTP rather than listener when we close server; I suspect that it's not a problem in practice (and it might be slightly more correct, even, considering that we want to manage the lifetime of the listener sockets in TeleportProcess rather than let random goroutines close them) but it might be worth noting in a comment in diagnostic.shutdown.
There was a problem hiding this comment.
We now close multiplexer in diagnostic.shutdown, which closes listener. So I guess we can do without the comment, since we've got virtually the same situation?
| process.RegisterFunc("diagnostic.service", func() error { | ||
| err := server.Serve(listener) | ||
| if err != nil && err != http.ErrServerClosed { | ||
| muxListener, err := multiplexer.New(multiplexer.Config{ |
There was a problem hiding this comment.
We should close muxListener either here in a defer or in diagnostic.shutdown.
Co-authored-by: Gus Luxton <gus@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
…XY enabled loadbalancer/proxy. (#39497) * Wrap diag service listener with multiplexer so it can work behind PROXY enabled loadbalancer/proxy. It accept simultaneously connections that are prepended with PROXY line or not. We also don't issue warnings about unspecified PROXY protocol mode for this listener. * Fix wording. Co-authored-by: Gus Luxton <gus@goteleport.com> * Use ExitContext instead of GracefulExitContext Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Close diag multiplexer listener during diagnostic.shutdown event. * Refactor server.Serve() call * Move creation of muxListener outside of diagnostic.service event. * Combine declaration and usage Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> --------- Co-authored-by: Gus Luxton <gus@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
…XY enabled loadbalancer/proxy. (#39497) * Wrap diag service listener with multiplexer so it can work behind PROXY enabled loadbalancer/proxy. It accept simultaneously connections that are prepended with PROXY line or not. We also don't issue warnings about unspecified PROXY protocol mode for this listener. * Fix wording. Co-authored-by: Gus Luxton <gus@goteleport.com> * Use ExitContext instead of GracefulExitContext Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Close diag multiplexer listener during diagnostic.shutdown event. * Refactor server.Serve() call * Move creation of muxListener outside of diagnostic.service event. * Combine declaration and usage Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> --------- Co-authored-by: Gus Luxton <gus@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
…XY enabled loadbalancer/proxy. (#39497) (#40139) * Wrap diag service listener with multiplexer so it can work behind PROXY enabled loadbalancer/proxy. It accept simultaneously connections that are prepended with PROXY line or not. We also don't issue warnings about unspecified PROXY protocol mode for this listener. * Fix wording. * Use ExitContext instead of GracefulExitContext * Close diag multiplexer listener during diagnostic.shutdown event. * Refactor server.Serve() call * Move creation of muxListener outside of diagnostic.service event. * Combine declaration and usage --------- Co-authored-by: Gus Luxton <gus@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
…XY enabled loadbalancer/proxy. (#39497) (#40140) * Wrap diag service listener with multiplexer so it can work behind PROXY enabled loadbalancer/proxy. It accept simultaneously connections that are prepended with PROXY line or not. We also don't issue warnings about unspecified PROXY protocol mode for this listener. * Fix wording. * Use ExitContext instead of GracefulExitContext * Close diag multiplexer listener during diagnostic.shutdown event. * Refactor server.Serve() call * Move creation of muxListener outside of diagnostic.service event. * Combine declaration and usage --------- Co-authored-by: Gus Luxton <gus@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

This PR wraps diag service listener with multiplexer. It now can accept simultaneously connections that are prepended with PROXY line or not. We also add
HTTP()protocol listener to multiplexer and a flag that controls whether we should issue warnings about unspecified PROXY protocol mode for this listener - diag service will always run in unspecified mode to support both local access and access from behind a proxy/loadbalancer.Fixes #39327
Changelog: Allow diagnostic endpoints to be accessed behind a PROXY protocol enabled loadbalancer/proxy.