From a392b19b6ad2ab2d18f9759869398956a338dba0 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Wed, 29 Jul 2020 09:25:29 -0500 Subject: [PATCH] consul/connect: fixup some spelling, comments, consts --- client/allocrunner/consul_grpc_sock_hook.go | 6 +++++- client/allocrunner/consul_http_sock_hook.go | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/allocrunner/consul_grpc_sock_hook.go b/client/allocrunner/consul_grpc_sock_hook.go index ccd3782af..1c406f4aa 100644 --- a/client/allocrunner/consul_grpc_sock_hook.go +++ b/client/allocrunner/consul_grpc_sock_hook.go @@ -21,6 +21,10 @@ import ( const ( consulGRPCSockHookName = "consul_grpc_socket" + + // socketProxyStopWaitTime is the amount of time to wait for a socket proxy + // to stop before assuming something went awry and return a timeout error. + socketProxyStopWaitTime = 3 * time.Second ) var ( @@ -222,7 +226,7 @@ func (p *grpcSocketProxy) stop() error { select { case <-p.doneCh: return nil - case <-time.After(3 * time.Second): + case <-time.After(socketProxyStopWaitTime): return errSocketProxyTimeout } } diff --git a/client/allocrunner/consul_http_sock_hook.go b/client/allocrunner/consul_http_sock_hook.go index 8e9201683..eb0102414 100644 --- a/client/allocrunner/consul_http_sock_hook.go +++ b/client/allocrunner/consul_http_sock_hook.go @@ -99,7 +99,7 @@ func (h *consulHTTPSockHook) Postrun() error { if err := h.proxy.stop(); err != nil { // Only log a failure to stop, worst case is the proxy leaks a goroutine. - h.logger.Debug("error stopping Consul HTTP proxy", "error", err) + h.logger.Warn("error stopping Consul HTTP proxy", "error", err) } return nil @@ -167,7 +167,7 @@ func (p *httpSocketProxy) run(alloc *structs.Allocation) error { // The Consul HTTP socket should be usable by all users in case a task is // running as a non-privileged user. Unix does not allow setting domain // socket permissions when creating the file, so we must manually call - // chmod afterwords. + // chmod afterwards. if err := os.Chmod(hostHTTPSockPath, os.ModePerm); err != nil { return errors.Wrap(err, "unable to set permissions on unix socket") } @@ -192,7 +192,7 @@ func (p *httpSocketProxy) stop() error { select { case <-p.doneCh: - case <-time.After(3 * time.Second): + case <-time.After(socketProxyStopWaitTime): return errSocketProxyTimeout }