Skip to content

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

Merged
merged 3 commits into from
Jun 21, 2023

Conversation

spikecurtis
Copy link
Contributor

First PR of #7961

Logs SSH connection beginning and end, but I need to modify coder/ssh to log the reason for disconnections.

Signed-off-by: Spike Curtis <spike@coder.com>
Copy link
Member

@mafredri mafredri left a 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.

@spikecurtis
Copy link
Contributor Author

I did find that a lot of these Info logs could perhaps be Debug instead?

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.

Copy link
Member

@mtojek mtojek left a 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",
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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>
@spikecurtis spikecurtis changed the title feat: adds logging of ssh connections to agent feat: add logging of ssh connections to agent Jun 21, 2023
@spikecurtis spikecurtis merged commit 1c8f564 into main Jun 21, 2023
@spikecurtis spikecurtis deleted the spike/7961-ssh-connection-logs branch June 21, 2023 09:50
@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants