From 8e41ada8f4c9bdfcfe0a02dcc8646c4fd776d77b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 6 May 2024 22:56:17 +0000 Subject: [PATCH] fix: check if context is nil when logging coordination delete errors I'm not exactly sure how to handle this idiomatically... See: https://github.com/coder/coder/actions/runs/8976564938/job/24653672411 --- enterprise/tailnet/pgcoord.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enterprise/tailnet/pgcoord.go b/enterprise/tailnet/pgcoord.go index 1a9dc88378b03..48fca1ba7e1bc 100644 --- a/enterprise/tailnet/pgcoord.go +++ b/enterprise/tailnet/pgcoord.go @@ -1654,7 +1654,11 @@ func (h *heartbeats) sendDelete() { ctx := dbauthz.As(context.Background(), pgCoordSubject) err := h.store.DeleteCoordinator(ctx, h.self) if err != nil { - h.logger.Error(h.ctx, "failed to send coordinator delete", slog.Error(err)) + // If this errors and the context is no longer active, this + // most likely is a database connection error. + if h.ctx.Err() == nil { + h.logger.Error(h.ctx, "failed to send coordinator delete", slog.Error(err)) + } return } h.logger.Debug(h.ctx, "deleted coordinator")