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>2022-05-05 12:55:55 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-05 12:55:55 +0300
commit3f35f74cbd48f0a1557cd567087f685feede6672 (patch)
treec7367339db74fa05695dcaa92348acdb74198582
parent1f98d5a94c880e3e556ae3ace095f83e44f002fb (diff)
parentb25bd0f037a2b8a4ee1973c5831a588615a3d990 (diff)
Merge branch 'pks-gitaly-internal-sockets-trim-max-length' into 'master'
gitaly: Shorten maximum internal socket path length See merge request gitlab-org/gitaly!4523
-rw-r--r--internal/gitaly/config/config.go20
-rw-r--r--internal/gitaly/config/config_test.go4
2 files changed, 12 insertions, 12 deletions
diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go
index 96943a850..8ed64b565 100644
--- a/internal/gitaly/config/config.go
+++ b/internal/gitaly/config/config.go
@@ -18,7 +18,6 @@ import (
internallog "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/log"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/prometheus"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/sentry"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
)
const (
@@ -399,7 +398,7 @@ func (cfg *Cfg) InternalSocketDir() string {
// 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()))
+ return filepath.Join(cfg.InternalSocketDir(), "intern")
}
func (cfg *Cfg) validateBinDir() error {
@@ -478,7 +477,7 @@ func (cfg *Cfg) validateInternalSocketDir() error {
}
if err := trySocketCreation(cfg.InternalSocketDir()); err != nil {
- return fmt.Errorf("internal_socket_dir: try create socket: %w", err)
+ return fmt.Errorf("failed creating internal test socket: %w", err)
}
return nil
@@ -487,13 +486,14 @@ func (cfg *Cfg) validateInternalSocketDir() error {
func trySocketCreation(dir string) error {
// To validate the socket can actually be created, we open and close a socket.
// Any error will be assumed persistent for when the gitaly-ruby sockets are created
- // and thus fatal at boot time
- b, err := text.RandomHex(4)
- if err != nil {
- return err
- }
-
- socketPath := filepath.Join(dir, fmt.Sprintf("test-%s.sock", b))
+ // and thus fatal at boot time.
+ //
+ // There are two kinds of internal sockets we create: the internal server socket
+ // called "intern", and then the Ruby worker sockets called "ruby.$N", with "$N"
+ // being the number of the Ruby worker. Given that we typically wouldn't spawn
+ // hundreds of Ruby workers, the maximum internal socket path name would thus be 7
+ // characters long.
+ socketPath := filepath.Join(dir, "tsocket")
defer func() { _ = os.Remove(socketPath) }()
// Attempt to create an actual socket and not just a file to catch socket path length problems
diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go
index 02fc1855c..d683fa352 100644
--- a/internal/gitaly/config/config_test.go
+++ b/internal/gitaly/config/config_test.go
@@ -680,9 +680,9 @@ func TestValidateInternalSocketDir(t *testing.T) {
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",
+ "failed creating internal test 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"),
+ filepath.Join(runtimeDir, "sock\\.d", "tsocket"),
),
actualErr.Error(),
)