summaryrefslogtreecommitdiff
path: root/internal/command
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2020-07-31 12:58:42 +0000
committerIgor Drozdov <idrozdov@gitlab.com>2020-07-31 12:58:42 +0000
commit87402ed127d9855b8123e5e08a4c89d373cc79e8 (patch)
tree6a28feda2a62ec88e889593d7fbf3ae950659e35 /internal/command
parent701ebca0b5d4a8451afe677c3bdb19cc92a5a2f0 (diff)
downloadgitlab-shell-87402ed127d9855b8123e5e08a4c89d373cc79e8.tar.gz
Generate and log correlation IDs
This will make it easier to tie an SSH access request to Rails API and Gitaly requests.
Diffstat (limited to 'internal/command')
-rw-r--r--internal/command/receivepack/gitalycall.go4
-rw-r--r--internal/command/receivepack/gitalycall_test.go1
-rw-r--r--internal/command/uploadarchive/gitalycall.go4
-rw-r--r--internal/command/uploadpack/gitalycall.go4
4 files changed, 4 insertions, 9 deletions
diff --git a/internal/command/receivepack/gitalycall.go b/internal/command/receivepack/gitalycall.go
index ffe0b6f..0754a3e 100644
--- a/internal/command/receivepack/gitalycall.go
+++ b/internal/command/receivepack/gitalycall.go
@@ -32,11 +32,9 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
}
return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
- ctx, cancel := context.WithCancel(ctx)
+ ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, request.GitProtocol)
defer cancel()
- gc.LogExecution(request.Repository, response, request.GitProtocol)
-
rw := c.ReadWriter
return client.ReceivePack(ctx, conn, rw.In, rw.Out, rw.ErrOut, request)
})
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index df922d9..8bee484 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -56,4 +56,5 @@ func TestReceivePack(t *testing.T) {
require.Contains(t, entries[1].Message, "remote_ip=127.0.0.1")
require.Contains(t, entries[1].Message, "gl_key_type=key")
require.Contains(t, entries[1].Message, "gl_key_id=123")
+ require.Contains(t, entries[1].Message, "correlation_id=")
}
diff --git a/internal/command/uploadarchive/gitalycall.go b/internal/command/uploadarchive/gitalycall.go
index 1b792cb..f17ee50 100644
--- a/internal/command/uploadarchive/gitalycall.go
+++ b/internal/command/uploadarchive/gitalycall.go
@@ -24,11 +24,9 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
request := &pb.SSHUploadArchiveRequest{Repository: &response.Gitaly.Repo}
return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
- ctx, cancel := context.WithCancel(ctx)
+ ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, "")
defer cancel()
- gc.LogExecution(request.Repository, response, "")
-
rw := c.ReadWriter
return client.UploadArchive(ctx, conn, rw.In, rw.Out, rw.ErrOut, request)
})
diff --git a/internal/command/uploadpack/gitalycall.go b/internal/command/uploadpack/gitalycall.go
index c15ef38..ba0fef2 100644
--- a/internal/command/uploadpack/gitalycall.go
+++ b/internal/command/uploadpack/gitalycall.go
@@ -29,11 +29,9 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
}
return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
- ctx, cancel := context.WithCancel(ctx)
+ ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, request.GitProtocol)
defer cancel()
- gc.LogExecution(request.Repository, response, request.GitProtocol)
-
rw := c.ReadWriter
return client.UploadPack(ctx, conn, rw.In, rw.Out, rw.ErrOut, request)
})