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:
authorJohn Cai <jcai@gitlab.com>2020-04-16 03:28:47 +0300
committerJohn Cai <jcai@gitlab.com>2020-04-21 23:36:02 +0300
commit0ed728f329ba5ad8fe6b43777343192f56300c53 (patch)
tree2674e8726e4b1726da7c8e23dfd56e164d55a2d4 /internal/praefect/service/server
parent3bc638cb3a46b42e9f0b60eed5284dced0e3725a (diff)
Allow Praefect's ServerInfo RPC to succeed even if the internal gitaly node calls fail
Since the ServerInfo is for informational purposes, it doesn't help to fail the whole RPC if one of the internal gitaly calls results in an error. We should return whatever info we can.
Diffstat (limited to 'internal/praefect/service/server')
-rw-r--r--internal/praefect/service/server/info.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/internal/praefect/service/server/info.go b/internal/praefect/service/server/info.go
index 27a7f6c2b..7f16b367d 100644
--- a/internal/praefect/service/server/info.go
+++ b/internal/praefect/service/server/info.go
@@ -5,9 +5,7 @@ import (
"sync"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- "gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
- "golang.org/x/sync/errgroup"
)
// ServerInfo sends ServerInfoRequest to all of a praefect server's internal gitaly nodes and aggregates the results into
@@ -17,30 +15,35 @@ func (s *Server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest)
var gitVersion, serverVersion string
- g, ctx := errgroup.WithContext(ctx)
+ var wg sync.WaitGroup
storageStatuses := make([]*gitalypb.ServerInfoResponse_StorageStatus, len(s.conf.VirtualStorages))
for i, virtualStorage := range s.conf.VirtualStorages {
shard, err := s.nodeMgr.GetShard(virtualStorage.Name)
if err != nil {
- return nil, err
+ ctxlogrus.Extract(ctx).WithField("virtual_storage", virtualStorage.Name).WithError(err).Error("error when getting shard")
+ continue
}
primary, err := shard.GetPrimary()
if err != nil {
- return nil, err
+ ctxlogrus.Extract(ctx).WithField("virtual_storage", virtualStorage.Name).WithError(err).Error("error when getting primary")
+ continue
}
+ wg.Add(1)
i := i
virtualStorage := virtualStorage
- g.Go(func() error {
+ go func() {
+ defer wg.Done()
+
client := gitalypb.NewServerServiceClient(primary.GetConnection())
resp, err := client.ServerInfo(ctx, &gitalypb.ServerInfoRequest{})
if err != nil {
ctxlogrus.Extract(ctx).WithField("storage", primary.GetStorage()).WithError(err).Error("error getting server info")
- return nil
+ return
}
// From the perspective of the praefect client, a server info call should result in the server infos
@@ -78,14 +81,10 @@ func (s *Server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest)
once.Do(func() {
gitVersion, serverVersion = resp.GetGitVersion(), resp.GetServerVersion()
})
-
- return nil
- })
+ }()
}
- if err := g.Wait(); err != nil {
- return nil, helper.ErrInternal(err)
- }
+ wg.Wait()
return &gitalypb.ServerInfoResponse{
ServerVersion: serverVersion,