- Notifications
You must be signed in to change notification settings - Fork1.1k
fix: avoid connection logging crashes in agent#20307
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -781,11 +781,15 @@ func (a *agent) reportConnectionsLoop(ctx context.Context, aAPI proto.DRPCAgentC | ||
| logger.Debug(ctx, "reporting connection") | ||
| _, err := aAPI.ReportConnection(ctx, payload) | ||
| if err != nil { | ||
| // Do not fail the loop if we fail to report a connection, just | ||
| // log a warning. | ||
| // Related to https://github.com/coder/coder/issues/20194 | ||
| logger.Warn(ctx, "failed to report connection to server", slog.Error(err)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. what is the consequence for a failed report? I see one action is This would fundamentally change that behavior, which is ok if we can document it. Or have some other kind of timeout/heartbeat to resolve the hanging "connection" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Ah I see, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's fine if connection logs get dropped. We document them as best effort | ||
| // keep going, we still need to remove it from the slice | ||
| } else { | ||
| logger.Debug(ctx, "successfully reported connection") | ||
| } | ||
| // Remove the payload we sent. | ||
| a.reportConnectionsMu.Lock() | ||
| a.reportConnections[0] = nil // Release the pointer from the underlying array. | ||
| @@ -816,6 +820,13 @@ func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_T | ||
| ip = host | ||
| } | ||
| // If the IP is "localhost" (which it can be in some cases), set it to | ||
| // 127.0.0.1 instead. | ||
| // Related to https://github.com/coder/coder/issues/20194 | ||
| if ip == "localhost" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do we need to handle this in both agent and coderd? I'd imagine just coderd would suffice but then again doesn't hurt either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah it probably doesn't need to be fixed here, but I think it's fine. It'd be great to fix the localhost issue entirely cuz it does seem like it shouldn't be happening anyway (should probably be a tailnet IP?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah, I think tailnet IP would be more appropriate 👍🏻 | ||
| ip = "127.0.0.1" | ||
| } | ||
Comment on lines +823 to +828 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Technically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I thought about this, but in the end these will just show up as | ||
| a.reportConnectionsMu.Lock() | ||
| defer a.reportConnectionsMu.Unlock() | ||
Uh oh!
There was an error while loading.Please reload this page.