From e4bf6e068fd756986ae035c897609e4e4d582c1b Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Thu, 18 Mar 2021 10:00:06 -0700 Subject: [PATCH] Add a comment to impersonator.go --- internal/concierge/impersonator/impersonator.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/concierge/impersonator/impersonator.go b/internal/concierge/impersonator/impersonator.go index a95dc770..3d7ad324 100644 --- a/internal/concierge/impersonator/impersonator.go +++ b/internal/concierge/impersonator/impersonator.go @@ -270,11 +270,14 @@ func newImpersonationReverseProxyFunc(restConfig *rest.Config) (func(*genericapi } plog.Debug("impersonation proxy servicing request", "method", r.Method, "url", r.URL.String()) - defer plog.Debug("impersonation proxy finished servicing request", "method", r.Method, "url", r.URL.String()) plog.Trace("impersonation proxy servicing request was for user", "method", r.Method, "url", r.URL.String(), "username", userInfo.GetName(), // this info leak seems fine for trace level logs ) + // The proxy library used below will panic when the client disconnects abruptly, so in order to + // assure that this log message is always printed at the end of this func, it must be deferred. + defer plog.Debug("impersonation proxy finished servicing request", "method", r.Method, "url", r.URL.String()) + reverseProxy := httputil.NewSingleHostReverseProxy(serverURL) reverseProxy.Transport = rt reverseProxy.FlushInterval = 200 * time.Millisecond // the "watch" verb will not work without this line