From 938e7f6fdf49464c4cb2c59d265f75dde5dece1c Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 11 Aug 2022 23:43:46 -0500 Subject: [PATCH] chore: Improve agent logging Contributes towards #3374. Maybe it's something with the reaper? This should make it pretty conclusive what the issue is. --- agent/agent.go | 2 ++ cli/agent.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/agent/agent.go b/agent/agent.go index 6b2e098ca5019..cb2f42ed3c4ed 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -129,6 +129,7 @@ func (a *agent) run(ctx context.Context) { // An exponential back-off occurs when the connection is failing to dial. // This is to prevent server spam in case of a coderd outage. for retrier := retry.New(50*time.Millisecond, 10*time.Second); retrier.Wait(ctx); { + a.logger.Info(ctx, "connecting") metadata, peerListener, err = a.dialer(ctx, a.logger) if err != nil { if errors.Is(err, context.Canceled) { @@ -255,6 +256,7 @@ func (a *agent) handlePeerConn(ctx context.Context, conn *peer.Conn) { } func (a *agent) init(ctx context.Context) { + a.logger.Info(ctx, "generating host key") // Clients' should ignore the host key when connecting. // The agent needs to authenticate with coderd to SSH, // so SSH authentication doesn't improve security. diff --git a/cli/agent.go b/cli/agent.go index 7c9daa8653961..38d94d6bf766b 100644 --- a/cli/agent.go +++ b/cli/agent.go @@ -73,6 +73,7 @@ func workspaceAgent() *cobra.Command { return nil } + logger.Info(cmd.Context(), "starting agent", slog.F("url", coderURL), slog.F("auth", auth)) client := codersdk.New(coderURL) if pprofEnabled { @@ -138,6 +139,7 @@ func workspaceAgent() *cobra.Command { } if exchangeToken != nil { + logger.Info(cmd.Context(), "exchanging identity token") // Agent's can start before resources are returned from the provisioner // daemon. If there are many resources being provisioned, this time // could be significant. This is arbitrarily set at an hour to prevent