Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d8b77d

Browse files
authored
chore: improve clarity of the agent logs (#6345)
I looked through these logs when debugging and there was a bit of spam!
1 parentec6f78d commit3d8b77d

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

‎agent/agent.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (a *agent) runLoop(ctx context.Context) {
156156
goa.reportLifecycleLoop(ctx)
157157

158158
forretrier:=retry.New(100*time.Millisecond,10*time.Second);retrier.Wait(ctx); {
159-
a.logger.Info(ctx,"running loop")
159+
a.logger.Info(ctx,"connecting to coderd")
160160
err:=a.run(ctx)
161161
// Cancel after the run is complete to clean up any leaked resources!
162162
iferr==nil {
@@ -169,7 +169,7 @@ func (a *agent) runLoop(ctx context.Context) {
169169
return
170170
}
171171
iferrors.Is(err,io.EOF) {
172-
a.logger.Info(ctx,"likelydisconnected fromcoder",slog.Error(err))
172+
a.logger.Info(ctx,"disconnected fromcoderd")
173173
continue
174174
}
175175
a.logger.Warn(ctx,"run exited with error",slog.Error(err))
@@ -197,7 +197,7 @@ func (a *agent) reportLifecycleLoop(ctx context.Context) {
197197
break
198198
}
199199

200-
a.logger.Debug(ctx,"post lifecycle state",slog.F("state",state))
200+
a.logger.Debug(ctx,"reporting lifecycle state",slog.F("state",state))
201201

202202
err:=a.client.PostLifecycle(ctx, agentsdk.PostLifecycleRequest{
203203
State:state,
@@ -242,7 +242,7 @@ func (a *agent) run(ctx context.Context) error {
242242
iferr!=nil {
243243
returnxerrors.Errorf("fetch metadata: %w",err)
244244
}
245-
a.logger.Info(ctx,"fetched metadata")
245+
a.logger.Info(ctx,"fetched metadata",slog.F("metadata",metadata))
246246

247247
// Expand the directory and send it back to coderd so external
248248
// applications that rely on the directory can use it.
@@ -330,13 +330,10 @@ func (a *agent) run(ctx context.Context) error {
330330
goNewWorkspaceAppHealthReporter(
331331
a.logger,metadata.Apps,a.client.PostAppHealth)(appReporterCtx)
332332

333-
a.logger.Debug(ctx,"running tailnet with derpmap",slog.F("derpmap",metadata.DERPMap))
334-
335333
a.closeMutex.Lock()
336334
network:=a.network
337335
a.closeMutex.Unlock()
338336
ifnetwork==nil {
339-
a.logger.Debug(ctx,"creating tailnet")
340337
network,err=a.createTailnet(ctx,metadata.DERPMap)
341338
iferr!=nil {
342339
returnxerrors.Errorf("create tailnet: %w",err)
@@ -385,10 +382,9 @@ func (a *agent) run(ctx context.Context) error {
385382
network.SetDERPMap(metadata.DERPMap)
386383
}
387384

388-
a.logger.Debug(ctx,"running coordinator")
385+
a.logger.Debug(ctx,"runningtailnet connectioncoordinator")
389386
err=a.runCoordinator(ctx,network)
390387
iferr!=nil {
391-
a.logger.Debug(ctx,"coordinator exited",slog.Error(err))
392388
returnxerrors.Errorf("run coordinator: %w",err)
393389
}
394390
returnnil
@@ -474,7 +470,9 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
474470
for {
475471
conn,err:=reconnectingPTYListener.Accept()
476472
iferr!=nil {
477-
logger.Debug(ctx,"accept pty failed",slog.Error(err))
473+
if!a.isClosed() {
474+
logger.Debug(ctx,"accept pty failed",slog.Error(err))
475+
}
478476
break
479477
}
480478
wg.Add(1)
@@ -529,7 +527,9 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
529527
for {
530528
conn,err:=speedtestListener.Accept()
531529
iferr!=nil {
532-
a.logger.Debug(ctx,"speedtest listener failed",slog.Error(err))
530+
if!a.isClosed() {
531+
a.logger.Debug(ctx,"speedtest listener failed",slog.Error(err))
532+
}
533533
break
534534
}
535535
wg.Add(1)
@@ -600,7 +600,7 @@ func (a *agent) runCoordinator(ctx context.Context, network *tailnet.Conn) error
600600
returnerr
601601
}
602602
defercoordinator.Close()
603-
a.logger.Info(ctx,"connected to coordinationserver")
603+
a.logger.Info(ctx,"connected to coordinationendpoint")
604604
sendNodes,errChan:=tailnet.ServeCoordinator(coordinator,func(nodes []*tailnet.Node)error {
605605
returnnetwork.UpdateNodes(nodes,false)
606606
})
@@ -646,7 +646,6 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error {
646646
}
647647

648648
func (a*agent)init(ctx context.Context) {
649-
a.logger.Info(ctx,"generating host key")
650649
// Clients' should ignore the host key when connecting.
651650
// The agent needs to authenticate with coderd to SSH,
652651
// so SSH authentication doesn't improve security.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp