As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 5b5e00ce authored by Igor Drozdov's avatar Igor Drozdov
Browse files

Put reuse Gitaly connections behind feature flag

The connections get canceled due to some shared state
Let's try disabling reusing Gitaly connections and see
whether anything changes
parent c8ba21bd
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -42,7 +42,11 @@ func (c *Client) InitSidechannelRegistry(ctx context.Context) {
c.SidechannelRegistry = gitalyclient.NewSidechannelRegistry(log.ContextLogger(ctx))
}
func (c *Client) GetConnection(ctx context.Context, cmd Command) (*grpc.ClientConn, error) {
func (c *Client) GetConnection(ctx context.Context, reuseConnections bool, cmd Command) (*grpc.ClientConn, error) {
if !reuseConnections {
return c.newConnection(ctx, cmd)
}
c.cache.RLock()
conn := c.cache.connections[cmd]
c.cache.RUnlock()
Loading
Loading
Loading
Loading
@@ -37,17 +37,21 @@ func TestCachedConnections(t *testing.T) {
cmd := Command{ServiceName: "git-upload-pack", Address: "tcp://localhost:9999"}
conn, err := c.GetConnection(context.Background(), cmd)
conn, err := c.GetConnection(context.Background(), false, cmd)
require.NoError(t, err)
require.Len(t, c.cache.connections, 0)
conn, err = c.GetConnection(context.Background(), true, cmd)
require.NoError(t, err)
require.Len(t, c.cache.connections, 1)
newConn, err := c.GetConnection(context.Background(), cmd)
newConn, err := c.GetConnection(context.Background(), true, cmd)
require.NoError(t, err)
require.Len(t, c.cache.connections, 1)
require.Equal(t, conn, newConn)
cmd = Command{ServiceName: "git-upload-pack", Address: "tcp://localhost:9998"}
_, err = c.GetConnection(context.Background(), cmd)
_, err = c.GetConnection(context.Background(), true, cmd)
require.NoError(t, err)
require.Len(t, c.cache.connections, 2)
}
Loading
Loading
Loading
Loading
@@ -32,10 +32,11 @@ type Request struct {
}
type Gitaly struct {
Repo pb.Repository `json:"repository"`
Address string `json:"address"`
Token string `json:"token"`
Features map[string]string `json:"features"`
Repo pb.Repository `json:"repository"`
Address string `json:"address"`
Token string `json:"token"`
Features map[string]string `json:"features"`
ReuseConnections bool `json:"reuse_gitaly_connections"`
}
type CustomPayloadData struct {
Loading
Loading
Loading
Loading
@@ -119,5 +119,5 @@ func withOutgoingMetadata(ctx context.Context, features map[string]string) conte
}
func (gc *GitalyCommand) getConn(ctx context.Context) (*grpc.ClientConn, error) {
return gc.Config.GitalyClient.GetConnection(ctx, gc.Command)
return gc.Config.GitalyClient.GetConnection(ctx, gc.Response.Gitaly.ReuseConnections, gc.Command)
}
Loading
Loading
@@ -50,8 +50,9 @@ func TestCachingOfGitalyConnections(t *testing.T) {
response := &accessverifier.Response{
Username: "user",
Gitaly: accessverifier.Gitaly{
Address: "tcp://localhost:9999",
Token: "token",
Address: "tcp://localhost:9999",
Token: "token",
ReuseConnections: true,
},
}
Loading
Loading
@@ -69,7 +70,7 @@ func TestCachingOfGitalyConnections(t *testing.T) {
}
func TestMissingGitalyAddress(t *testing.T) {
cmd := GitalyCommand{Config: newConfig()}
cmd := GitalyCommand{Config: newConfig(), Response: &accessverifier.Response{}}
err := cmd.RunGitalyCommand(context.Background(), makeHandler(t, nil))
require.EqualError(t, err, "no gitaly_address given")
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment