From 5acc82e04698faa9a50e0cf9d6b32575f7a75039 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 4 Sep 2024 14:40:04 +0400 Subject: [PATCH] fix: improves coordination logging --- enterprise/tailnet/connio.go | 3 ++- tailnet/configmaps.go | 1 + tailnet/coordinator.go | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/enterprise/tailnet/connio.go b/enterprise/tailnet/connio.go index 665f58fd8afb7..fd2c99bdeb8eb 100644 --- a/enterprise/tailnet/connio.go +++ b/enterprise/tailnet/connio.go @@ -65,7 +65,7 @@ func newConnIO(coordContext context.Context, coordCtx: coordContext, peerCtx: peerCtx, cancel: cancel, - logger: logger.With(slog.F("name", name)), + logger: logger.With(slog.F("name", name), slog.F("peer_id", id)), requests: requests, responses: responses, bindings: bindings, @@ -135,6 +135,7 @@ func (c *connIO) handleRequest(req *proto.CoordinateRequest) error { c.logger.Debug(c.peerCtx, "got request") err := c.auth.Authorize(req) if err != nil { + c.logger.Warn(c.peerCtx, "unauthorized request", slog.Error(err)) return xerrors.Errorf("authorize request: %w", err) } diff --git a/tailnet/configmaps.go b/tailnet/configmaps.go index 3af711ffa8f3a..fb00fc2a396e1 100644 --- a/tailnet/configmaps.go +++ b/tailnet/configmaps.go @@ -239,6 +239,7 @@ func (c *configMaps) setTunnelDestination(id uuid.UUID) { lc = &peerLifecycle{ peerID: id, } + c.logger.Debug(context.Background(), "setting peer tunnel destination", slog.F("peer_id", id)) c.peers[id] = lc } lc.isDestination = true diff --git a/tailnet/coordinator.go b/tailnet/coordinator.go index 423dc0ecbfa8d..6586c9917cfb2 100644 --- a/tailnet/coordinator.go +++ b/tailnet/coordinator.go @@ -162,12 +162,14 @@ func (c *remoteCoordination) respLoop() { for { resp, err := c.protocol.Recv() if err != nil { + c.logger.Debug(context.Background(), "failed to read from protocol", slog.Error(err)) c.sendErr(xerrors.Errorf("read: %w", err)) return } err = c.coordinatee.UpdatePeers(resp.GetPeerUpdates()) if err != nil { + c.logger.Debug(context.Background(), "failed to update peers", slog.Error(err)) c.sendErr(xerrors.Errorf("update peers: %w", err)) return } @@ -191,6 +193,7 @@ func (c *remoteCoordination) respLoop() { ReadyForHandshake: rfh, }) if err != nil { + c.logger.Debug(context.Background(), "failed to send ready for handshake", slog.Error(err)) c.sendErr(xerrors.Errorf("send: %w", err)) return }