-
Notifications
You must be signed in to change notification settings - Fork 886
feat: add logging of ssh connections to agent #8096
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
Conversation
Signed-off-by: Spike Curtis <spike@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding more logging! I did find that a lot of these Info
logs could perhaps be Debug
instead? Other than that, suggested some minor changes.
Debug is the lowest level, and should be reserved for very detailed logs that let us trace execution flow. I'd like to get away from running with debug logging on by default. I.e. our assumption should be that we don't get debug logs from production scenarios unless we specifically ask a customer to turn them on for a specific process. The volume of SSH sessions coming and going on a single agent should be low. For many use cases, it's only a few a day, and they're a frequent subject of support requests, so we should be logging major lifecycle events (starts, stops, errors) at Info or higher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with adding more logging but I admit that some of these could be emitted on debug level. I understand that this way we're reducing the load on support, so I'm 👍
func (s *Server) Serve(l net.Listener) (retErr error) { | ||
s.logger.Info(context.Background(), "started serving listener", slog.F("listen_addr", l.Addr())) | ||
defer func() { | ||
s.logger.Info(context.Background(), "stopped serving listener", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we should also log the total serving time for debugging/support purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logs have timestamps, so I'm not generally worried about being able to tell how much time elapsed.
Listeners get restarted only on agent reconnections to coderd, which should be pretty obvious from the logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I was thinking only about reducing the investigation time, even if the information is redundant. Feel free to leave it as is.
Signed-off-by: Spike Curtis <spike@coder.com>
…-ssh-connection-logs
First PR of #7961
Logs SSH connection beginning and end, but I need to modify coder/ssh to log the reason for disconnections.