mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
fix: reduce excessive logging when database is unreachable (#17363)
Fixes #17045 --------- Signed-off-by: Danny Kopping <dannykopping@gmail.com>
This commit is contained in:
@ -2,6 +2,7 @@ package tailnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
@ -21,11 +22,12 @@ import (
|
||||
"tailscale.com/util/dnsname"
|
||||
|
||||
"cdr.dev/slog"
|
||||
"github.com/coder/quartz"
|
||||
"github.com/coder/retry"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/tailnet/proto"
|
||||
"github.com/coder/quartz"
|
||||
"github.com/coder/retry"
|
||||
)
|
||||
|
||||
// A Controller connects to the tailnet control plane, and then uses the control protocols to
|
||||
@ -1381,6 +1383,14 @@ func (c *Controller) Run(ctx context.Context) {
|
||||
if xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded) {
|
||||
return
|
||||
}
|
||||
|
||||
// If the database is unreachable by the control plane, there's not much we can do, so we'll just retry later.
|
||||
if errors.Is(err, codersdk.ErrDatabaseNotReachable) {
|
||||
c.logger.Warn(c.ctx, "control plane lost connection to database, retrying",
|
||||
slog.Error(err), slog.F("delay", fmt.Sprintf("%vms", retrier.Delay.Milliseconds())))
|
||||
continue
|
||||
}
|
||||
|
||||
errF := slog.Error(err)
|
||||
var sdkErr *codersdk.Error
|
||||
if xerrors.As(err, &sdkErr) {
|
||||
|
Reference in New Issue
Block a user