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:
authorSami Hiltunen <shiltunen@gitlab.com>2022-07-07 19:03:35 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-07-08 14:33:51 +0300
commit94efb3dbb2aef7482bcd7b1be3c00d9b97febd9e (patch)
tree43f0bf4e3a53e0d01fa56a08bac243d2017644aa
parentf30d27e6c3dc7070d738364f28e9e0734b79b44c (diff)
Move trySocketCreation closer to SetupRuntimeDirectory
trySocketCreation is used from SetupRuntimeDirectory. Move it closer to the caller so it is easier to find.
-rw-r--r--internal/gitaly/config/config.go54
1 files changed, 27 insertions, 27 deletions
diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go
index 8e32468aa..e05ee173b 100644
--- a/internal/gitaly/config/config.go
+++ b/internal/gitaly/config/config.go
@@ -432,33 +432,6 @@ func (cfg *Cfg) validateToken() error {
return nil
}
-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.
- //
- // 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
- l, err := net.Listen("unix", socketPath)
- if err != nil {
- var errno syscall.Errno
- if errors.As(err, &errno) && errno == syscall.EINVAL {
- return fmt.Errorf("%w: your socket path is likely too long, please change Gitaly's runtime directory", errno)
- }
-
- return fmt.Errorf("socket could not be created in %s: %w", dir, err)
- }
-
- return l.Close()
-}
-
// defaultMaintenanceWindow specifies a 10 minute job that runs daily at +1200
// GMT time
func defaultMaintenanceWindow(storages []Storage) DailyJob {
@@ -616,3 +589,30 @@ func SetupRuntimeDirectory(cfg Cfg, processID int) (string, error) {
return runtimeDir, nil
}
+
+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.
+ //
+ // 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
+ l, err := net.Listen("unix", socketPath)
+ if err != nil {
+ var errno syscall.Errno
+ if errors.As(err, &errno) && errno == syscall.EINVAL {
+ return fmt.Errorf("%w: your socket path is likely too long, please change Gitaly's runtime directory", errno)
+ }
+
+ return fmt.Errorf("socket could not be created in %s: %w", dir, err)
+ }
+
+ return l.Close()
+}