diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-04-29 15:28:22 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-04-29 15:28:22 +0300 |
commit | 4afeaef9595693f02e05026555ef724b0385ae98 (patch) | |
tree | 95e0f518a7690191ac06b76f0c0ba5140c105953 | |
parent | 364005ad128cce1d8e33d904daaef93acccdda46 (diff) | |
parent | 8a3373c8b07b06fe38ade96350c9bde836b25849 (diff) |
Merge branch 'pks-config-remove-internal-socket-directory' into 'master'
config: Remove internal socket path configuration
Closes #4139
See merge request gitlab-org/gitaly!4504
-rw-r--r-- | cmd/gitaly-ssh/upload_pack_test.go | 2 | ||||
-rw-r--r-- | cmd/gitaly/main.go | 2 | ||||
-rw-r--r-- | internal/git/gittest/testhelper_test.go | 1 | ||||
-rw-r--r-- | internal/git/hooks_payload.go | 2 | ||||
-rw-r--r-- | internal/git/hooks_payload_test.go | 6 | ||||
-rw-r--r-- | internal/gitaly/config/config.go | 38 | ||||
-rw-r--r-- | internal/gitaly/config/config_test.go | 134 | ||||
-rw-r--r-- | internal/gitaly/rubyserver/rubyserver.go | 4 | ||||
-rw-r--r-- | internal/gitaly/rubyserver/rubyserver_test.go | 6 | ||||
-rw-r--r-- | internal/gitaly/service/operations/branches_test.go | 4 | ||||
-rw-r--r-- | internal/gitaly/service/operations/tags_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/repository/apply_gitattributes_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/smarthttp/receive_pack_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/ssh/receive_pack_test.go | 2 | ||||
-rw-r--r-- | internal/testhelper/testcfg/gitaly_builder.go | 6 | ||||
-rw-r--r-- | internal/testhelper/testserver/gitaly.go | 8 |
16 files changed, 122 insertions, 99 deletions
diff --git a/cmd/gitaly-ssh/upload_pack_test.go b/cmd/gitaly-ssh/upload_pack_test.go index 745f9b558..0758cc8ee 100644 --- a/cmd/gitaly-ssh/upload_pack_test.go +++ b/cmd/gitaly-ssh/upload_pack_test.go @@ -32,7 +32,7 @@ func TestVisibilityOfHiddenRefs(t *testing.T) { _, clean := runServer(t, false, cfg, "unix", socketPath) defer clean() - _, clean = runServer(t, false, cfg, "unix", cfg.GitalyInternalSocketPath()) + _, clean = runServer(t, false, cfg, "unix", cfg.InternalSocketPath()) defer clean() // Create a keep-around ref diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index b0c124038..50d8306ed 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -260,7 +260,7 @@ func run(cfg config.Cfg) error { for _, c := range []starter.Config{ {Name: starter.Unix, Addr: cfg.SocketPath, HandoverOnUpgrade: true}, - {Name: starter.Unix, Addr: cfg.GitalyInternalSocketPath(), HandoverOnUpgrade: false}, + {Name: starter.Unix, Addr: cfg.InternalSocketPath(), HandoverOnUpgrade: false}, {Name: starter.TCP, Addr: cfg.ListenAddr, HandoverOnUpgrade: true}, {Name: starter.TLS, Addr: cfg.TLSListenAddr, HandoverOnUpgrade: true}, } { diff --git a/internal/git/gittest/testhelper_test.go b/internal/git/gittest/testhelper_test.go index 4565301d2..47cefc0cd 100644 --- a/internal/git/gittest/testhelper_test.go +++ b/internal/git/gittest/testhelper_test.go @@ -47,6 +47,7 @@ func setup(t testing.TB) (config.Cfg, *gitalypb.Repository, string) { cfg.RuntimeDir = filepath.Join(rootDir, "run.d") require.NoError(t, os.Mkdir(cfg.RuntimeDir, 0o700)) + require.NoError(t, os.Mkdir(cfg.InternalSocketDir(), 0o700)) require.NoError(t, cfg.Validate()) diff --git a/internal/git/hooks_payload.go b/internal/git/hooks_payload.go index d12bb0a81..e06fd7fa2 100644 --- a/internal/git/hooks_payload.go +++ b/internal/git/hooks_payload.go @@ -109,7 +109,7 @@ func NewHooksPayload( return HooksPayload{ Repo: repo, RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), InternalSocketToken: cfg.Auth.Token, Transaction: tx, ReceiveHooksPayload: receiveHooksPayload, diff --git a/internal/git/hooks_payload_test.go b/internal/git/hooks_payload_test.go index c1e97e380..37acd892b 100644 --- a/internal/git/hooks_payload_test.go +++ b/internal/git/hooks_payload_test.go @@ -41,7 +41,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, git.HooksPayload{ Repo: repo, RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), RequestedHooks: git.PreReceiveHook, FeatureFlags: featureflag.Raw{"flag-key": "flag-value"}, }, payload) @@ -57,7 +57,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, git.HooksPayload{ Repo: repo, RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), Transaction: &tx, RequestedHooks: git.UpdateHook, }, payload) @@ -93,7 +93,7 @@ func TestHooksPayload(t *testing.T) { require.Equal(t, git.HooksPayload{ Repo: repo, RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), InternalSocketToken: cfg.Auth.Token, ReceiveHooksPayload: &git.ReceiveHooksPayload{ UserID: "1234", diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go index 49b6cc509..8e9328104 100644 --- a/internal/gitaly/config/config.go +++ b/internal/gitaly/config/config.go @@ -62,7 +62,6 @@ type Cfg struct { Concurrency []Concurrency `toml:"concurrency"` RateLimiting []RateLimiting `toml:"rate_limiting"` GracefulRestartTimeout Duration `toml:"graceful_restart_timeout"` - InternalSocketDir string `toml:"internal_socket_dir"` DailyMaintenance DailyJob `toml:"daily_maintenance"` Cgroups cgroups.Config `toml:"cgroups"` PackObjectsCache StreamCacheConfig `toml:"pack_objects_cache"` @@ -272,17 +271,12 @@ func (cfg *Cfg) setDefaults() error { cfg.RuntimeDir = runtimeDir } - if cfg.InternalSocketDir == "" { - // The socket path must be short-ish because listen(2) fails on long - // socket paths. We hope/expect that os.MkdirTemp creates a directory - // that is not too deep. We need a directory, not a tempfile, because we - // will later want to set its permissions to 0700 - socketDir := filepath.Join(cfg.RuntimeDir, "sock.d") - if err := os.Mkdir(socketDir, 0o700); err != nil { - return fmt.Errorf("create internal socket directory: %w", err) - } - - cfg.InternalSocketDir = socketDir + // The socket path must be short-ish because listen(2) fails on long + // socket paths. We hope/expect that os.MkdirTemp creates a directory + // that is not too deep. We need a directory, not a tempfile, because we + // will later want to set its permissions to 0700 + if err := os.Mkdir(cfg.InternalSocketDir(), 0o700); err != nil { + return fmt.Errorf("create internal socket directory: %w", err) } if reflect.DeepEqual(cfg.DailyMaintenance, DailyJob{}) { @@ -390,9 +384,14 @@ func (cfg *Cfg) Storage(storageName string) (Storage, bool) { return Storage{}, false } -// GitalyInternalSocketPath is the path to the internal gitaly socket -func (cfg *Cfg) GitalyInternalSocketPath() string { - return filepath.Join(cfg.InternalSocketDir, fmt.Sprintf("internal_%d.sock", os.Getpid())) +// InternalSocketDir returns the location of the internal socket directory. +func (cfg *Cfg) InternalSocketDir() string { + return filepath.Join(cfg.RuntimeDir, "sock.d") +} + +// InternalSocketPath is the path to the internal Gitaly socket. +func (cfg *Cfg) InternalSocketPath() string { + return filepath.Join(cfg.InternalSocketDir(), fmt.Sprintf("internal_%d.sock", os.Getpid())) } func (cfg *Cfg) validateBinDir() error { @@ -466,17 +465,14 @@ func (cfg *Cfg) validateToken() error { } func (cfg *Cfg) validateInternalSocketDir() error { - if cfg.InternalSocketDir == "" { - return nil - } - - if err := validateIsDirectory(cfg.InternalSocketDir, "internal_socket_dir"); err != nil { + if err := validateIsDirectory(cfg.InternalSocketDir(), "internal_socket_dir"); err != nil { return err } - if err := trySocketCreation(cfg.InternalSocketDir); err != nil { + if err := trySocketCreation(cfg.InternalSocketDir()); err != nil { return fmt.Errorf("internal_socket_dir: try create socket: %w", err) } + return nil } diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go index 82c345c71..763fe4b1c 100644 --- a/internal/gitaly/config/config_test.go +++ b/internal/gitaly/config/config_test.go @@ -1,7 +1,6 @@ package config import ( - "bytes" "errors" "fmt" "os" @@ -30,8 +29,7 @@ func TestLoadEmptyConfig(t *testing.T) { require.NoError(t, err) expectedCfg := Cfg{ - Prometheus: prometheus.DefaultConfig(), - InternalSocketDir: cfg.InternalSocketDir, + Prometheus: prometheus.DefaultConfig(), } require.NoError(t, expectedCfg.setDefaults()) @@ -604,80 +602,112 @@ dir = '%s'`, gitlabShellDir)) } func TestValidateInternalSocketDir(t *testing.T) { - // create a valid socket directory - tmpDir := testhelper.TempDir(t) - // create a symlinked socket directory - dirName := "internal_socket_dir" - validSocketDirSymlink := filepath.Join(tmpDir, dirName) - tmpSocketDir, err := os.MkdirTemp(tmpDir, "") - require.NoError(t, err) - tmpSocketDir, err = filepath.Abs(tmpSocketDir) - require.NoError(t, err) - require.NoError(t, os.Symlink(tmpSocketDir, validSocketDirSymlink)) - - // create a broken symlink - dirName = "internal_socket_dir_broken" - brokenSocketDirSymlink := filepath.Join(tmpDir, dirName) - require.NoError(t, os.Symlink("/does/not/exist", brokenSocketDirSymlink)) - - pathTooLongForSocket := filepath.Join(tmpDir, strings.Repeat("/nested_directory", 10)) - require.NoError(t, os.MkdirAll(pathTooLongForSocket, os.ModePerm)) + verifyPathDoesNotExist := func(t *testing.T, runtimeDir string, actualErr error) { + require.Equal(t, fmt.Errorf("internal_socket_dir: path doesn't exist: %q", filepath.Join(runtimeDir, "sock.d")), actualErr) + } testCases := []struct { - desc string - internalSocketDir string - expErrMsgRegexp string + desc string + setup func(t *testing.T) string + verify func(t *testing.T, runtimeDir string, actualErr error) }{ { - desc: "empty socket dir", - internalSocketDir: "", + desc: "unconfigured runtime directory", + setup: func(t *testing.T) string { + return "" + }, + verify: verifyPathDoesNotExist, }, { - desc: "non existing directory", - internalSocketDir: "/tmp/relative/path/to/nowhere", - expErrMsgRegexp: `internal_socket_dir: path doesn't exist: "/tmp/relative/path/to/nowhere"`, + desc: "non existing directory", + setup: func(t *testing.T) string { + return "/path/does/not/exist" + }, + verify: verifyPathDoesNotExist, }, { - desc: "valid socket directory", - internalSocketDir: tmpDir, + desc: "runtime directory missing sock.d", + setup: func(t *testing.T) string { + runtimeDir := testhelper.TempDir(t) + return runtimeDir + }, + verify: verifyPathDoesNotExist, }, { - desc: "valid symlinked directory", - internalSocketDir: validSocketDirSymlink, + desc: "runtime directory with valid sock.d", + setup: func(t *testing.T) string { + runtimeDir := testhelper.TempDir(t) + require.NoError(t, os.Mkdir(filepath.Join(runtimeDir, "sock.d"), os.ModePerm)) + return runtimeDir + }, + }, + { + desc: "symlinked runtime directory", + setup: func(t *testing.T) string { + runtimeDir := testhelper.TempDir(t) + require.NoError(t, os.Mkdir(filepath.Join(runtimeDir, "sock.d"), os.ModePerm)) + + // Create a symlink which points to the real runtime directory. + symlinkDir := testhelper.TempDir(t) + symlink := filepath.Join(symlinkDir, "symlink-to-runtime-dir") + require.NoError(t, os.Symlink(runtimeDir, symlink)) + + return symlink + }, }, { - desc: "broken symlinked directory", - internalSocketDir: brokenSocketDirSymlink, - expErrMsgRegexp: fmt.Sprintf(`internal_socket_dir: path doesn't exist: %q`, brokenSocketDirSymlink), + desc: "broken symlinked runtime directory", + setup: func(t *testing.T) string { + symlinkDir := testhelper.TempDir(t) + symlink := filepath.Join(symlinkDir, "symlink-to-runtime-dir") + require.NoError(t, os.Symlink("/path/does/not/exist", symlink)) + return symlink + }, + verify: verifyPathDoesNotExist, }, { - desc: "socket can't be created", - internalSocketDir: pathTooLongForSocket, - expErrMsgRegexp: `internal_socket_dir: try create socket: socket could not be created in .*\/test-.{8}\.sock: bind: invalid argument`, + desc: "socket can't be created", + setup: func(t *testing.T) string { + tempDir := testhelper.TempDir(t) + + runtimeDirTooLongForSockets := filepath.Join(tempDir, strings.Repeat("/nested_directory", 10)) + socketDir := filepath.Join(runtimeDirTooLongForSockets, "sock.d") + require.NoError(t, os.MkdirAll(socketDir, os.ModePerm)) + + return runtimeDirTooLongForSockets + }, + verify: func(t *testing.T, runtimeDir string, actualErr error) { + require.Error(t, actualErr) + require.Regexp(t, + fmt.Sprintf( + "internal_socket_dir: try create socket: socket could not be created in %s: listen unix %s: bind: invalid argument", + filepath.Join(runtimeDir, "sock\\.d"), + filepath.Join(runtimeDir, "sock\\.d", "test-.{8}\\.sock"), + ), + actualErr.Error(), + ) + }, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - err := (&Cfg{InternalSocketDir: tc.internalSocketDir}).validateInternalSocketDir() - if tc.expErrMsgRegexp != "" { - assert.Regexp(t, tc.expErrMsgRegexp, err) + runtimeDir := tc.setup(t) + + cfg := Cfg{ + RuntimeDir: runtimeDir, + } + + actualErr := cfg.validateInternalSocketDir() + if tc.verify == nil { + require.NoError(t, actualErr) } else { - assert.NoError(t, err) + tc.verify(t, runtimeDir, actualErr) } }) } } -func TestInternalSocketDir(t *testing.T) { - cfg, err := Load(bytes.NewReader(nil)) - require.NoError(t, err) - socketDir := cfg.InternalSocketDir - - require.NoError(t, trySocketCreation(socketDir)) - require.NoError(t, os.RemoveAll(socketDir)) -} - func TestLoadDailyMaintenance(t *testing.T) { for _, tt := range []struct { name string diff --git a/internal/gitaly/rubyserver/rubyserver.go b/internal/gitaly/rubyserver/rubyserver.go index c64f183ab..794178123 100644 --- a/internal/gitaly/rubyserver/rubyserver.go +++ b/internal/gitaly/rubyserver/rubyserver.go @@ -55,7 +55,7 @@ func setupEnv(cfg config.Cfg, gitCmdFactory git.CommandFactory) []string { "GITALY_RUBY_GITALY_BIN_DIR="+cfg.BinDir, "GITALY_VERSION="+version.GetVersion(), "GITALY_GIT_HOOKS_DIR="+hooksPath, - "GITALY_SOCKET="+cfg.GitalyInternalSocketPath(), + "GITALY_SOCKET="+cfg.InternalSocketPath(), "GITALY_TOKEN="+cfg.Auth.Token, "GITALY_RUGGED_GIT_CONFIG_SEARCH_PATH="+cfg.Ruby.RuggedGitConfigSearchPath, ) @@ -142,7 +142,7 @@ func (s *Server) start() error { for i := 0; i < numWorkers; i++ { name := fmt.Sprintf("gitaly-ruby.%d", i) - socketPath := filepath.Join(cfg.InternalSocketDir, fmt.Sprintf("ruby.%d", i)) + socketPath := filepath.Join(cfg.InternalSocketDir(), fmt.Sprintf("ruby.%d", i)) // Use 'ruby-cd' to make sure gitaly-ruby has the same working directory // as the current process. This is a hack to sort-of support relative diff --git a/internal/gitaly/rubyserver/rubyserver_test.go b/internal/gitaly/rubyserver/rubyserver_test.go index dceb98d17..d852841a1 100644 --- a/internal/gitaly/rubyserver/rubyserver_test.go +++ b/internal/gitaly/rubyserver/rubyserver_test.go @@ -98,8 +98,8 @@ func (mockGitCommandFactory) HooksPath(context.Context) string { func TestSetupEnv(t *testing.T) { cfg := config.Cfg{ - BinDir: "/bin/dit", - InternalSocketDir: "/gitaly", + BinDir: "/bin/dit", + RuntimeDir: "/gitaly", Logging: config.Logging{ Config: log.Config{ Dir: "/log/dir", @@ -122,7 +122,7 @@ func TestSetupEnv(t *testing.T) { require.Contains(t, env, fmt.Sprintf("GITALY_RUBY_MAX_COMMIT_OR_TAG_MESSAGE_SIZE=%d", helper.MaxCommitOrTagMessageSize)) require.Contains(t, env, "GITALY_RUBY_GITALY_BIN_DIR=/bin/dit") require.Contains(t, env, "GITALY_VERSION="+version.GetVersion()) - require.Contains(t, env, fmt.Sprintf("GITALY_SOCKET=%s", cfg.GitalyInternalSocketPath())) + require.Contains(t, env, fmt.Sprintf("GITALY_SOCKET=%s", cfg.InternalSocketPath())) require.Contains(t, env, "GITALY_TOKEN=paswd") require.Contains(t, env, "GITALY_RUGGED_GIT_CONFIG_SEARCH_PATH=/bin/rugged") require.Contains(t, env, "SENTRY_DSN=testDSN") diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go index 7a660f91d..7a7badde7 100644 --- a/internal/gitaly/service/operations/branches_test.go +++ b/internal/gitaly/service/operations/branches_test.go @@ -147,7 +147,7 @@ func TestUserCreateBranchWithTransaction(t *testing.T) { }, { desc: "Unix socket", - address: "unix://" + cfg.GitalyInternalSocketPath(), + address: "unix://" + cfg.InternalSocketPath(), }, } @@ -490,7 +490,7 @@ func TestUserDeleteBranch_transaction(t *testing.T) { require.NoError(t, err) ctx = metadata.IncomingToOutgoing(ctx) - client := newMuxedOperationClient(t, ctx, fmt.Sprintf("unix://"+cfg.GitalyInternalSocketPath()), cfg.Auth.Token, + client := newMuxedOperationClient(t, ctx, fmt.Sprintf("unix://"+cfg.InternalSocketPath()), cfg.Auth.Token, backchannel.NewClientHandshaker( testhelper.NewDiscardingLogEntry(t), func() backchannel.Server { diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go index 9018e4345..bb5957023 100644 --- a/internal/gitaly/service/operations/tags_test.go +++ b/internal/gitaly/service/operations/tags_test.go @@ -273,7 +273,7 @@ func TestUserCreateTagWithTransaction(t *testing.T) { // transaction information we inject further down below. So we instead // use internal socket so we can circumvent Praefect and just talk // to Gitaly directly. - client := newMuxedOperationClient(t, ctx, "unix://"+cfg.GitalyInternalSocketPath(), cfg.Auth.Token, + client := newMuxedOperationClient(t, ctx, "unix://"+cfg.InternalSocketPath(), cfg.Auth.Token, backchannel.NewClientHandshaker( testhelper.NewDiscardingLogEntry(t), func() backchannel.Server { diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go index 802e3db7d..63a76ab66 100644 --- a/internal/gitaly/service/repository/apply_gitattributes_test.go +++ b/internal/gitaly/service/repository/apply_gitattributes_test.go @@ -111,7 +111,7 @@ func TestApplyGitattributesWithTransaction(t *testing.T) { // carefully crafted transaction and server information. logger := testhelper.NewDiscardingLogEntry(t) - client := newMuxedRepositoryClient(t, ctx, cfg, "unix://"+cfg.GitalyInternalSocketPath(), + client := newMuxedRepositoryClient(t, ctx, cfg, "unix://"+cfg.InternalSocketPath(), backchannel.NewClientHandshaker(logger, func() backchannel.Server { srv := grpc.NewServer() gitalypb.RegisterRefTransactionServer(srv, transactionServer) diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go index e7349ac80..54f07fe26 100644 --- a/internal/gitaly/service/smarthttp/receive_pack_test.go +++ b/internal/gitaly/service/smarthttp/receive_pack_test.go @@ -104,7 +104,7 @@ func TestSuccessfulReceivePackRequest(t *testing.T) { require.Equal(t, git.HooksPayload{ RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), InternalSocketToken: cfg.Auth.Token, ReceiveHooksPayload: &git.ReceiveHooksPayload{ UserID: "123", diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index 6439446bd..c99d99ee4 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -159,7 +159,7 @@ func TestReceivePackPushSuccess(t *testing.T) { require.Equal(t, git.HooksPayload{ RuntimeDir: cfg.RuntimeDir, - InternalSocket: cfg.GitalyInternalSocketPath(), + InternalSocket: cfg.InternalSocketPath(), InternalSocketToken: cfg.Auth.Token, ReceiveHooksPayload: &git.ReceiveHooksPayload{ UserID: "123", diff --git a/internal/testhelper/testcfg/gitaly_builder.go b/internal/testhelper/testcfg/gitaly_builder.go index 855bbe549..86974e4a6 100644 --- a/internal/testhelper/testcfg/gitaly_builder.go +++ b/internal/testhelper/testcfg/gitaly_builder.go @@ -109,11 +109,7 @@ func (gc *GitalyCfgBuilder) Build(t testing.TB) config.Cfg { if cfg.RuntimeDir == "" { cfg.RuntimeDir = filepath.Join(root, "runtime.d") require.NoError(t, os.Mkdir(cfg.RuntimeDir, 0o700)) - } - - if cfg.InternalSocketDir == "" { - cfg.InternalSocketDir = filepath.Join(cfg.RuntimeDir, "sock.d") - require.NoError(t, os.Mkdir(cfg.InternalSocketDir, 0o755)) + require.NoError(t, os.Mkdir(cfg.InternalSocketDir(), 0o755)) } if len(cfg.Storages) != 0 && len(gc.storages) != 0 { diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go index 753a579e3..6033e7e12 100644 --- a/internal/testhelper/testserver/gitaly.go +++ b/internal/testhelper/testserver/gitaly.go @@ -161,7 +161,7 @@ func runGitaly(t testing.TB, cfg config.Cfg, rubyServer *rubyserver.Server, regi []*limithandler.LimiterMiddleware{deps.GetLimitHandler()}, ) - if cfg.InternalSocketDir != "" { + if cfg.RuntimeDir != "" { internalServer, err := serverFactory.CreateInternal() require.NoError(t, err) t.Cleanup(internalServer.Stop) @@ -169,10 +169,10 @@ func runGitaly(t testing.TB, cfg config.Cfg, rubyServer *rubyserver.Server, regi registrar(internalServer, deps) registerHealthServerIfNotRegistered(internalServer) - require.NoError(t, os.MkdirAll(cfg.InternalSocketDir, 0o700)) - t.Cleanup(func() { require.NoError(t, os.RemoveAll(cfg.InternalSocketDir)) }) + require.NoError(t, os.MkdirAll(cfg.InternalSocketDir(), 0o700)) + t.Cleanup(func() { require.NoError(t, os.RemoveAll(cfg.InternalSocketDir())) }) - internalListener, err := net.Listen("unix", cfg.GitalyInternalSocketPath()) + internalListener, err := net.Listen("unix", cfg.InternalSocketPath()) require.NoError(t, err) go func() { assert.NoError(t, internalServer.Serve(internalListener), "failure to serve internal gRPC") |