Skip to content

Commit 7b39f6b

Browse files
authored
fix: improves coordination logging (coder#14556)
1 parent 2e6dbd1 commit 7b39f6b

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

enterprise/tailnet/connio.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func newConnIO(coordContext context.Context,
6565
coordCtx: coordContext,
6666
peerCtx: peerCtx,
6767
cancel: cancel,
68-
logger: logger.With(slog.F("name", name)),
68+
logger: logger.With(slog.F("name", name), slog.F("peer_id", id)),
6969
requests: requests,
7070
responses: responses,
7171
bindings: bindings,
@@ -135,6 +135,7 @@ func (c *connIO) handleRequest(req *proto.CoordinateRequest) error {
135135
c.logger.Debug(c.peerCtx, "got request")
136136
err := c.auth.Authorize(req)
137137
if err != nil {
138+
c.logger.Warn(c.peerCtx, "unauthorized request", slog.Error(err))
138139
return xerrors.Errorf("authorize request: %w", err)
139140
}
140141

tailnet/configmaps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func (c *configMaps) setTunnelDestination(id uuid.UUID) {
239239
lc = &peerLifecycle{
240240
peerID: id,
241241
}
242+
c.logger.Debug(context.Background(), "setting peer tunnel destination", slog.F("peer_id", id))
242243
c.peers[id] = lc
243244
}
244245
lc.isDestination = true

tailnet/coordinator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,14 @@ func (c *remoteCoordination) respLoop() {
162162
for {
163163
resp, err := c.protocol.Recv()
164164
if err != nil {
165+
c.logger.Debug(context.Background(), "failed to read from protocol", slog.Error(err))
165166
c.sendErr(xerrors.Errorf("read: %w", err))
166167
return
167168
}
168169

169170
err = c.coordinatee.UpdatePeers(resp.GetPeerUpdates())
170171
if err != nil {
172+
c.logger.Debug(context.Background(), "failed to update peers", slog.Error(err))
171173
c.sendErr(xerrors.Errorf("update peers: %w", err))
172174
return
173175
}
@@ -191,6 +193,7 @@ func (c *remoteCoordination) respLoop() {
191193
ReadyForHandshake: rfh,
192194
})
193195
if err != nil {
196+
c.logger.Debug(context.Background(), "failed to send ready for handshake", slog.Error(err))
194197
c.sendErr(xerrors.Errorf("send: %w", err))
195198
return
196199
}

0 commit comments

Comments
 (0)