Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-14 10:01:23 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-15 13:37:43 +0300
commit214d0ff9641c85d71de337f1f2f58d5c6c2dce7b (patch)
treedb1d3f619af3849029fe44f8ec259947b9f06bd5
parent2a006c4ee8b47887ddc1274dab9f645caf679c41 (diff)
log: Encapsulate our use of the `ctxlogrus` package
The `ctxlogrus` package is about to go away. Let's encapsulate it so that the transition will become easier for us at a later point.
-rw-r--r--STYLE.md2
-rw-r--r--internal/cache/diskcache.go5
-rw-r--r--internal/cache/keyer.go4
-rw-r--r--internal/command/command.go5
-rw-r--r--internal/command/command_test.go14
-rw-r--r--internal/git/bitmap.go4
-rw-r--r--internal/git/dirs.go4
-rw-r--r--internal/git/localrepo/refs.go4
-rw-r--r--internal/git/objectpool/disconnect.go4
-rw-r--r--internal/git/objectpool/fetch.go3
-rw-r--r--internal/git/protocol.go4
-rw-r--r--internal/git/ssh.go4
-rw-r--r--internal/git/stats/repository_info.go6
-rw-r--r--internal/git/stats/repository_info_test.go6
-rw-r--r--internal/gitaly/hook/postreceive.go6
-rw-r--r--internal/gitaly/hook/prereceive.go6
-rw-r--r--internal/gitaly/hook/update.go6
-rw-r--r--internal/gitaly/hook/updateref/update_with_hooks.go4
-rw-r--r--internal/gitaly/linguist/linguist.go4
-rw-r--r--internal/gitaly/repoutil/custom_hooks.go6
-rw-r--r--internal/gitaly/repoutil/lock.go4
-rw-r--r--internal/gitaly/repoutil/remove.go4
-rw-r--r--internal/gitaly/service/cleanup/cleaner.go10
-rw-r--r--internal/gitaly/service/commit/commits_helper.go10
-rw-r--r--internal/gitaly/service/commit/count_commits.go6
-rw-r--r--internal/gitaly/service/commit/get_tree_entries.go6
-rw-r--r--internal/gitaly/service/commit/isancestor.go6
-rw-r--r--internal/gitaly/service/commit/list_files.go6
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts.go5
-rw-r--r--internal/gitaly/service/diff/commit_delta.go6
-rw-r--r--internal/gitaly/service/diff/commit_diff.go6
-rw-r--r--internal/gitaly/service/objectpool/get.go4
-rw-r--r--internal/gitaly/service/operations/apply_patch.go4
-rw-r--r--internal/gitaly/service/operations/commit_files.go6
-rw-r--r--internal/gitaly/service/operations/merge_to_ref.go4
-rw-r--r--internal/gitaly/service/operations/submodules.go5
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes.go4
-rw-r--r--internal/gitaly/service/repository/archive.go3
-rw-r--r--internal/gitaly/service/repository/fetch.go4
-rw-r--r--internal/gitaly/service/repository/rename.go6
-rw-r--r--internal/gitaly/service/repository/replicate.go4
-rw-r--r--internal/gitaly/service/repository/snapshot.go4
-rw-r--r--internal/gitaly/service/server/disk_stats.go4
-rw-r--r--internal/gitaly/service/server/info.go4
-rw-r--r--internal/gitaly/service/smarthttp/cache.go6
-rw-r--r--internal/gitaly/service/smarthttp/inforefs.go6
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack.go6
-rw-r--r--internal/gitaly/service/smarthttp/upload_pack.go6
-rw-r--r--internal/gitaly/service/ssh/receive_pack.go8
-rw-r--r--internal/gitaly/service/ssh/upload_pack.go12
-rw-r--r--internal/gitaly/storage/storagemgr/transaction_manager.go6
-rw-r--r--internal/gitaly/transaction/manager.go3
-rw-r--r--internal/helper/perm/fix_permissions.go4
-rw-r--r--internal/log/logger.go26
-rw-r--r--internal/log/middleware.go11
-rw-r--r--internal/praefect/coordinator.go29
-rw-r--r--internal/praefect/datastore/storage_provider_test.go14
-rw-r--r--internal/praefect/nodes/per_repository.go4
-rw-r--r--internal/praefect/nodes/per_repository_test.go4
-rw-r--r--internal/praefect/remove_repository.go4
-rw-r--r--internal/praefect/router.go4
-rw-r--r--internal/praefect/service/server/info.go4
-rw-r--r--internal/praefect/transactions/manager.go3
-rw-r--r--internal/tempdir/tempdir.go4
-rw-r--r--internal/testhelper/testhelper.go9
65 files changed, 202 insertions, 197 deletions
diff --git a/STYLE.md b/STYLE.md
index 594a65728..d12142c8b 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -239,7 +239,7 @@ package transaction
type Manager struct {}
func (m Manager) StartTransaction(ctx context.Context) {
- ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"component": "transaction.Manager",
}).Debug("StartTransaction")
}
diff --git a/internal/cache/diskcache.go b/internal/cache/diskcache.go
index d4bb1fb89..a1b2da590 100644
--- a/internal/cache/diskcache.go
+++ b/internal/cache/diskcache.go
@@ -8,7 +8,6 @@ import (
"path/filepath"
"sync"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/gitaly/v16/internal/dontpanic"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
@@ -243,7 +242,7 @@ func (c *DiskCache) GetStream(ctx context.Context, repo *gitalypb.Repository, re
return nil, err
}
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithField("stream_path", respPath).
Info("getting stream")
@@ -282,7 +281,7 @@ func (c *DiskCache) PutStream(ctx context.Context, repo *gitalypb.Repository, re
return err
}
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithField("stream_path", reqPath).
Info("putting stream")
diff --git a/internal/cache/keyer.go b/internal/cache/keyer.go
index db9620b23..13588ebb9 100644
--- a/internal/cache/keyer.go
+++ b/internal/cache/keyer.go
@@ -14,10 +14,10 @@ import (
"time"
"github.com/google/uuid"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/version"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -92,7 +92,7 @@ func (keyer leaseKeyer) updateLatest(ctx context.Context, repo *gitalypb.Reposit
return "", err
}
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithField("diskcache", nextGenID).
Infof("diskcache state change")
diff --git a/internal/command/command.go b/internal/command/command.go
index 53bf24298..edcaa3c8b 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -13,7 +13,6 @@ import (
"syscall"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
grpcmwtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
@@ -208,7 +207,7 @@ func New(ctx context.Context, nameAndArgs []string, opts ...Option) (*Command, e
logPid := -1
defer func() {
- ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"pid": logPid,
"path": nameAndArgs[0],
"args": nameAndArgs[1:],
@@ -470,7 +469,7 @@ func (c *Command) logProcessComplete() {
fields["command.cgroup_path"] = c.cgroupPath
}
- entry := ctxlogrus.Extract(ctx).WithFields(fields)
+ entry := log.FromContext(ctx).WithFields(fields)
rusage, ok := cmd.ProcessState.SysUsage().(*syscall.Rusage)
if ok {
diff --git a/internal/command/command_test.go b/internal/command/command_test.go
index ce26ed88b..081e5ab1a 100644
--- a/internal/command/command_test.go
+++ b/internal/command/command_test.go
@@ -16,13 +16,13 @@ import (
"testing"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/cgroups"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -352,7 +352,7 @@ func TestCommand_stderrLogging(t *testing.T) {
logger, hook := test.NewNullLogger()
ctx := testhelper.Context(t)
- ctx = ctxlogrus.ToContext(ctx, logrus.NewEntry(logger))
+ ctx = log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx)
var stdout bytes.Buffer
cmd, err := New(ctx, []string{binaryPath}, WithStdout(&stdout))
@@ -376,7 +376,7 @@ func TestCommand_stderrLoggingTruncation(t *testing.T) {
logger, hook := test.NewNullLogger()
ctx := testhelper.Context(t)
- ctx = ctxlogrus.ToContext(ctx, logrus.NewEntry(logger))
+ ctx = log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx)
var stdout bytes.Buffer
cmd, err := New(ctx, []string{binaryPath}, WithStdout(&stdout))
@@ -397,7 +397,7 @@ func TestCommand_stderrLoggingWithNulBytes(t *testing.T) {
logger, hook := test.NewNullLogger()
ctx := testhelper.Context(t)
- ctx = ctxlogrus.ToContext(ctx, logrus.NewEntry(logger))
+ ctx = log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx)
var stdout bytes.Buffer
cmd, err := New(ctx, []string{binaryPath}, WithStdout(&stdout))
@@ -420,7 +420,7 @@ func TestCommand_stderrLoggingLongLine(t *testing.T) {
logger, hook := test.NewNullLogger()
ctx := testhelper.Context(t)
- ctx = ctxlogrus.ToContext(ctx, logrus.NewEntry(logger))
+ ctx = log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx)
var stdout bytes.Buffer
cmd, err := New(ctx, []string{binaryPath}, WithStdout(&stdout))
@@ -467,7 +467,7 @@ func TestCommand_stderrLoggingMaxBytes(t *testing.T) {
logger, hook := test.NewNullLogger()
ctx := testhelper.Context(t)
- ctx = ctxlogrus.ToContext(ctx, logrus.NewEntry(logger))
+ ctx = log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx)
var stdout bytes.Buffer
cmd, err := New(ctx, []string{binaryPath}, WithStdout(&stdout))
@@ -493,7 +493,7 @@ func TestCommand_logMessage(t *testing.T) {
logger, hook := test.NewNullLogger()
logger.SetLevel(logrus.DebugLevel)
- ctx := ctxlogrus.ToContext(testhelper.Context(t), logrus.NewEntry(logger))
+ ctx := log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(testhelper.Context(t))
cmd, err := New(ctx, []string{"echo", "hello world"},
WithCgroup(mockCgroupManager{
diff --git a/internal/git/bitmap.go b/internal/git/bitmap.go
index d467422dd..2a78a1bde 100644
--- a/internal/git/bitmap.go
+++ b/internal/git/bitmap.go
@@ -6,12 +6,12 @@ import (
"strconv"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
grpcmwtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/packfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
var badBitmapRequestCount = promauto.NewCounterVec(
@@ -26,7 +26,7 @@ var badBitmapRequestCount = promauto.NewCounterVec(
// repoPath, and if it finds any, it logs a warning. This is to help us
// investigate https://gitlab.com/gitlab-org/gitaly/issues/1728.
func WarnIfTooManyBitmaps(ctx context.Context, locator storage.Locator, storageName, repoPath string) {
- logEntry := ctxlogrus.Extract(ctx)
+ logEntry := log.FromContext(ctx)
storageRoot, err := locator.GetStorageByName(storageName)
if err != nil {
diff --git a/internal/git/dirs.go b/internal/git/dirs.go
index 16444ed5a..e50f9f999 100644
--- a/internal/git/dirs.go
+++ b/internal/git/dirs.go
@@ -7,7 +7,7 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
// alternateOutsideStorageError is returned when an alternates file contains an
@@ -43,7 +43,7 @@ func AlternateObjectDirectories(ctx context.Context, storageRoot, repoPath strin
}
func altObjectDirs(ctx context.Context, storagePrefix, objDir string, depth int) ([]string, error) {
- logEntry := ctxlogrus.Extract(ctx)
+ logEntry := log.FromContext(ctx)
const maxAlternatesDepth = 5 // Taken from https://github.com/git/git/blob/v2.23.0/sha1-file.c#L575
if depth > maxAlternatesDepth {
logEntry.WithField("objdir", objDir).Warn("ignoring deeply nested alternate object directory")
diff --git a/internal/git/localrepo/refs.go b/internal/git/localrepo/refs.go
index 9fb4c5aa6..fe38e93c3 100644
--- a/internal/git/localrepo/refs.go
+++ b/internal/git/localrepo/refs.go
@@ -10,10 +10,10 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
)
@@ -164,7 +164,7 @@ func (repo *Repo) setDefaultBranchWithTransaction(ctx context.Context, txManager
}
defer func() {
if err := lockingFileWriter.Close(); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("closing locked HEAD: %w", err)
+ log.FromContext(ctx).WithError(err).Error("closing locked HEAD: %w", err)
}
}()
diff --git a/internal/git/objectpool/disconnect.go b/internal/git/objectpool/disconnect.go
index 9ea36b966..1f1fcb9ea 100644
--- a/internal/git/objectpool/disconnect.go
+++ b/internal/git/objectpool/disconnect.go
@@ -10,13 +10,13 @@ import (
"strings"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/voting"
)
@@ -210,7 +210,7 @@ func removeAlternatesIfOk(ctx context.Context, repo *localrepo.Repo, altFile, ba
return
}
- logger := ctxlogrus.Extract(ctx)
+ logger := log.FromContext(ctx)
// If we would do a os.Rename, and then someone else comes and clobbers
// our file, it's gone forever. This trick with os.Link and os.Rename
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index cae02d4a0..8470ec44d 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -8,7 +8,6 @@ import (
"io"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
@@ -25,7 +24,7 @@ var objectPoolRefspec = fmt.Sprintf("+refs/*:%s/*", git.ObjectPoolRefNamespace)
// FetchFromOrigin initializes the pool and fetches the objects from its origin repository
func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo) error {
- logger := ctxlogrus.Extract(ctx)
+ logger := log.FromContext(ctx)
if !o.Exists() {
return structerr.NewInvalidArgument("object pool does not exist")
diff --git a/internal/git/protocol.go b/internal/git/protocol.go
index e72053aa6..d03a3a5a8 100644
--- a/internal/git/protocol.go
+++ b/internal/git/protocol.go
@@ -5,11 +5,11 @@ import (
"fmt"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
grpcmwtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
const (
@@ -50,7 +50,7 @@ func gitProtocolEnv(ctx context.Context, req RequestWithGitProtocol) []string {
case "":
protocol = "v0"
default:
- ctxlogrus.Extract(ctx).WithField("git_protocol", gp).Warn("invalid git protocol requested")
+ log.FromContext(ctx).WithField("git_protocol", gp).Warn("invalid git protocol requested")
protocol = "invalid"
}
diff --git a/internal/git/ssh.go b/internal/git/ssh.go
index fc7ac31f0..25077b634 100644
--- a/internal/git/ssh.go
+++ b/internal/git/ssh.go
@@ -7,8 +7,8 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
// BuildSSHInvocation builds a command line to invoke SSH with the provided key and known hosts.
@@ -26,7 +26,7 @@ func BuildSSHInvocation(ctx context.Context, sshKey, knownHosts string) (string,
cleanup := func() {
if err := os.RemoveAll(tmpDir); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed to remove tmp directory with ssh key/config")
+ log.FromContext(ctx).WithError(err).Error("failed to remove tmp directory with ssh key/config")
}
}
diff --git a/internal/git/stats/repository_info.go b/internal/git/stats/repository_info.go
index eede939e9..047745c07 100644
--- a/internal/git/stats/repository_info.go
+++ b/internal/git/stats/repository_info.go
@@ -14,9 +14,9 @@ import (
"strings"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
const (
@@ -120,7 +120,7 @@ func LooseObjects(repo *localrepo.Repo) (uint64, error) {
func LogRepositoryInfo(ctx context.Context, repo *localrepo.Repo) {
repoInfo, err := RepositoryInfoForRepository(repo)
if err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Warn("failed reading repository info")
+ log.FromContext(ctx).WithError(err).Warn("failed reading repository info")
} else {
repoInfo.Log(ctx)
}
@@ -184,7 +184,7 @@ func RepositoryInfoForRepository(repo *localrepo.Repo) (RepositoryInfo, error) {
// Log logs the repository information as a structured entry under the `repository_info` field.
func (i RepositoryInfo) Log(ctx context.Context) {
- ctxlogrus.Extract(ctx).WithField("repository_info", i).Info("repository info")
+ log.FromContext(ctx).WithField("repository_info", i).Info("repository info")
}
// ReferencesInfo contains information about references.
diff --git a/internal/git/stats/repository_info_test.go b/internal/git/stats/repository_info_test.go
index a904ae4de..b99862a44 100644
--- a/internal/git/stats/repository_info_test.go
+++ b/internal/git/stats/repository_info_test.go
@@ -11,7 +11,6 @@ import (
"testing"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/require"
@@ -19,6 +18,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -103,7 +103,7 @@ func TestLogObjectInfo(t *testing.T) {
t.Parallel()
logger, hook := test.NewNullLogger()
- ctx := ctxlogrus.ToContext(ctx, logger.WithField("test", "logging"))
+ ctx := log.FromLogrusEntry(logger.WithField("test", "logging")).ToContext(ctx)
_, repoPath1 := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
@@ -152,7 +152,7 @@ func TestLogObjectInfo(t *testing.T) {
t.Parallel()
logger, hook := test.NewNullLogger()
- ctx := ctxlogrus.ToContext(ctx, logger.WithField("test", "logging"))
+ ctx := log.FromLogrusEntry(logger.WithField("test", "logging")).ToContext(ctx)
repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
diff --git a/internal/gitaly/hook/postreceive.go b/internal/gitaly/hook/postreceive.go
index f1d11f13d..6429c3329 100644
--- a/internal/gitaly/hook/postreceive.go
+++ b/internal/gitaly/hook/postreceive.go
@@ -9,9 +9,9 @@ import (
"math"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitlab"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -119,12 +119,12 @@ func (m *GitLabHookManager) PostReceiveHook(ctx context.Context, repo *gitalypb.
if isPrimary(payload) {
if err := m.postReceiveHook(ctx, payload, repo, pushOptions, env, changes, stdout, stderr); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Warn("stopping transaction because post-receive hook failed")
+ log.FromContext(ctx).WithError(err).Warn("stopping transaction because post-receive hook failed")
// If the post-receive hook declines the push, then we need to stop any
// secondaries voting on the transaction.
if err := m.stopTransaction(ctx, payload); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed stopping transaction in post-receive hook")
+ log.FromContext(ctx).WithError(err).Error("failed stopping transaction in post-receive hook")
}
return err
diff --git a/internal/gitaly/hook/prereceive.go b/internal/gitaly/hook/prereceive.go
index 46cd18ada..cf63e95d0 100644
--- a/internal/gitaly/hook/prereceive.go
+++ b/internal/gitaly/hook/prereceive.go
@@ -9,10 +9,10 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitlab"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/env"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -76,12 +76,12 @@ func (m *GitLabHookManager) PreReceiveHook(ctx context.Context, repo *gitalypb.R
// Only the primary should execute hooks and increment reference counters.
if isPrimary(payload) {
if err := m.preReceiveHook(ctx, payload, repo, pushOptions, env, changes, stdout, stderr); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Warn("stopping transaction because pre-receive hook failed")
+ log.FromContext(ctx).WithError(err).Warn("stopping transaction because pre-receive hook failed")
// If the pre-receive hook declines the push, then we need to stop any
// secondaries voting on the transaction.
if err := m.stopTransaction(ctx, payload); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed stopping transaction in pre-receive hook")
+ log.FromContext(ctx).WithError(err).Error("failed stopping transaction in pre-receive hook")
}
return err
diff --git a/internal/gitaly/hook/update.go b/internal/gitaly/hook/update.go
index be5e38188..64b337ce1 100644
--- a/internal/gitaly/hook/update.go
+++ b/internal/gitaly/hook/update.go
@@ -5,8 +5,8 @@ import (
"fmt"
"io"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -20,12 +20,12 @@ func (m *GitLabHookManager) UpdateHook(ctx context.Context, repo *gitalypb.Repos
if isPrimary(payload) {
if err := m.updateHook(ctx, payload, repo, ref, oldValue, newValue, env, stdout, stderr); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Warn("stopping transaction because update hook failed")
+ log.FromContext(ctx).WithError(err).Warn("stopping transaction because update hook failed")
// If the update hook declines the push, then we need
// to stop any secondaries voting on the transaction.
if err := m.stopTransaction(ctx, payload); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed stopping transaction in update hook")
+ log.FromContext(ctx).WithError(err).Error("failed stopping transaction in update hook")
}
return err
diff --git a/internal/gitaly/hook/updateref/update_with_hooks.go b/internal/gitaly/hook/updateref/update_with_hooks.go
index 796f042f8..a1fb7175a 100644
--- a/internal/gitaly/hook/updateref/update_with_hooks.go
+++ b/internal/gitaly/hook/updateref/update_with_hooks.go
@@ -7,7 +7,6 @@ import (
"fmt"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
@@ -17,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/txinfo"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -303,7 +303,7 @@ func (u *UpdaterWithHooks) UpdateReference(
if errors.As(err, &customHookErr) {
// Only log the error when we've got a custom-hook error, but otherwise
// ignore it and continue with whatever we have been doing.
- ctxlogrus.Extract(ctx).WithError(err).Error("custom post-receive hook returned an error")
+ log.FromContext(ctx).WithError(err).Error("custom post-receive hook returned an error")
} else {
return fmt.Errorf("running post-receive hooks: %w", wrapHookError(err, git.PostReceiveHook, stdout.String(), stderr.String()))
}
diff --git a/internal/gitaly/linguist/linguist.go b/internal/gitaly/linguist/linguist.go
index e5219b1e0..e5a8ee52e 100644
--- a/internal/gitaly/linguist/linguist.go
+++ b/internal/gitaly/linguist/linguist.go
@@ -7,7 +7,6 @@ import (
"io"
"github.com/go-enry/go-enry/v2"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
@@ -15,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gitpipe"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
// ByteCountPerLanguage represents a counter value (bytes) per language.
@@ -51,7 +51,7 @@ func Color(language string) string {
func (inst *Instance) Stats(ctx context.Context, commitID string) (ByteCountPerLanguage, error) {
stats, err := initLanguageStats(inst.repo)
if err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Info("linguist load from cache")
+ log.FromContext(ctx).WithError(err).Info("linguist load from cache")
}
if stats.CommitID == commitID {
return stats.Totals, nil
diff --git a/internal/gitaly/repoutil/custom_hooks.go b/internal/gitaly/repoutil/custom_hooks.go
index b355ff924..eb26cadfe 100644
--- a/internal/gitaly/repoutil/custom_hooks.go
+++ b/internal/gitaly/repoutil/custom_hooks.go
@@ -12,12 +12,12 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/archive"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/tempdir"
@@ -123,7 +123,7 @@ func SetCustomHooks(
// future modifications to the repository's hooks will be prevented. If
// this occurs, the `.lock` file will have to be manually removed.
if err := hooksLock.Unlock(); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed to unlock hooks")
+ log.FromContext(ctx).WithError(err).Error("failed to unlock hooks")
}
}()
@@ -138,7 +138,7 @@ func SetCustomHooks(
defer func() {
if err := os.RemoveAll(tmpDir.Path()); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Warn("failed to remove temporary directory")
+ log.FromContext(ctx).WithError(err).Warn("failed to remove temporary directory")
}
}()
diff --git a/internal/gitaly/repoutil/lock.go b/internal/gitaly/repoutil/lock.go
index 097374e61..3bbf30716 100644
--- a/internal/gitaly/repoutil/lock.go
+++ b/internal/gitaly/repoutil/lock.go
@@ -5,9 +5,9 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
)
@@ -41,7 +41,7 @@ func Lock(ctx context.Context, locator storage.Locator, repository storage.Repos
unlock := func() {
if err := locker.Close(); err != nil {
- ctxlogrus.Extract(ctx).Error("closing repository locker: %w", err)
+ log.FromContext(ctx).Error("closing repository locker: %w", err)
}
}
diff --git a/internal/gitaly/repoutil/remove.go b/internal/gitaly/repoutil/remove.go
index eb702d742..721be1ff4 100644
--- a/internal/gitaly/repoutil/remove.go
+++ b/internal/gitaly/repoutil/remove.go
@@ -7,11 +7,11 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage/counter"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/txinfo"
@@ -100,7 +100,7 @@ func remove(
defer func() {
if err := removeAll(destDir); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed removing repository from temporary directory")
+ log.FromContext(ctx).WithError(err).Error("failed removing repository from temporary directory")
}
}()
diff --git a/internal/gitaly/service/cleanup/cleaner.go b/internal/gitaly/service/cleanup/cleaner.go
index 994cf80cc..744a8fe4a 100644
--- a/internal/gitaly/service/cleanup/cleaner.go
+++ b/internal/gitaly/service/cleanup/cleaner.go
@@ -7,10 +7,10 @@ import (
"io"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
// forEachFunc can be called for every entry in the filter-repo or BFG object
@@ -120,7 +120,7 @@ func (c *cleaner) processEntry(ctx context.Context, updater *updateref.Updater,
return nil
}
- ctxlogrus.Extract(c.ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"sha": oldSHA,
"refs": refs,
}).Info("removing internal references")
@@ -162,7 +162,7 @@ func buildLookupTable(ctx context.Context, repo git.RepositoryExecutor) (map[str
return nil, err
}
- logger := ctxlogrus.Extract(ctx)
+ logger := log.FromContext(ctx)
out := make(map[string][]git.ReferenceName)
scanner := bufio.NewScanner(cmd)
@@ -171,7 +171,7 @@ func buildLookupTable(ctx context.Context, repo git.RepositoryExecutor) (map[str
objectName, refName, ok := strings.Cut(line, " ")
if !ok {
- logger.WithFields(log.Fields{"line": line}).Warn("failed to parse git refs")
+ logger.WithFields(logrus.Fields{"line": line}).Warn("failed to parse git refs")
return nil, fmt.Errorf("failed to parse git refs")
}
diff --git a/internal/gitaly/service/commit/commits_helper.go b/internal/gitaly/service/commit/commits_helper.go
index c0ec26d78..50587337c 100644
--- a/internal/gitaly/service/commit/commits_helper.go
+++ b/internal/gitaly/service/commit/commits_helper.go
@@ -3,10 +3,10 @@ package commit
import (
"context"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/log"
+ gitlog "gitlab.com/gitlab-org/gitaly/v16/internal/git/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/chunk"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -24,12 +24,12 @@ func (s *server) sendCommits(
revisions[i] = git.Revision(revision)
}
- cmd, err := log.GitLogCommand(ctx, s.gitCmdFactory, repo, revisions, paths, options, extraArgs...)
+ cmd, err := gitlog.GitLogCommand(ctx, s.gitCmdFactory, repo, revisions, paths, options, extraArgs...)
if err != nil {
return err
}
- logParser, cancel, err := log.NewParser(ctx, s.catfileCache, repo, cmd)
+ logParser, cancel, err := gitlog.NewParser(ctx, s.catfileCache, repo, cmd)
if err != nil {
return err
}
@@ -53,7 +53,7 @@ func (s *server) sendCommits(
if err := cmd.Wait(); err != nil {
// We expect this error to be caused by non-existing references. In that
// case, we just log the error and send no commits to the `sender`.
- ctxlogrus.Extract(ctx).WithError(err).Info("ignoring git-log error")
+ log.FromContext(ctx).WithError(err).Info("ignoring git-log error")
}
return nil
diff --git a/internal/gitaly/service/commit/count_commits.go b/internal/gitaly/service/commit/count_commits.go
index 7332df2d8..629a811ff 100644
--- a/internal/gitaly/service/commit/count_commits.go
+++ b/internal/gitaly/service/commit/count_commits.go
@@ -8,9 +8,9 @@ import (
"strconv"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -53,11 +53,11 @@ func (s *server) CountCommits(ctx context.Context, in *gitalypb.CountCommitsRequ
var count int64
countStr, readAllErr := io.ReadAll(cmd)
if readAllErr != nil {
- ctxlogrus.Extract(ctx).WithError(err).Info("ignoring git rev-list error")
+ log.FromContext(ctx).WithError(err).Info("ignoring git rev-list error")
}
if err := cmd.Wait(); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Info("ignoring git rev-list error")
+ log.FromContext(ctx).WithError(err).Info("ignoring git rev-list error")
count = 0
} else if readAllErr == nil {
var err error
diff --git a/internal/gitaly/service/commit/get_tree_entries.go b/internal/gitaly/service/commit/get_tree_entries.go
index 13bcadcce..5338764ec 100644
--- a/internal/gitaly/service/commit/get_tree_entries.go
+++ b/internal/gitaly/service/commit/get_tree_entries.go
@@ -9,13 +9,13 @@ import (
"path/filepath"
"sort"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/chunk"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"google.golang.org/protobuf/proto"
@@ -329,7 +329,7 @@ func (c *treeEntriesSender) SetPaginationCursor(cursor string) {
}
func (s *server) GetTreeEntries(in *gitalypb.GetTreeEntriesRequest, stream gitalypb.CommitService_GetTreeEntriesServer) error {
- ctxlogrus.Extract(stream.Context()).WithFields(log.Fields{
+ log.FromContext(stream.Context()).WithFields(logrus.Fields{
"Revision": in.Revision,
"Path": in.Path,
}).Debug("GetTreeEntries")
diff --git a/internal/gitaly/service/commit/isancestor.go b/internal/gitaly/service/commit/isancestor.go
index 9b2fc2fa9..fa87fe653 100644
--- a/internal/gitaly/service/commit/isancestor.go
+++ b/internal/gitaly/service/commit/isancestor.go
@@ -4,10 +4,10 @@ import (
"context"
"errors"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -36,7 +36,7 @@ func (s *server) CommitIsAncestor(ctx context.Context, in *gitalypb.CommitIsAnce
// Assumes that `path`, `ancestorID` and `childID` are populated :trollface:
func (s *server) commitIsAncestorName(ctx context.Context, repo *gitalypb.Repository, ancestorID, childID string) (bool, error) {
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"ancestorSha": ancestorID,
"childSha": childID,
}).Debug("commitIsAncestor")
diff --git a/internal/gitaly/service/commit/list_files.go b/internal/gitaly/service/commit/list_files.go
index aba98f4e7..09402659d 100644
--- a/internal/gitaly/service/commit/list_files.go
+++ b/internal/gitaly/service/commit/list_files.go
@@ -4,19 +4,19 @@ import (
"fmt"
"io"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/chunk"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"google.golang.org/protobuf/proto"
)
func (s *server) ListFiles(in *gitalypb.ListFilesRequest, stream gitalypb.CommitService_ListFilesServer) error {
- ctxlogrus.Extract(stream.Context()).WithFields(log.Fields{
+ log.FromContext(stream.Context()).WithFields(logrus.Fields{
"Revision": in.GetRevision(),
}).Debug("ListFiles")
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts.go b/internal/gitaly/service/conflicts/resolve_conflicts.go
index 493a2a24e..57e7fdd06 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts.go
@@ -12,12 +12,12 @@ import (
"strings"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/conflict"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/remoterepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -57,8 +57,7 @@ func handleResolveConflictsErr(err error, stream gitalypb.ConflictsService_Resol
// log the error since the interceptor won't catch this
// error due to the unique way the RPC is defined to
// handle resolution errors
- ctxlogrus.
- Extract(stream.Context()).
+ log.FromContext(stream.Context()).
WithError(err).
Error("ResolveConflicts: unable to resolve conflict")
return stream.SendAndClose(&gitalypb.ResolveConflictsResponse{
diff --git a/internal/gitaly/service/diff/commit_delta.go b/internal/gitaly/service/diff/commit_delta.go
index 131ec5798..1672854d7 100644
--- a/internal/gitaly/service/diff/commit_delta.go
+++ b/internal/gitaly/service/diff/commit_delta.go
@@ -3,10 +3,10 @@ package diff
import (
"fmt"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/diff"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -14,7 +14,7 @@ import (
func (s *server) CommitDelta(in *gitalypb.CommitDeltaRequest, stream gitalypb.DiffService_CommitDeltaServer) error {
ctx := stream.Context()
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"LeftCommitId": in.LeftCommitId,
"RightCommitId": in.RightCommitId,
"Paths": logPaths(in.Paths),
diff --git a/internal/gitaly/service/diff/commit_diff.go b/internal/gitaly/service/diff/commit_diff.go
index a5ae472d8..c80876462 100644
--- a/internal/gitaly/service/diff/commit_diff.go
+++ b/internal/gitaly/service/diff/commit_diff.go
@@ -3,10 +3,10 @@ package diff
import (
"fmt"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/diff"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -14,7 +14,7 @@ import (
func (s *server) CommitDiff(in *gitalypb.CommitDiffRequest, stream gitalypb.DiffService_CommitDiffServer) error {
ctx := stream.Context()
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"LeftCommitId": in.LeftCommitId,
"RightCommitId": in.RightCommitId,
"Paths": logPaths(in.Paths),
diff --git a/internal/gitaly/service/objectpool/get.go b/internal/gitaly/service/objectpool/get.go
index 2aa1bf90c..158e09368 100644
--- a/internal/gitaly/service/objectpool/get.go
+++ b/internal/gitaly/service/objectpool/get.go
@@ -3,8 +3,8 @@ package objectpool
import (
"context"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/objectpool"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -19,7 +19,7 @@ func (s *server) GetObjectPool(ctx context.Context, in *gitalypb.GetObjectPoolRe
objectPool, err := objectpool.FromRepo(s.locator, s.gitCmdFactory, s.catfileCache, s.txManager, s.housekeepingManager, repo)
if err != nil {
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithError(err).
WithField("storage", repository.GetStorageName()).
WithField("relative_path", repository.GetRelativePath()).
diff --git a/internal/gitaly/service/operations/apply_patch.go b/internal/gitaly/service/operations/apply_patch.go
index aa38e378d..e81daa98a 100644
--- a/internal/gitaly/service/operations/apply_patch.go
+++ b/internal/gitaly/service/operations/apply_patch.go
@@ -9,12 +9,12 @@ import (
"path/filepath"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v16/streamio"
@@ -109,7 +109,7 @@ func (s *Server) userApplyPatch(ctx context.Context, header *gitalypb.UserApplyP
worktreeName := filepath.Base(worktreePath)
if err := s.removeWorktree(ctx, header.Repository, worktreeName); err != nil {
- ctxlogrus.Extract(ctx).WithField("worktree_name", worktreeName).WithError(err).Error("failed to remove worktree")
+ log.FromContext(ctx).WithField("worktree_name", worktreeName).WithError(err).Error("failed to remove worktree")
}
}()
diff --git a/internal/gitaly/service/operations/commit_files.go b/internal/gitaly/service/operations/commit_files.go
index c6ed6f5dc..b14a6b9cc 100644
--- a/internal/gitaly/service/operations/commit_files.go
+++ b/internal/gitaly/service/operations/commit_files.go
@@ -10,13 +10,13 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/remoterepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -144,7 +144,7 @@ func (s *Server) UserCommitFiles(stream gitalypb.OperationService_UserCommitFile
}
if err := s.userCommitFiles(ctx, header, stream, objectHash); err != nil {
- ctxlogrus.AddFields(ctx, logrus.Fields{
+ log.AddFields(ctx, logrus.Fields{
"repository_storage": header.Repository.StorageName,
"repository_relative_path": header.Repository.RelativePath,
"branch_name": header.BranchName,
@@ -154,7 +154,7 @@ func (s *Server) UserCommitFiles(stream gitalypb.OperationService_UserCommitFile
})
if startRepo := header.GetStartRepository(); startRepo != nil {
- ctxlogrus.AddFields(ctx, logrus.Fields{
+ log.AddFields(ctx, logrus.Fields{
"start_repository_storage": startRepo.StorageName,
"start_repository_relative_path": startRepo.RelativePath,
})
diff --git a/internal/gitaly/service/operations/merge_to_ref.go b/internal/gitaly/service/operations/merge_to_ref.go
index d04566c39..3a5e98780 100644
--- a/internal/gitaly/service/operations/merge_to_ref.go
+++ b/internal/gitaly/service/operations/merge_to_ref.go
@@ -6,10 +6,10 @@ import (
"fmt"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -105,7 +105,7 @@ func (s *Server) UserMergeToRef(ctx context.Context, request *gitalypb.UserMerge
false,
)
if err != nil {
- ctxlogrus.Extract(ctx).WithError(err).WithFields(
+ log.FromContext(ctx).WithError(err).WithFields(
logrus.Fields{
"source_sha": sourceOID,
"target_sha": oid,
diff --git a/internal/gitaly/service/operations/submodules.go b/internal/gitaly/service/operations/submodules.go
index 6ba4911bf..e999e7693 100644
--- a/internal/gitaly/service/operations/submodules.go
+++ b/internal/gitaly/service/operations/submodules.go
@@ -6,11 +6,11 @@ import (
"fmt"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -88,8 +88,7 @@ func (s *Server) UserUpdateSubmodule(ctx context.Context, req *gitalypb.UserUpda
resp = &gitalypb.UserUpdateSubmoduleResponse{
CommitError: legacyErrPrefixInvalidSubmodulePath,
}
- ctxlogrus.
- Extract(ctx).
+ log.FromContext(ctx).
WithError(err).
Error("UserUpdateSubmodule: git2go subcommand failure")
}
diff --git a/internal/gitaly/service/repository/apply_gitattributes.go b/internal/gitaly/service/repository/apply_gitattributes.go
index 131d961ee..e0095678e 100644
--- a/internal/gitaly/service/repository/apply_gitattributes.go
+++ b/internal/gitaly/service/repository/apply_gitattributes.go
@@ -8,12 +8,12 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/txinfo"
@@ -55,7 +55,7 @@ func (s *server) applyGitattributes(ctx context.Context, repo *localrepo.Repo, o
}
defer func() {
if err := locker.Close(); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("unlocking gitattributes")
+ log.FromContext(ctx).WithError(err).Error("unlocking gitattributes")
}
}()
diff --git a/internal/gitaly/service/repository/archive.go b/internal/gitaly/service/repository/archive.go
index 7254abd79..8992d0b42 100644
--- a/internal/gitaly/service/repository/archive.go
+++ b/internal/gitaly/service/repository/archive.go
@@ -9,7 +9,6 @@ import (
"os"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile"
@@ -83,7 +82,7 @@ func (s *server) GetArchive(in *gitalypb.GetArchiveRequest, stream gitalypb.Repo
return stream.Send(&gitalypb.GetArchiveResponse{Data: p})
})
- ctxlogrus.Extract(ctx).WithField("request_hash", requestHash(in)).Info("request details")
+ log.FromContext(ctx).WithField("request_hash", requestHash(in)).Info("request details")
return s.handleArchive(ctx, archiveParams{
writer: writer,
diff --git a/internal/gitaly/service/repository/fetch.go b/internal/gitaly/service/repository/fetch.go
index f449f9a4f..143c67006 100644
--- a/internal/gitaly/service/repository/fetch.go
+++ b/internal/gitaly/service/repository/fetch.go
@@ -4,11 +4,11 @@ import (
"context"
"errors"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/remoterepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -91,7 +91,7 @@ func (s *server) FetchSourceBranch(ctx context.Context, req *gitalypb.FetchSourc
); err != nil {
// Design quirk: if the fetch fails, this RPC returns Result: false, but no error.
if errors.As(err, &localrepo.FetchFailedError{}) {
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithField("oid", sourceOid.String()).
WithError(err).Warn("git fetch failed")
return &gitalypb.FetchSourceBranchResponse{Result: false}, nil
diff --git a/internal/gitaly/service/repository/rename.go b/internal/gitaly/service/repository/rename.go
index 51343e681..296d59e5c 100644
--- a/internal/gitaly/service/repository/rename.go
+++ b/internal/gitaly/service/repository/rename.go
@@ -7,9 +7,9 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -62,7 +62,7 @@ func (s *server) renameRepository(ctx context.Context, sourceRepo, targetRepo *g
}
defer func() {
if err := sourceLocker.Close(); err != nil {
- ctxlogrus.Extract(ctx).Error("closing source repo locker: %w", err)
+ log.FromContext(ctx).Error("closing source repo locker: %w", err)
}
}()
@@ -72,7 +72,7 @@ func (s *server) renameRepository(ctx context.Context, sourceRepo, targetRepo *g
}
defer func() {
if err := targetLocker.Close(); err != nil {
- ctxlogrus.Extract(ctx).Error("closing target repo locker: %w", err)
+ log.FromContext(ctx).Error("closing target repo locker: %w", err)
}
}()
diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go
index 233dd9bdf..d7aaac44b 100644
--- a/internal/gitaly/service/repository/replicate.go
+++ b/internal/gitaly/service/repository/replicate.go
@@ -10,7 +10,6 @@ import (
"path/filepath"
"strings"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
@@ -23,6 +22,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/client"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/metadata"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/tempdir"
@@ -151,7 +151,7 @@ func (s *server) create(ctx context.Context, in *gitalypb.ReplicateRepositoryReq
return fmt.Errorf("error deleting invalid repo: %w", err)
}
- ctxlogrus.Extract(ctx).WithField("repo_path", repoPath).Warn("removed invalid repository")
+ log.FromContext(ctx).WithField("repo_path", repoPath).Warn("removed invalid repository")
}
if err := s.createFromSnapshot(ctx, in.GetSource(), in.GetRepository()); err != nil {
diff --git a/internal/gitaly/service/repository/snapshot.go b/internal/gitaly/service/repository/snapshot.go
index 4d67fd8e6..1530013f4 100644
--- a/internal/gitaly/service/repository/snapshot.go
+++ b/internal/gitaly/service/repository/snapshot.go
@@ -7,9 +7,9 @@ import (
"path/filepath"
"regexp"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/archive"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v16/streamio"
@@ -98,7 +98,7 @@ func (s *server) addAlternateFiles(ctx context.Context, repository *gitalypb.Rep
altObjDirs, err := git.AlternateObjectDirectories(ctx, storageRoot, repoPath)
if err != nil {
- ctxlogrus.Extract(ctx).WithField("error", err).Warn("error getting alternate object directories")
+ log.FromContext(ctx).WithField("error", err).Warn("error getting alternate object directories")
return nil
}
diff --git a/internal/gitaly/service/server/disk_stats.go b/internal/gitaly/service/server/disk_stats.go
index f278357a4..2abcf251f 100644
--- a/internal/gitaly/service/server/disk_stats.go
+++ b/internal/gitaly/service/server/disk_stats.go
@@ -3,7 +3,7 @@ package server
import (
"context"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -12,7 +12,7 @@ func (s *server) DiskStatistics(ctx context.Context, _ *gitalypb.DiskStatisticsR
for _, shard := range s.storages {
shardInfo, err := getStorageStatus(shard)
if err != nil {
- ctxlogrus.Extract(ctx).WithField("storage", shard).WithError(err).Error("to retrieve shard disk statistics")
+ log.FromContext(ctx).WithField("storage", shard).WithError(err).Error("to retrieve shard disk statistics")
results = append(results, &gitalypb.DiskStatisticsResponse_StorageStatus{StorageName: shard.Name})
continue
}
diff --git a/internal/gitaly/service/server/info.go b/internal/gitaly/service/server/info.go
index 0e3d9fa0f..f1580bc47 100644
--- a/internal/gitaly/service/server/info.go
+++ b/internal/gitaly/service/server/info.go
@@ -5,10 +5,10 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/fstype"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/version"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -27,7 +27,7 @@ func (s *server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest)
gitalyMetadata, err := storage.ReadMetadataFile(shard.Path)
if err != nil {
- ctxlogrus.Extract(ctx).WithField("storage", shard).WithError(err).Error("reading gitaly metadata file")
+ log.FromContext(ctx).WithField("storage", shard).WithError(err).Error("reading gitaly metadata file")
}
storageStatuses = append(storageStatuses, &gitalypb.ServerInfoResponse_StorageStatus{
diff --git a/internal/gitaly/service/smarthttp/cache.go b/internal/gitaly/service/smarthttp/cache.go
index b5ca72969..37add5bad 100644
--- a/internal/gitaly/service/smarthttp/cache.go
+++ b/internal/gitaly/service/smarthttp/cache.go
@@ -5,11 +5,11 @@ import (
"io"
"sync"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/cache"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -53,7 +53,7 @@ func (c infoRefCache) tryCache(ctx context.Context, in *gitalypb.InfoRefsRequest
return missFn(w)
}
- logger := ctxlogrus.Extract(ctx).WithFields(log.Fields{"service": uploadPackSvc})
+ logger := log.FromContext(ctx).WithFields(logrus.Fields{"service": uploadPackSvc})
logger.Debug("Attempting to fetch cached response")
countAttempt()
diff --git a/internal/gitaly/service/smarthttp/inforefs.go b/internal/gitaly/service/smarthttp/inforefs.go
index 97b50bbdc..b384f6142 100644
--- a/internal/gitaly/service/smarthttp/inforefs.go
+++ b/internal/gitaly/service/smarthttp/inforefs.go
@@ -5,10 +5,10 @@ import (
"fmt"
"io"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/pktline"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v16/streamio"
@@ -54,7 +54,7 @@ func (s *server) InfoRefsReceivePack(in *gitalypb.InfoRefsRequest, stream gitaly
}
func (s *server) handleInfoRefs(ctx context.Context, service, repoPath string, req *gitalypb.InfoRefsRequest, w io.Writer) error {
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"service": service,
}).Debug("handleInfoRefs")
diff --git a/internal/gitaly/service/smarthttp/receive_pack.go b/internal/gitaly/service/smarthttp/receive_pack.go
index d440bc8db..561c5ce49 100644
--- a/internal/gitaly/service/smarthttp/receive_pack.go
+++ b/internal/gitaly/service/smarthttp/receive_pack.go
@@ -3,11 +3,11 @@ package smarthttp
import (
"errors"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -21,7 +21,7 @@ func (s *server) PostReceivePack(stream gitalypb.SmartHTTPService_PostReceivePac
return err
}
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"GlID": req.GlId,
"GlRepository": req.GlRepository,
"GlUsername": req.GlUsername,
diff --git a/internal/gitaly/service/smarthttp/upload_pack.go b/internal/gitaly/service/smarthttp/upload_pack.go
index f39a21af2..aaca1417f 100644
--- a/internal/gitaly/service/smarthttp/upload_pack.go
+++ b/internal/gitaly/service/smarthttp/upload_pack.go
@@ -6,11 +6,11 @@ import (
"fmt"
"io"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/sidechannel"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -64,7 +64,7 @@ func (s *server) runStatsCollector(ctx context.Context, r io.Reader) (io.Reader,
stats, err := stats.ParsePackfileNegotiation(pr)
if err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Debug("failed parsing packfile negotiation")
+ log.FromContext(ctx).WithError(err).Debug("failed parsing packfile negotiation")
return
}
stats.UpdateMetrics(s.packfileNegotiationMetrics)
@@ -141,6 +141,6 @@ func (s *server) runUploadPack(ctx context.Context, req *gitalypb.PostUploadPack
return nil, structerr.NewFailedPrecondition("waiting for upload-pack: %w", err)
}
- ctxlogrus.Extract(ctx).WithField("request_sha", fmt.Sprintf("%x", h.Sum(nil))).WithField("response_bytes", respBytes).Info("request details")
+ log.FromContext(ctx).WithField("request_sha", fmt.Sprintf("%x", h.Sum(nil))).WithField("response_bytes", respBytes).Info("request details")
return nil, nil
}
diff --git a/internal/gitaly/service/ssh/receive_pack.go b/internal/gitaly/service/ssh/receive_pack.go
index ac8f03d7d..302d1dc0c 100644
--- a/internal/gitaly/service/ssh/receive_pack.go
+++ b/internal/gitaly/service/ssh/receive_pack.go
@@ -8,12 +8,12 @@ import (
"strings"
"sync"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/transaction"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -26,7 +26,7 @@ func (s *server) SSHReceivePack(stream gitalypb.SSHService_SSHReceivePackServer)
return structerr.NewInternal("%w", err)
}
- ctxlogrus.Extract(stream.Context()).WithFields(log.Fields{
+ log.FromContext(stream.Context()).WithFields(logrus.Fields{
"GlID": req.GlId,
"GlRepository": req.GlRepository,
"GlUsername": req.GlUsername,
@@ -128,7 +128,7 @@ func (s *server) sshReceivePack(stream gitalypb.SSHService_SSHReceivePackServer,
if errSend := stream.Send(&gitalypb.SSHReceivePackResponse{
ExitStatus: &gitalypb.ExitStatus{Value: int32(status)},
}); errSend != nil {
- ctxlogrus.Extract(ctx).WithError(errSend).Error("send final status code")
+ log.FromContext(ctx).WithError(errSend).Error("send final status code")
}
// Detect the case where the user has cancelled the push and log it with a proper
diff --git a/internal/gitaly/service/ssh/upload_pack.go b/internal/gitaly/service/ssh/upload_pack.go
index c5815536a..f798a71e0 100644
--- a/internal/gitaly/service/ssh/upload_pack.go
+++ b/internal/gitaly/service/ssh/upload_pack.go
@@ -8,8 +8,7 @@ import (
"strings"
"sync"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/command"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/pktline"
@@ -17,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/sidechannel"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/stream"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -31,7 +31,7 @@ func (s *server) SSHUploadPack(stream gitalypb.SSHService_SSHUploadPackServer) e
return structerr.NewInternal("%w", err)
}
- ctxlogrus.Extract(ctx).WithFields(log.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"GlRepository": req.GetRepository().GetGlRepository(),
"GitConfigOptions": req.GitConfigOptions,
"GitProtocol": req.GitProtocol,
@@ -60,7 +60,7 @@ func (s *server) SSHUploadPack(stream gitalypb.SSHService_SSHUploadPackServer) e
if errSend := stream.Send(&gitalypb.SSHUploadPackResponse{
ExitStatus: &gitalypb.ExitStatus{Value: int32(status)},
}); errSend != nil {
- ctxlogrus.Extract(ctx).WithError(errSend).Error("send final status code")
+ log.FromContext(ctx).WithError(errSend).Error("send final status code")
}
return structerr.NewInternal("%w", err)
@@ -115,7 +115,7 @@ func (s *server) sshUploadPack(rpcContext context.Context, req sshUploadPackRequ
stats, errIgnore := stats.ParsePackfileNegotiation(pr)
negotiation = &stats
if errIgnore != nil {
- ctxlogrus.Extract(ctx).WithError(errIgnore).Debug("failed parsing packfile negotiation")
+ log.FromContext(ctx).WithError(errIgnore).Debug("failed parsing packfile negotiation")
return
}
stats.UpdateMetrics(s.packfileNegotiationMetrics)
@@ -179,7 +179,7 @@ func (s *server) sshUploadPack(rpcContext context.Context, req sshUploadPackRequ
return nil, status, fmt.Errorf("cmd wait: %w, stderr: %q", err, stderrBuilder.String())
}
- ctxlogrus.Extract(ctx).WithField("response_bytes", stdoutCounter.N).Info("request details")
+ log.FromContext(ctx).WithField("response_bytes", stdoutCounter.N).Info("request details")
return nil, 0, nil
}
diff --git a/internal/gitaly/storage/storagemgr/transaction_manager.go b/internal/gitaly/storage/storagemgr/transaction_manager.go
index d95d9fd78..fefc94cae 100644
--- a/internal/gitaly/storage/storagemgr/transaction_manager.go
+++ b/internal/gitaly/storage/storagemgr/transaction_manager.go
@@ -18,13 +18,13 @@ import (
"sync"
"github.com/dgraph-io/badger/v4"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/repoutil"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/safe"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -263,7 +263,7 @@ func (mgr *TransactionManager) Begin(ctx context.Context, opts TransactionOption
defer func() {
if returnedErr != nil {
if err := txn.finish(); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Error("failed finishing unsuccessful transaction begin")
+ log.FromContext(ctx).WithError(err).Error("failed finishing unsuccessful transaction begin")
}
}
}()
@@ -1369,7 +1369,7 @@ func (mgr *TransactionManager) prepareReferenceTransaction(ctx context.Context,
// We ask housekeeping to cleanup stale reference locks. We don't add a grace period, because
// transaction manager is the only process which writes into the repository, so it is safe
// to delete these locks.
- if err := mgr.housekeepingManager.CleanStaleData(ctx, ctxlogrus.Extract(ctx), mgr.repository, housekeeping.OnlyStaleReferenceLockCleanup(0)); err != nil {
+ if err := mgr.housekeepingManager.CleanStaleData(ctx, log.FromContext(ctx), mgr.repository, housekeeping.OnlyStaleReferenceLockCleanup(0)); err != nil {
return nil, fmt.Errorf("running reflock cleanup: %w", err)
}
diff --git a/internal/gitaly/transaction/manager.go b/internal/gitaly/transaction/manager.go
index aeb1d506d..0ba4312aa 100644
--- a/internal/gitaly/transaction/manager.go
+++ b/internal/gitaly/transaction/manager.go
@@ -6,7 +6,6 @@ import (
"fmt"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config"
@@ -177,5 +176,5 @@ func (m *PoolManager) Stop(ctx context.Context, tx txinfo.Transaction) error {
}
func (m *PoolManager) log(ctx context.Context) log.Logger {
- return ctxlogrus.Extract(ctx).WithField("component", "transaction.PoolManager")
+ return log.FromContext(ctx).WithField("component", "transaction.PoolManager")
}
diff --git a/internal/helper/perm/fix_permissions.go b/internal/helper/perm/fix_permissions.go
index 330ee84ee..d80abd4ca 100644
--- a/internal/helper/perm/fix_permissions.go
+++ b/internal/helper/perm/fix_permissions.go
@@ -5,8 +5,8 @@ import (
"os"
"path/filepath"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
// FixDirectoryPermissions does a recursive directory walk to look for
@@ -20,7 +20,7 @@ func FixDirectoryPermissions(ctx context.Context, path string) error {
func fixDirectoryPermissions(ctx context.Context, path string, retriedPaths map[string]struct{}) error {
return filepath.Walk(path, func(path string, info os.FileInfo, errIncoming error) error {
if info == nil {
- ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"path": path,
}).WithError(errIncoming).Error("nil FileInfo in perm.fixDirectoryPermissions")
diff --git a/internal/log/logger.go b/internal/log/logger.go
index e3696fc77..49411c7a7 100644
--- a/internal/log/logger.go
+++ b/internal/log/logger.go
@@ -1,6 +1,11 @@
package log
-import "github.com/sirupsen/logrus"
+import (
+ "context"
+
+ "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
+ "github.com/sirupsen/logrus"
+)
// Logger is the logging type used by Gitaly.
type Logger interface {
@@ -16,3 +21,22 @@ type LogrusLogger struct {
func FromLogrusEntry(entry *logrus.Entry) LogrusLogger {
return LogrusLogger{Entry: entry}
}
+
+// ToContext injects the logger into the given context so that it can be retrieved via `FromContext()`.
+func (l LogrusLogger) ToContext(ctx context.Context) context.Context {
+ return ctxlogrus.ToContext(ctx, l.Entry)
+}
+
+// FromContext extracts the logger from the context. If no logger has been injected then this will return a discarding
+// logger.
+func FromContext(ctx context.Context) LogrusLogger {
+ return LogrusLogger{
+ Entry: ctxlogrus.Extract(ctx),
+ }
+}
+
+// AddFields adds the given log fields to the context so that it will be used by any context logger extracted via
+// `FromContext()`.
+func AddFields(ctx context.Context, fields logrus.Fields) {
+ ctxlogrus.AddFields(ctx, fields)
+}
diff --git a/internal/log/middleware.go b/internal/log/middleware.go
index c258d5c83..cab888e87 100644
--- a/internal/log/middleware.go
+++ b/internal/log/middleware.go
@@ -6,7 +6,6 @@ import (
grpcmwlogging "github.com/grpc-ecosystem/go-grpc-middleware/logging"
grpcmwlogrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/env"
"google.golang.org/grpc"
@@ -81,7 +80,7 @@ func MessageProducer(mp grpcmwlogrus.MessageProducer, fieldsProducers ...FieldsP
}
type messageProducerHolder struct {
- logger *logrus.Entry
+ logger LogrusLogger
actual grpcmwlogrus.MessageProducer
format string
level logrus.Level
@@ -113,7 +112,7 @@ func PropagationMessageProducer(actual grpcmwlogrus.MessageProducer) grpcmwlogru
return
}
*mpp = messageProducerHolder{
- logger: ctxlogrus.Extract(ctx),
+ logger: FromContext(ctx),
actual: actual,
format: format,
level: level,
@@ -170,7 +169,7 @@ func (lh PerRPCLogHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
// a logger we need to set logger manually into the context.
// It's needed because github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus.DefaultMessageProducer
// extracts logger from the context and use it to write the logs.
- ctx = ctxlogrus.ToContext(ctx, mpp.logger)
+ ctx = mpp.logger.ToContext(ctx)
mpp.actual(ctx, mpp.format, mpp.level, mpp.code, mpp.err, mpp.fields)
return
}
@@ -191,7 +190,7 @@ func UnaryLogDataCatcherServerInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
mpp := messageProducerPropagationFrom(ctx)
if mpp != nil {
- mpp.fields = ctxlogrus.Extract(ctx).Data
+ mpp.fields = FromContext(ctx).Entry.Data
}
return handler(ctx, req)
}
@@ -204,7 +203,7 @@ func StreamLogDataCatcherServerInterceptor() grpc.StreamServerInterceptor {
ctx := ss.Context()
mpp := messageProducerPropagationFrom(ctx)
if mpp != nil {
- mpp.fields = ctxlogrus.Extract(ctx).Data
+ mpp.fields = FromContext(ctx).Entry.Data
}
return handler(srv, ss)
}
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 58c30c469..4f1583ede 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -7,7 +7,6 @@ import (
"sync"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
@@ -17,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/protoregistry"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/proxy"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/metrics"
@@ -252,7 +252,7 @@ func (c *Coordinator) Collect(metrics chan<- prometheus.Metric) {
}
func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, call grpcCall) (*proxy.StreamParameters, error) {
- ctxlogrus.AddFields(ctx, logrus.Fields{
+ log.AddFields(ctx, logrus.Fields{
"virtual_storage": call.targetRepo.StorageName,
"relative_path": call.targetRepo.RelativePath,
})
@@ -491,14 +491,14 @@ func (c *Coordinator) mutatorStreamParameters(ctx context.Context, call grpcCall
defer nodeErrors.Unlock()
nodeErrors.errByNode[secondary.Storage] = err
- ctxlogrus.Extract(ctx).WithError(err).
+ log.FromContext(ctx).WithError(err).
Error("proxying to secondary failed")
// Cancels failed node's voter in its current subtransaction.
// Also updates internal state of subtransaction to fail and
// release blocked voters if quorum becomes impossible.
if err := c.txMgr.CancelTransactionNodeVoter(transaction.ID(), secondary.Storage); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).
+ log.FromContext(ctx).WithError(err).
Error("canceling secondary voter failed")
}
@@ -544,8 +544,7 @@ func (c *Coordinator) mutatorStreamParameters(ctx context.Context, call grpcCall
continue
}
- ctxlogrus.
- Extract(ctx).
+ log.FromContext(ctx).
WithError(err).
Error("coordinator proxy stream finalizer failure")
}
@@ -590,7 +589,7 @@ func (c *Coordinator) maintenanceStreamParameters(ctx context.Context, call grpc
defer nodeErrors.Unlock()
nodeErrors.errByNode[node.Storage] = err
- ctxlogrus.Extract(ctx).WithField("gitaly_storage", node.Storage).WithError(err).Error("proxying maintenance RPC to node failed")
+ log.FromContext(ctx).WithField("gitaly_storage", node.Storage).WithError(err).Error("proxying maintenance RPC to node failed")
// We ignore any errors returned by nodes such that they all have a
// chance to finish their maintenance RPC in a best-effort strategy.
@@ -667,7 +666,7 @@ func streamParametersContext(ctx context.Context) context.Context {
func (c *Coordinator) StreamDirector(ctx context.Context, fullMethodName string, peeker proxy.StreamPeeker) (*proxy.StreamParameters, error) {
// For phase 1, we need to route messages based on the storage location
// to the appropriate Gitaly node.
- ctxlogrus.Extract(ctx).Debugf("Stream director received method %s", fullMethodName)
+ log.FromContext(ctx).Debugf("Stream director received method %s", fullMethodName)
mi, err := c.registry.LookupMethod(fullMethodName)
if err != nil {
@@ -952,7 +951,7 @@ func getUpdatedAndOutdatedSecondaries(
nodesByState := make(map[string][]string)
defer func() {
- ctxlogrus.Extract(ctx).
+ log.FromContext(ctx).
WithField("transaction.primary", route.Primary.Storage).
WithField("transaction.secondaries", nodesByState).
Info("transactional node states")
@@ -1071,18 +1070,18 @@ func (c *Coordinator) newRequestFinalizer(
ctx, cancel := context.WithTimeout(helper.SuppressCancellation(originalCtx), 30*time.Second)
defer cancel()
- log := ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ logEntry := log.FromContext(ctx).WithFields(logrus.Fields{
"replication.cause": cause,
"replication.change": change,
"replication.primary": primary,
})
if len(updatedSecondaries) > 0 {
- log = log.WithField("replication.updated", updatedSecondaries)
+ logEntry = logEntry.WithField("replication.updated", updatedSecondaries)
}
if len(outdatedSecondaries) > 0 {
- log = log.WithField("replication.outdated", outdatedSecondaries)
+ logEntry = logEntry.WithField("replication.outdated", outdatedSecondaries)
}
- log.Info("queueing replication jobs")
+ logEntry.Info("queueing replication jobs")
switch change {
case datastore.UpdateRepo:
@@ -1101,7 +1100,7 @@ func (c *Coordinator) newRequestFinalizer(
return fmt.Errorf("rename repository: %w", err)
}
- ctxlogrus.Extract(ctx).WithError(err).Info("renamed repository does not have a store entry")
+ log.FromContext(ctx).WithError(err).Info("renamed repository does not have a store entry")
}
case datastore.CreateRepo:
repositorySpecificPrimariesEnabled := c.conf.Failover.ElectionStrategy == config.ElectionStrategyPerRepository
@@ -1148,7 +1147,7 @@ func (c *Coordinator) newRequestFinalizer(
g.Go(func() error {
if _, err := c.queue.Enqueue(ctx, event); err != nil {
if errors.As(err, &datastore.ReplicationEventExistsError{}) {
- ctxlogrus.Extract(ctx).WithError(err).Info("replication event queue already has similar entry")
+ log.FromContext(ctx).WithError(err).Info("replication event queue already has similar entry")
return nil
}
diff --git a/internal/praefect/datastore/storage_provider_test.go b/internal/praefect/datastore/storage_provider_test.go
index 4a907c5c1..17b1c0e52 100644
--- a/internal/praefect/datastore/storage_provider_test.go
+++ b/internal/praefect/datastore/storage_provider_test.go
@@ -9,13 +9,13 @@ import (
"sync"
"testing"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/datastructure"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore/glsql"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testdb"
@@ -32,7 +32,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
require.NoError(t, rs.CreateRepository(ctx, 1, "unknown", "/repo/path", "replica-path", "g1", []string{"g2", "g3"}, nil, true, false))
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), rs, []string{"vs"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), rs, []string{"vs"})
require.NoError(t, err)
cache.Connected()
@@ -56,7 +56,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
require.NoError(t, rs.CreateRepository(ctx, 1, "vs", "/repo/path", "replica-path", "g1", []string{"g2", "g3"}, nil, true, false))
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), rs, []string{"vs"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), rs, []string{"vs"})
require.NoError(t, err)
cache.Connected()
@@ -180,7 +180,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
require.NoError(t, rs.CreateRepository(ctx, 1, "vs", "/repo/path/1", "replica-path-1", "g1", []string{"g2", "g3"}, nil, true, false))
require.NoError(t, rs.CreateRepository(ctx, 2, "vs", "/repo/path/2", "replica-path-2", "g1", []string{"g2"}, nil, true, false))
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), rs, []string{"vs"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), rs, []string{"vs"})
require.NoError(t, err)
cache.Connected()
@@ -230,7 +230,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
require.NoError(t, rs.CreateRepository(ctx, 1, "vs", "/repo/path", "replica-path", "g1", []string{"g2", "g3"}, nil, true, false))
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), rs, []string{"vs"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), rs, []string{"vs"})
require.NoError(t, err)
cache.Connected()
@@ -266,7 +266,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
require.NoError(t, rs.CreateRepository(ctx, 1, "vs", "/repo/path/1", "replica-path-1", "g1", nil, nil, true, false))
require.NoError(t, rs.CreateRepository(ctx, 2, "vs", "/repo/path/2", "replica-path-2", "g1", nil, nil, true, false))
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), rs, []string{"vs"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), rs, []string{"vs"})
require.NoError(t, err)
cache.Connected()
@@ -331,7 +331,7 @@ func TestCachingStorageProvider_GetSyncedNodes(t *testing.T) {
},
}
- cache, err := NewCachingConsistentStoragesGetter(ctxlogrus.Extract(ctx), mockRepositoryStore, []string{"storage-1", "storage-2"})
+ cache, err := NewCachingConsistentStoragesGetter(log.FromContext(ctx), mockRepositoryStore, []string{"storage-1", "storage-2"})
require.NoError(t, err)
cache.Connected()
diff --git a/internal/praefect/nodes/per_repository.go b/internal/praefect/nodes/per_repository.go
index cd457d3a5..9c53ef184 100644
--- a/internal/praefect/nodes/per_repository.go
+++ b/internal/praefect/nodes/per_repository.go
@@ -6,8 +6,8 @@ import (
"errors"
"fmt"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore/glsql"
)
@@ -110,7 +110,7 @@ WHERE snapshot.repository_id = $1
}
if current != previous {
- ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"repository_id": repositoryID,
"current_primary": current.String,
"previous_primary": previous.String,
diff --git a/internal/praefect/nodes/per_repository_test.go b/internal/praefect/nodes/per_repository_test.go
index 673c2a9a0..19b73bd25 100644
--- a/internal/praefect/nodes/per_repository_test.go
+++ b/internal/praefect/nodes/per_repository_test.go
@@ -3,11 +3,11 @@ package nodes
import (
"testing"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testdb"
@@ -533,7 +533,7 @@ func TestPerRepositoryElector(t *testing.T) {
logger, hook := test.NewNullLogger()
elector := NewPerRepositoryElector(tx)
- primary, err := elector.GetPrimary(ctxlogrus.ToContext(ctx, logrus.NewEntry(logger)), "", repositoryID)
+ primary, err := elector.GetPrimary(log.FromLogrusEntry(logrus.NewEntry(logger)).ToContext(ctx), "", repositoryID)
assert.Equal(t, step.error, err)
assert.Less(t, len(hook.Entries), 2)
diff --git a/internal/praefect/remove_repository.go b/internal/praefect/remove_repository.go
index 58401d682..83c9cbb83 100644
--- a/internal/praefect/remove_repository.go
+++ b/internal/praefect/remove_repository.go
@@ -7,9 +7,9 @@ import (
"sync"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
@@ -99,7 +99,7 @@ func removeRepositoryHandler(rs datastore.RepositoryStore, conns Connections, pa
rewritten.RelativePath = replicaPath
if err := proxyRequest(ctx, conn, rewritten); err != nil {
- ctxlogrus.Extract(ctx).WithFields(logrus.Fields{
+ log.FromContext(ctx).WithFields(logrus.Fields{
"virtual_storage": virtualStorage,
"relative_path": repo.RelativePath,
"storage": rewrittenStorage,
diff --git a/internal/praefect/router.go b/internal/praefect/router.go
index 36fe9b179..9abdce830 100644
--- a/internal/praefect/router.go
+++ b/internal/praefect/router.go
@@ -3,8 +3,8 @@ package praefect
import (
"context"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"google.golang.org/grpc"
)
@@ -27,7 +27,7 @@ func (e additionalRepositoryNotFoundError) Error() string {
}
func addRouteLogField(ctx context.Context, fields logrus.Fields) {
- ctxlogrus.AddFields(ctx, logrus.Fields{"route": fields})
+ log.AddFields(ctx, logrus.Fields{"route": fields})
}
func routerNodeStorages(secondaries []RouterNode) []string {
diff --git a/internal/praefect/service/server/info.go b/internal/praefect/service/server/info.go
index 9481ecb8d..644007a37 100644
--- a/internal/praefect/service/server/info.go
+++ b/internal/praefect/service/server/info.go
@@ -5,8 +5,8 @@ import (
"sync"
"github.com/google/uuid"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/grpc/metadata"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
"google.golang.org/grpc"
)
@@ -52,7 +52,7 @@ func (s *Server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest)
client := gitalypb.NewServerServiceClient(conn)
resp, err := client.ServerInfo(ctx, &gitalypb.ServerInfoRequest{})
if err != nil {
- ctxlogrus.Extract(ctx).WithField("storage", storage).WithError(err).Error("error getting server info")
+ log.FromContext(ctx).WithField("storage", storage).WithError(err).Error("error getting server info")
return
}
diff --git a/internal/praefect/transactions/manager.go b/internal/praefect/transactions/manager.go
index ac4081d31..2d56d82e7 100644
--- a/internal/praefect/transactions/manager.go
+++ b/internal/praefect/transactions/manager.go
@@ -8,7 +8,6 @@ import (
"sync/atomic"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/log"
@@ -77,7 +76,7 @@ func (mgr *Manager) Collect(metrics chan<- prometheus.Metric) {
}
func (mgr *Manager) log(ctx context.Context) log.Logger {
- return ctxlogrus.Extract(ctx).WithField("component", "transactions.Manager")
+ return log.FromContext(ctx).WithField("component", "transactions.Manager")
}
// CancelFunc is the transaction cancellation function returned by
diff --git a/internal/tempdir/tempdir.go b/internal/tempdir/tempdir.go
index 01bdd5eee..15e9b5484 100644
--- a/internal/tempdir/tempdir.go
+++ b/internal/tempdir/tempdir.go
@@ -7,9 +7,9 @@ import (
"path/filepath"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
@@ -98,7 +98,7 @@ func newDirectory(ctx context.Context, storageName string, prefix string, loc st
func (d Dir) cleanupOnDone(ctx context.Context) {
<-ctx.Done()
if err := os.RemoveAll(d.Path()); err != nil {
- ctxlogrus.Extract(ctx).WithError(err).Errorf("failed to cleanup temp dir %q", d.path)
+ log.FromContext(ctx).WithError(err).Errorf("failed to cleanup temp dir %q", d.path)
}
close(d.doneCh)
}
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 6b92eade3..4ee0e5f19 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -17,8 +17,6 @@ import (
"syscall"
"testing"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/featureflag"
@@ -208,13 +206,6 @@ func GetLocalhostListener(tb testing.TB) (net.Listener, string) {
// ContextOpt returns a new context instance with the new additions to it.
type ContextOpt func(context.Context) context.Context
-// ContextWithLogger allows to inject provided logger into the context.
-func ContextWithLogger(logger *log.Entry) ContextOpt {
- return func(ctx context.Context) context.Context {
- return ctxlogrus.ToContext(ctx, logger)
- }
-}
-
// Context returns that gets canceled at the end of the test.
func Context(tb testing.TB, opts ...ContextOpt) context.Context {
ctx, cancel := context.WithCancel(ContextWithoutCancel(opts...))