mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
fix: improves coordination logging (#14556)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user