Close idle channels on gitlab-sshd termination
Why do we need this issue
The graceful shutdown was implemented in !484 (merged).
It relies on canceling the top-level context that is shared by all the connections: https://gitlab.com/gitlab-org/gitlab-shell/blob/42796af90647d55bf2c349a994fd8b9b27526b55/cmd/gitlab-sshd/main.go#L108. We wait for graceful-shutdown-period and then cancel the context and then wait until all operations complete the execution because we expect that all of them are canceled.
The problem is that some blocking operations don't respect the context. For example, authenticating a user uses ssh.NewServerConn that can't be interrupted by canceling a context. The termination hangs as a result (takes longer than graceful-shutdown-period).
Possible solutions
One of the solutions would be to store the connections and close all of them when we're ready to exit (after graceful-shutdown-period is expired).