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:
Diffstat (limited to 'internal/praefect/coordinator.go')
-rw-r--r--internal/praefect/coordinator.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index ef9bbdc28..a476b61c9 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -12,6 +12,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/sirupsen/logrus"
+ internalerrs "gitlab.com/gitlab-org/gitaly/internal/errors"
"gitlab.com/gitlab-org/gitaly/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/internal/praefect/conn"
"gitlab.com/gitlab-org/gitaly/internal/praefect/datastore"
@@ -19,6 +20,8 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/praefect/models"
"gitlab.com/gitlab-org/gitaly/internal/praefect/protoregistry"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
)
func isDestructive(methodName string) bool {
@@ -81,9 +84,19 @@ func (c *Coordinator) streamDirector(ctx context.Context, fullMethodName string,
var storage string
if mi.Scope == protoregistry.ScopeRepository {
- storage, requestFinalizer, err = c.getStorageForRepositoryMessage(mi, m, peeker, fullMethodName)
- if err != nil {
- return nil, err
+ var getRepoErr error
+ storage, requestFinalizer, getRepoErr = c.getStorageForRepositoryMessage(mi, m, peeker, fullMethodName)
+
+ if getRepoErr == protoregistry.ErrTargetRepoMissing {
+ return nil, status.Errorf(codes.InvalidArgument, getRepoErr.Error())
+ }
+
+ if getRepoErr != nil {
+ return nil, getRepoErr
+ }
+
+ if storage == "" {
+ return nil, status.Error(codes.InvalidArgument, "storage not found")
}
} else {
storage, requestFinalizer, err = c.getAnyStorageNode()
@@ -185,6 +198,9 @@ func (c *Coordinator) selectPrimary(mi protoregistry.MethodInfo, targetRepo *git
newPrimary, err := c.datastore.PickAPrimary(targetRepo.GetStorageName())
if err != nil {
+ if err == datastore.ErrNoPrimaryForStorage {
+ return nil, status.Error(codes.InvalidArgument, internalerrs.ErrInvalidRepository.Error())
+ }
return nil, fmt.Errorf("could not choose a primary: %v", err)
}