From a2c106eba032ffafd6da1ed3fefc75cb6c32bfc6 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 5 Oct 2023 21:51:41 +0000 Subject: [PATCH] backport of commit 270f0400de54a361d3d4205f7dd4483d6ffa8dda --- CHANGELOG.md | 2 ++ internal/daemon/worker/controller_connection.go | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da58d7629..045a86ee67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. * cli: Fix issue when using the `authenticate` command against a password auth method on Windows where the password would be swallowed when the login name is submitted ([PR](https://github.com/hashicorp/boundary/pull/3800)) +* worker: Fix an issue that could cause intermittent startup issues on slow + systems ([PR](https://github.com/hashicorp/boundary/pull/3803)) ## 0.13.1 (2023/07/10) diff --git a/internal/daemon/worker/controller_connection.go b/internal/daemon/worker/controller_connection.go index a96402efd1..2dc2a2f636 100644 --- a/internal/daemon/worker/controller_connection.go +++ b/internal/daemon/worker/controller_connection.go @@ -162,12 +162,12 @@ func (w *Worker) upstreamDialerFunc(extraAlpnProtos ...string) func(context.Cont default: // In this case, event, so that the operator can understand that // it was rejected - event.WriteError(ctx, op, fmt.Errorf("controller rejected activation token as invalid")) + event.WriteError(w.baseContext, op, fmt.Errorf("controller rejected activation token as invalid")) return nil, errors.Wrap(w.baseContext, err, op) } default: - event.WriteError(ctx, op, err) + event.WriteError(w.baseContext, op, err) return nil, errors.Wrap(w.baseContext, err, op) } @@ -176,7 +176,7 @@ func (w *Worker) upstreamDialerFunc(extraAlpnProtos ...string) func(context.Cont w.everAuthenticated.Store(authenticationStatusFirstAuthentication) } - event.WriteSysEvent(ctx, op, "worker has successfully authenticated") + event.WriteSysEvent(w.baseContext, op, "worker has successfully authenticated") } return conn, err @@ -204,13 +204,13 @@ func (w *Worker) v1KmsAuthDialFn(ctx context.Context, addr string, extraAlpnProt written, err := tlsConn.Write([]byte(authInfo.ConnectionNonce)) if err != nil { if err := nonTlsConn.Close(); err != nil { - event.WriteError(ctx, op, err, event.WithInfoMsg("error closing connection after writing failure")) + event.WriteError(w.baseContext, op, err, event.WithInfoMsg("error closing connection after writing failure")) } return nil, fmt.Errorf("unable to write connection nonce: %w", err) } if written != len(authInfo.ConnectionNonce) { if err := nonTlsConn.Close(); err != nil { - event.WriteError(ctx, op, err, event.WithInfoMsg("error closing connection after writing failure")) + event.WriteError(w.baseContext, op, err, event.WithInfoMsg("error closing connection after writing failure")) } return nil, fmt.Errorf("expected to write %d bytes of connection nonce, wrote %d", len(authInfo.ConnectionNonce), written) }