Skip to content

chore: tailnet debug logging #7260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More reconnectingPTY logging
Signed-off-by: Spike Curtis <spike@coder.com>
  • Loading branch information
spikecurtis committed Apr 26, 2023
commit 62f3155d266b4ec127b49f38920634849383345f
13 changes: 11 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
// 1. The timeout completed.
// 2. The parent context was canceled.
<-ctx.Done()
logger.Debug(ctx, "context done", slog.Error(ctx.Err()))
_ = process.Kill()
}()
// We don't need to separately monitor for the process exiting.
Expand All @@ -1049,6 +1050,8 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
read, err := rpty.ptty.OutputReader().Read(buffer)
if err != nil {
// When the PTY is closed, this is triggered.
// Error is typically a benign EOF, so only log for debugging.
logger.Debug(ctx, "PTY output read error", slog.Error(err))
break
}
part := buffer[:read]
Expand All @@ -1060,8 +1063,14 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
break
}
rpty.activeConnsMutex.Lock()
for _, conn := range rpty.activeConns {
_, _ = conn.Write(part)
for cid, conn := range rpty.activeConns {
_, err = conn.Write(part)
logger.Debug(ctx,
"wrote to active conn",
slog.F("other_conn_id", cid),
slog.F("data", part),
slog.Error(err),
)
}
rpty.activeConnsMutex.Unlock()
}
Expand Down