As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 5dfa9628 authored by Ash McKenzie's avatar Ash McKenzie Committed by Igor Drozdov
Browse files

Create a 'msg: "access"' log entry at the completion of work, including a `duration_s` field

parent 052c7318
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -109,7 +109,6 @@ func main() {
<-time.After(gracePeriod)
cancel()
}()
if err := server.ListenAndServe(ctx); err != nil {
Loading
Loading
Loading
Loading
@@ -51,6 +51,8 @@ func newConnection(cfg *config.Config, nconn net.Conn) *connection {
}
func (c *connection) handle(ctx context.Context, srvCfg *ssh.ServerConfig, handler channelHandler) {
log.WithContextFields(ctx, log.Fields{}).Info("server: handleConn: start")
sconn, chans, err := c.initServerConn(ctx, srvCfg)
if err != nil {
return
Loading
Loading
Loading
Loading
@@ -180,7 +180,6 @@ func (s *Server) handleConn(ctx context.Context, nconn net.Conn) {
remoteAddr := nconn.RemoteAddr().String()
ctxlog := log.WithContextFields(ctx, log.Fields{"remote_addr": remoteAddr})
ctxlog.Debug("server: handleConn: start")
// Prevent a panic in a single connection from taking out the whole server
defer func() {
Loading
Loading
@@ -191,7 +190,9 @@ func (s *Server) handleConn(ctx context.Context, nconn net.Conn) {
}
}()
started := time.Now()
conn := newConnection(s.Config, nconn)
conn.handle(ctx, s.serverConfig.get(ctx), func(sconn *ssh.ServerConn, channel ssh.Channel, requests <-chan *ssh.Request) error {
session := &session{
cfg: s.Config,
Loading
Loading
@@ -199,11 +200,13 @@ func (s *Server) handleConn(ctx context.Context, nconn net.Conn) {
gitlabKeyId: sconn.Permissions.Extensions["key-id"],
gitlabKrb5Principal: sconn.Permissions.Extensions["krb5principal"],
remoteAddr: remoteAddr,
started: time.Now(),
started: started,
}
return session.handle(ctx, requests)
})
ctxlog.WithFields(log.Fields{"duration_s": time.Since(started).Seconds()}).Info("access: finish")
}
func (s *Server) proxyPolicy() (proxyproto.PolicyFunc, error) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment