Skip to content

Commit 16c12e9

Browse files
authored
chore: Improve agent logging (#3483)
1 parent ca34206 commit 16c12e9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

agent/agent.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (a *agent) run(ctx context.Context) {
129129
// An exponential back-off occurs when the connection is failing to dial.
130130
// This is to prevent server spam in case of a coderd outage.
131131
for retrier := retry.New(50*time.Millisecond, 10*time.Second); retrier.Wait(ctx); {
132+
a.logger.Info(ctx, "connecting")
132133
metadata, peerListener, err = a.dialer(ctx, a.logger)
133134
if err != nil {
134135
if errors.Is(err, context.Canceled) {
@@ -255,6 +256,7 @@ func (a *agent) handlePeerConn(ctx context.Context, conn *peer.Conn) {
255256
}
256257

257258
func (a *agent) init(ctx context.Context) {
259+
a.logger.Info(ctx, "generating host key")
258260
// Clients' should ignore the host key when connecting.
259261
// The agent needs to authenticate with coderd to SSH,
260262
// so SSH authentication doesn't improve security.

cli/agent.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func workspaceAgent() *cobra.Command {
7373
return nil
7474
}
7575

76+
logger.Info(cmd.Context(), "starting agent", slog.F("url", coderURL), slog.F("auth", auth))
7677
client := codersdk.New(coderURL)
7778

7879
if pprofEnabled {
@@ -138,6 +139,7 @@ func workspaceAgent() *cobra.Command {
138139
}
139140

140141
if exchangeToken != nil {
142+
logger.Info(cmd.Context(), "exchanging identity token")
141143
// Agent's can start before resources are returned from the provisioner
142144
// daemon. If there are many resources being provisioned, this time
143145
// could be significant. This is arbitrarily set at an hour to prevent

0 commit comments

Comments
 (0)