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 d9c008f8 authored by Igor Drozdov's avatar Igor Drozdov
Browse files

Sync sessions and new channels execution

If the connection stops accepting new channels we want to wait
until Gitaly operation is complete before exiting
parent 199ea1d1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5,6 +5,7 @@ import (
"golang.org/x/crypto/ssh"
"golang.org/x/sync/semaphore"
"sync"
"gitlab.com/gitlab-org/gitlab-shell/internal/metrics"
Loading
Loading
@@ -28,6 +29,7 @@ func newConnection(maxSessions int64, remoteAddr string) *connection {
func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, handler channelHandler) {
ctxlog := log.WithContextFields(ctx, log.Fields{"remote_addr": c.remoteAddr})
var wg sync.WaitGroup
for newChannel := range chans {
ctxlog.WithField("channel_type", newChannel.ChannelType()).Info("connection: handle: new channel requested")
if newChannel.ChannelType() != "session" {
Loading
Loading
@@ -48,8 +50,10 @@ func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, ha
continue
}
wg.Add(1)
go func() {
defer c.concurrentSessions.Release(1)
defer wg.Done()
// Prevent a panic in a single session from taking out the whole server
defer func() {
Loading
Loading
@@ -62,4 +66,5 @@ func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, ha
ctxlog.Info("connection: handle: done")
}()
}
wg.Wait()
}
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