Skip to content

Commit 84324a0

Browse files
Patrick BajaoQuang-Minh Nguyen
Patrick Bajao
and
Quang-Minh Nguyen
committed
Merge branch 'qmnguyen0711/add-client-side-load-balancing-options' into 'main'
Add DNS discovery support to Gitaly via client-side load-balancing options See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/717 Merged-by: Patrick Bajao <[email protected]> Approved-by: Oscar Tovar <[email protected]> Approved-by: Ash McKenzie <[email protected]> Approved-by: Patrick Bajao <[email protected]> Reviewed-by: Ash McKenzie <[email protected]> Reviewed-by: Quang-Minh Nguyen <[email protected]> Reviewed-by: Oscar Tovar <[email protected]> Co-authored-by: Quang-Minh Nguyen <[email protected]>
2 parents c099100 + 11227dd commit 84324a0

File tree

8 files changed

+404
-353
lines changed

8 files changed

+404
-353
lines changed

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ tests:
5656
extends: .test
5757
parallel:
5858
matrix:
59-
- GO_VERSION: ["golang-1.17", "golang-1.18", "golang-1.19"]
59+
- GO_VERSION: ["golang-1.18", "golang-1.19"]
6060
- RUBY_VERSION: ["ruby-2.7", "ruby-3.0"]
6161
script:
6262
- make verify test

client/testserver/gitalyserver.go

+32-11
Original file line numberDiff line numberDiff line change
@@ -85,30 +85,51 @@ func (s *TestGitalyServer) SSHUploadArchive(stream pb.SSHService_SSHUploadArchiv
8585
return nil
8686
}
8787

88-
func StartGitalyServer(t *testing.T) (string, *TestGitalyServer) {
88+
func StartGitalyServer(t *testing.T, network string) (string, *TestGitalyServer) {
8989
t.Helper()
9090

91-
tempDir, _ := os.MkdirTemp("", "gitlab-shell-test-api")
92-
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
93-
t.Cleanup(func() { os.RemoveAll(tempDir) })
91+
switch network {
92+
case "unix":
93+
tempDir, _ := os.MkdirTemp("", "gitlab-shell-test-api")
94+
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
95+
t.Cleanup(func() { require.NoError(t, os.RemoveAll(tempDir)) })
9496

95-
err := os.MkdirAll(filepath.Dir(gitalySocketPath), 0700)
96-
require.NoError(t, err)
97+
err := os.MkdirAll(filepath.Dir(gitalySocketPath), 0700)
98+
require.NoError(t, err)
99+
100+
addr, testServer := doStartTestServer(t, "unix", gitalySocketPath)
101+
return fmt.Sprintf("unix:%s", addr), testServer
102+
103+
case "tcp":
104+
addr, testServer := doStartTestServer(t, "tcp", "127.0.0.1:0")
105+
return fmt.Sprintf("tcp://%s", addr), testServer
106+
107+
case "dns":
108+
addr, testServer := doStartTestServer(t, "tcp", "127.0.0.1:0")
109+
// gRPC URL with DNS scheme follows this format: https://grpc.github.io/grpc/core/md_doc_naming.html
110+
// When the authority is dropped, the URL have 3 splashes.
111+
return fmt.Sprintf("dns:///%s", addr), testServer
97112

113+
default:
114+
panic(fmt.Sprintf("Unsupported network %s", network))
115+
}
116+
}
117+
118+
func doStartTestServer(t *testing.T, network string, path string) (string, *TestGitalyServer) {
98119
server := grpc.NewServer(
99120
client.SidechannelServer(log.ContextLogger(context.Background()), insecure.NewCredentials()),
100121
)
101122

102-
listener, err := net.Listen("unix", gitalySocketPath)
123+
listener, err := net.Listen(network, path)
103124
require.NoError(t, err)
104125

105126
testServer := TestGitalyServer{}
106127
pb.RegisterSSHServiceServer(server, &testServer)
107128

108-
go server.Serve(listener)
129+
go func() {
130+
require.NoError(t, server.Serve(listener))
131+
}()
109132
t.Cleanup(func() { server.Stop() })
110133

111-
gitalySocketUrl := "unix:" + gitalySocketPath
112-
113-
return gitalySocketUrl, &testServer
134+
return listener.Addr().String(), &testServer
114135
}

go.mod

+49-42
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,97 @@
11
module gitlab.com/gitlab-org/gitlab-shell/v14
22

3-
go 1.17
3+
go 1.18
44

55
require (
6-
github.com/golang-jwt/jwt/v4 v4.4.1
6+
github.com/golang-jwt/jwt/v4 v4.4.3
77
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
88
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
99
github.com/hashicorp/go-retryablehttp v0.7.1
10-
github.com/mattn/go-shellwords v1.0.11
10+
github.com/mattn/go-shellwords v1.0.12
1111
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
1212
github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b
1313
github.com/otiai10/copy v1.4.2
1414
github.com/pires/go-proxyproto v0.6.2
15-
github.com/prometheus/client_golang v1.13.1
15+
github.com/prometheus/client_golang v1.14.0
1616
github.com/sirupsen/logrus v1.9.0
17-
github.com/stretchr/testify v1.8.0
18-
gitlab.com/gitlab-org/gitaly/v15 v15.4.0-rc2
19-
gitlab.com/gitlab-org/labkit v1.16.0
20-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
21-
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
22-
google.golang.org/grpc v1.48.0
17+
github.com/stretchr/testify v1.8.1
18+
gitlab.com/gitlab-org/gitaly/v15 v15.9.0-rc4
19+
gitlab.com/gitlab-org/labkit v1.17.0
20+
golang.org/x/crypto v0.5.0
21+
golang.org/x/sync v0.1.0
22+
google.golang.org/grpc v1.53.0
2323
google.golang.org/protobuf v1.28.1
2424
gopkg.in/yaml.v2 v2.4.0
2525
)
2626

2727
require (
28-
cloud.google.com/go v0.100.2 // indirect
29-
cloud.google.com/go/compute v1.5.0 // indirect
30-
cloud.google.com/go/monitoring v1.4.0 // indirect
28+
cloud.google.com/go v0.107.0 // indirect
29+
cloud.google.com/go/compute v1.15.1 // indirect
30+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
31+
cloud.google.com/go/monitoring v1.9.0 // indirect
3132
cloud.google.com/go/profiler v0.1.0 // indirect
32-
cloud.google.com/go/trace v1.2.0 // indirect
33-
contrib.go.opencensus.io/exporter/stackdriver v0.13.10 // indirect
33+
cloud.google.com/go/trace v1.4.0 // indirect
34+
contrib.go.opencensus.io/exporter/stackdriver v0.13.14 // indirect
3435
github.com/DataDog/datadog-go v4.4.0+incompatible // indirect
3536
github.com/DataDog/sketches-go v1.0.0 // indirect
36-
github.com/Microsoft/go-winio v0.5.0 // indirect
37-
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
38-
github.com/aws/aws-sdk-go v1.43.31 // indirect
37+
github.com/Microsoft/go-winio v0.5.1 // indirect
38+
github.com/aws/aws-sdk-go v1.44.151 // indirect
3939
github.com/beevik/ntp v0.3.0 // indirect
4040
github.com/beorn7/perks v1.0.1 // indirect
41-
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
42-
github.com/cespare/xxhash/v2 v2.1.2 // indirect
41+
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
42+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
4343
github.com/client9/reopen v1.0.0 // indirect
4444
github.com/davecgh/go-spew v1.1.1 // indirect
45-
github.com/go-ole/go-ole v1.2.4 // indirect
45+
github.com/go-ole/go-ole v1.2.6 // indirect
4646
github.com/gogo/protobuf v1.3.2 // indirect
4747
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4848
github.com/golang/protobuf v1.5.2 // indirect
49-
github.com/google/go-cmp v0.5.8 // indirect
50-
github.com/google/pprof v0.0.0-20210804190019-f964ff605595 // indirect
49+
github.com/google/go-cmp v0.5.9 // indirect
50+
github.com/google/pprof v0.0.0-20221102093814-76f304f74e5e // indirect
5151
github.com/google/uuid v1.3.0 // indirect
52-
github.com/googleapis/gax-go/v2 v2.2.0 // indirect
53-
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
52+
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
53+
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
54+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
5455
github.com/hashicorp/yamux v0.1.1 // indirect
5556
github.com/jmespath/go-jmespath v0.4.0 // indirect
56-
github.com/kr/text v0.2.0 // indirect
57+
github.com/kr/pretty v0.3.1 // indirect
5758
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20210210170715-a8dfcb80d3a7 // indirect
5859
github.com/lightstep/lightstep-tracer-go v0.25.0 // indirect
59-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
60+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
61+
github.com/mattn/go-colorable v0.1.13 // indirect
62+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
6063
github.com/oklog/ulid/v2 v2.0.2 // indirect
64+
github.com/onsi/ginkgo v1.16.5 // indirect
65+
github.com/onsi/gomega v1.20.1 // indirect
6166
github.com/opentracing/opentracing-go v1.2.0 // indirect
6267
github.com/philhofer/fwd v1.1.1 // indirect
6368
github.com/pkg/errors v0.9.1 // indirect
6469
github.com/pmezard/go-difflib v1.0.0 // indirect
65-
github.com/prometheus/client_model v0.2.0 // indirect
70+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
71+
github.com/prometheus/client_model v0.3.0 // indirect
6672
github.com/prometheus/common v0.37.0 // indirect
6773
github.com/prometheus/procfs v0.8.0 // indirect
74+
github.com/prometheus/prometheus v0.40.5 // indirect
6875
github.com/sebest/xff v0.0.0-20210106013422-671bd2870b3a // indirect
69-
github.com/shirou/gopsutil/v3 v3.21.2 // indirect
76+
github.com/shirou/gopsutil/v3 v3.22.8 // indirect
7077
github.com/tinylib/msgp v1.1.2 // indirect
71-
github.com/tklauser/go-sysconf v0.3.4 // indirect
72-
github.com/tklauser/numcpus v0.2.1 // indirect
78+
github.com/tklauser/go-sysconf v0.3.10 // indirect
79+
github.com/tklauser/numcpus v0.4.0 // indirect
7380
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
7481
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
75-
go.opencensus.io v0.23.0 // indirect
76-
go.uber.org/atomic v1.9.0 // indirect
77-
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
78-
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
79-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
80-
golang.org/x/text v0.3.8 // indirect
81-
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
82-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
83-
google.golang.org/api v0.74.0 // indirect
82+
github.com/yusufpapurcu/wmi v1.2.2 // indirect
83+
go.opencensus.io v0.24.0 // indirect
84+
go.uber.org/atomic v1.10.0 // indirect
85+
golang.org/x/net v0.5.0 // indirect
86+
golang.org/x/oauth2 v0.4.0 // indirect
87+
golang.org/x/sys v0.5.0 // indirect
88+
golang.org/x/text v0.6.0 // indirect
89+
golang.org/x/time v0.3.0 // indirect
90+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
91+
google.golang.org/api v0.103.0 // indirect
8492
google.golang.org/appengine v1.6.7 // indirect
85-
google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de // indirect
93+
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
8694
gopkg.in/DataDog/dd-trace-go.v1 v1.32.0 // indirect
87-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
8895
gopkg.in/yaml.v3 v3.0.1 // indirect
8996
)
9097

0 commit comments

Comments
 (0)