Fix UNIX socket file too long
Why do we need this MR
My system version is macOS 11.4
.
I tried to execute a go test, got FAIL like this:
test command and log:
GOROOT=/Users/cbd/.asdf/installs/golang/1.16.4/go #gosetup
GOPATH=/Users/cbd/go #gosetup
/Users/cbd/.asdf/installs/golang/1.16.4/go/bin/go test -c -o /private/var/folders/yn/9bkfy_zs6nx881snv4_t_44c0000gn/T/___TestUserCommitFiles_in_gitlab_com_gitlab_org_gitaly_v14_internal_gitaly_service_operations.test gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/operations #gosetup
/Users/cbd/.asdf/installs/golang/1.16.4/go/bin/go tool test2json -t /private/var/folders/yn/9bkfy_zs6nx881snv4_t_44c0000gn/T/___TestUserCommitFiles_in_gitlab_com_gitlab_org_gitaly_v14_internal_gitaly_service_operations.test -test.v -test.paniconexit0 -test.run ^\QTestUserCommitFiles\E$
=== RUN TestUserCommitFiles
gitaly_builder.go:151:
Error Trace: gitaly_builder.go:125
gitaly_builder.go:151
testhelper_test.go:73
commit_files_test.go:36
Error: Received unexpected error:
socket could not be created in /var/folders/yn/9bkfy_zs6nx881snv4_t_44c0000gn/T/gitaly-801540891/519633854/internal_socks.d: listen unix /var/folders/yn/9bkfy_zs6nx881snv4_t_44c0000gn/T/gitaly-801540891/519633854/internal_socks.d/test-fd848dac.sock: bind: invalid argument
Although the message here is bind: invalid argument
, the real reason is that the unix socket file path is too long.
Here, ioutil.TempDir
returned to a macOS-style temporary directory: /var/folders/yn/9bkfy_zs6nx881snv4_t_44c0000gn/T/
. It's too long.
By the way, we can find the prompt from the man unix
:
UNIX-domain addresses are variable-length filesystem pathnames of at most 104 characters.
Why did I do this
After modification, we will get such a temporary directory: /tmp/gitaly-238865111
.
It's short and has good compatibility.
Edited by Baodong