diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2022-08-11 13:52:32 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2022-08-11 13:52:32 +0300 |
commit | e15d444699daaad18af204a2eeb1573ef661b5ec (patch) | |
tree | 0aab691af28f550defd43e5f5b264bc33814492c | |
parent | f20b8259797f3a1f3b59142c9789af97fcb0f69f (diff) | |
parent | 96bdc9439798f202647360242cb5109cece5e2d8 (diff) |
Merge branch 'pks-git-command-factory-fix-warning' into 'master'
git: Fix warning on startup about Git binary fallback
See merge request gitlab-org/gitaly!4805
-rw-r--r-- | internal/git/command_factory.go | 13 | ||||
-rw-r--r-- | internal/git/execution_environment.go | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go index 210288dd4..77ff1976c 100644 --- a/internal/git/command_factory.go +++ b/internal/git/command_factory.go @@ -9,6 +9,7 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" + "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v15/internal/cgroups" "gitlab.com/gitlab-org/gitaly/v15/internal/command" "gitlab.com/gitlab-org/gitaly/v15/internal/git/alternates" @@ -193,7 +194,17 @@ func setupGitExecutionEnvironments(cfg config.Cfg, factoryCfg execCommandFactory } if len(execEnvs) == 0 { - return nil, nil, fmt.Errorf("could not set up any Git execution environments") + execEnv, err := FallbackGitEnvironmentConstructor{}.Construct(cfg) + if err != nil { + return nil, nil, fmt.Errorf("could not set up any Git execution environments") + } + execEnv.EnvironmentVariables = append(execEnv.EnvironmentVariables, sharedEnvironment...) + + logrus.WithFields(logrus.Fields{ + "resolvedPath": execEnv.BinaryPath, + }).Warn("Git has not been properly configured, falling back to Git found on PATH") + + execEnvs = append(execEnvs, execEnv) } return execEnvs, func() { diff --git a/internal/git/execution_environment.go b/internal/git/execution_environment.go index c35d5e108..99aa795c3 100644 --- a/internal/git/execution_environment.go +++ b/internal/git/execution_environment.go @@ -35,7 +35,6 @@ var ( Suffix: "-v2.35.1.gl1", }, DistributedGitEnvironmentConstructor{}, - FallbackGitEnvironmentConstructor{}, } ) @@ -247,10 +246,6 @@ func (c FallbackGitEnvironmentConstructor) Construct(config.Cfg) (ExecutionEnvir return ExecutionEnvironment{}, fmt.Errorf("resolving git executable: %w", err) } - logrus.WithFields(logrus.Fields{ - "resolvedPath": resolvedPath, - }).Warn("git path not configured. Using default path resolution") - return ExecutionEnvironment{ BinaryPath: resolvedPath, // We always pretend that this environment is disabled. This has the effect that |