diff options
author | Paul Okstad <pokstad@gitlab.com> | 2020-01-09 05:44:34 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2020-01-09 05:44:34 +0300 |
commit | 77905f6da584a13b6e4e6440b3d1b545778a5c8c (patch) | |
tree | a80dcf1b4a8b7aa4bdfab6bc4b116b7642ebe910 | |
parent | f19a5f98e6d367684fd2c9fda1e8dd598f525ec3 (diff) |
Revert "Merge branch 'ps-log-pack-stat-on-clone' into 'master'"
This reverts commit 57f5c06e85935eb33b0b8a8188e83237234eda7d, reversing
changes made to afdd436d7eddd97854489151f1bd1e287908b371.
-rw-r--r-- | changelogs/unreleased/ps-log-pack-stat-on-clone.yml | 5 | ||||
-rw-r--r-- | internal/service/inspect/inspector.go | 48 | ||||
-rw-r--r-- | internal/service/inspect/inspector_test.go | 42 | ||||
-rw-r--r-- | internal/service/smarthttp/upload_pack.go | 5 | ||||
-rw-r--r-- | internal/service/ssh/upload_pack.go | 6 |
5 files changed, 0 insertions, 106 deletions
diff --git a/changelogs/unreleased/ps-log-pack-stat-on-clone.yml b/changelogs/unreleased/ps-log-pack-stat-on-clone.yml deleted file mode 100644 index 38ef187dc..000000000 --- a/changelogs/unreleased/ps-log-pack-stat-on-clone.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Log statistics of pack re-use on clone and fetch -merge_request: 1699 -author: -type: other diff --git a/internal/service/inspect/inspector.go b/internal/service/inspect/inspector.go deleted file mode 100644 index 2abdfe60e..000000000 --- a/internal/service/inspect/inspector.go +++ /dev/null @@ -1,48 +0,0 @@ -package inspect - -import ( - "bytes" - "context" - "io" - "io/ioutil" - - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" - "gitlab.com/gitlab-org/gitaly/internal/git/pktline" - "gitlab.com/gitlab-org/gitaly/internal/helper/text" -) - -// Write returns Writer that will feed 'action' with data on each write to it. -func Write(writer io.Writer, action func(reader io.Reader)) io.Writer { - pr, pw := io.Pipe() - multiOut := io.MultiWriter(pw, writer) - - go func() { - defer func() { - io.Copy(ioutil.Discard, pr) - pw.Close() - }() - - action(pr) - }() - - return multiOut -} - -// LogPackInfoStatistic inspect data stream for the informational messages -// and logs info about pack file usage. -func LogPackInfoStatistic(ctx context.Context) func(reader io.Reader) { - return func(reader io.Reader) { - logger := ctxlogrus.Extract(ctx) - - scanner := pktline.NewScanner(reader) - for scanner.Scan() { - pktData := pktline.Data(scanner.Bytes()) - if !bytes.HasPrefix(pktData, []byte("\x02Total ")) { - continue - } - - logger.WithField("pack.stat", text.ChompBytes(pktData[1:])).Info("pack file compression statistic") - } - // we are not interested in scanner.Err() - } -} diff --git a/internal/service/inspect/inspector_test.go b/internal/service/inspect/inspector_test.go deleted file mode 100644 index a2d6855b2..000000000 --- a/internal/service/inspect/inspector_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package inspect - -import ( - "bytes" - "context" - "io" - "io/ioutil" - "strings" - "testing" - - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" - "github.com/sirupsen/logrus" - "github.com/stretchr/testify/require" -) - -func TestWrite(t *testing.T) { - dest := &bytes.Buffer{} - writer := Write(dest, func(reader io.Reader) { - data, err := ioutil.ReadAll(reader) - require.NoError(t, err) - require.Equal(t, data, "test\x02data") - }) - - _, err := io.Copy(writer, strings.NewReader("test\x02data")) - require.NoError(t, err) -} - -func TestLogPackInfoStatistic(t *testing.T) { - dest := &bytes.Buffer{} - log := &logrus.Logger{ - Out: dest, - Formatter: new(logrus.JSONFormatter), - Level: logrus.InfoLevel, - } - ctx := ctxlogrus.ToContext(context.Background(), log.WithField("test", "logging")) - - logging := LogPackInfoStatistic(ctx) - logging(strings.NewReader("0038\x41ACK 1e292f8fedd741b75372e19097c76d327140c312 ready\n0035\x02Total 1044 (delta 519), reused 1035 (delta 512)\n0038\x41ACK 1e292f8fedd741b75372e19097c76d327140c312 ready\n0000\x01")) - - require.Contains(t, dest.String(), "Total 1044 (delta 519), reused 1035 (delta 512)") - require.NotContains(t, dest.String(), "ACK 1e292f8fedd741b75372e19097c76d327140c312") -} diff --git a/internal/service/smarthttp/upload_pack.go b/internal/service/smarthttp/upload_pack.go index 8655e0924..4bb8dc327 100644 --- a/internal/service/smarthttp/upload_pack.go +++ b/internal/service/smarthttp/upload_pack.go @@ -11,7 +11,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" - "gitlab.com/gitlab-org/gitaly/internal/service/inspect" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" @@ -66,10 +65,6 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS return stream.Send(&gitalypb.PostUploadPackResponse{Data: p}) }) - // TODO: it is first step of the https://gitlab.com/gitlab-org/gitaly/issues/1519 - // needs to be removed after we get some statistics on this - stdout = inspect.Write(stdout, inspect.LogPackInfoStatistic(ctx)) - env := git.AddGitProtocolEnv(ctx, req, command.GitEnv) repoPath, err := helper.GetRepoPath(req.Repository) diff --git a/internal/service/ssh/upload_pack.go b/internal/service/ssh/upload_pack.go index e38e5c40f..3973a0955 100644 --- a/internal/service/ssh/upload_pack.go +++ b/internal/service/ssh/upload_pack.go @@ -8,7 +8,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/pktline" "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/service/inspect" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" ) @@ -38,14 +37,9 @@ func (s *server) sshUploadPack(stream gitalypb.SSHService_SSHUploadPackServer, r request, err := stream.Recv() return request.GetStdin(), err }) - stdout := streamio.NewWriter(func(p []byte) error { return stream.Send(&gitalypb.SSHUploadPackResponse{Stdout: p}) }) - // TODO: it is first step of the https://gitlab.com/gitlab-org/gitaly/issues/1519 - // needs to be removed after we get some statistics on this - stdout = inspect.Write(stdout, inspect.LogPackInfoStatistic(ctx)) - stderr := streamio.NewWriter(func(p []byte) error { return stream.Send(&gitalypb.SSHUploadPackResponse{Stderr: p}) }) |