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:
authorSami Hiltunen <shiltunen@gitlab.com>2021-03-26 16:27:30 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-03-26 16:48:45 +0300
commite381be85fd6b44d99a0d5e5b372fc423a076b165 (patch)
tree08801dbe4451aa73d7703060868974277a7c9602
parentf7b6fea190ed73d75c1588805be6c329f02f193d (diff)
prevent running reconcile with repository specific primaries
`praefect reconcile` command is unnecessary with repository specific primaries and doesn't work together with them. There are few reasons for this: 1. When repository specific primaries are enabled, Praefect expects to have database records for every repository. As such, the automatic reconciler can already perform all of the reconciling the manual command would do. This makes the manual command unnecessary. 2. The manual command works on the level of a storage. Running the command would very likely result in jobs from secondaries to the primaries. While this is not harmful as Praefect has checks against downgrading, we should not produce such jobs. 3. Reconcile automatically figures out the primary of the virtual storage and uses it as the reference storage. This is not a good approach as the primary might not even be up to date. More so, there is no single primary when repository specific primaries are enabled. Due to the above points, the reconcile subcommand is not needed when repository specific primaries are enabled. While we should keep it around for backwards compatibility as long as virtual storage scoped primaries can be enabled, we should prevent it from being used with repository specific primaries.
-rw-r--r--internal/praefect/service/info/consistencycheck.go8
-rw-r--r--internal/praefect/service/info/consistencycheck_test.go12
2 files changed, 20 insertions, 0 deletions
diff --git a/internal/praefect/service/info/consistencycheck.go b/internal/praefect/service/info/consistencycheck.go
index 1f1b0c399..3d7848768 100644
--- a/internal/praefect/service/info/consistencycheck.go
+++ b/internal/praefect/service/info/consistencycheck.go
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/middleware/metadatahandler"
+ "gitlab.com/gitlab-org/gitaly/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/internal/praefect/nodes"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -16,9 +17,15 @@ import (
"google.golang.org/grpc/status"
)
+var errRepositorySpecificPrimariesUnsupported = status.Error(codes.FailedPrecondition, "`praefect reconcile` should not be used with repository specific primaries enabled. Please enable automatic reconciler instead.")
+
var errReconciliationInternal = errors.New("internal error(s) occurred during execution")
func (s *Server) validateConsistencyCheckRequest(req *gitalypb.ConsistencyCheckRequest) error {
+ if s.conf.Failover.ElectionStrategy == config.ElectionStrategyPerRepository {
+ return errRepositorySpecificPrimariesUnsupported
+ }
+
if req.GetTargetStorage() == "" {
return status.Error(codes.InvalidArgument, "missing target storage")
}
@@ -32,6 +39,7 @@ func (s *Server) validateConsistencyCheckRequest(req *gitalypb.ConsistencyCheckR
req.GetTargetStorage(), req.GetReferenceStorage(),
)
}
+
return nil
}
diff --git a/internal/praefect/service/info/consistencycheck_test.go b/internal/praefect/service/info/consistencycheck_test.go
index e9266784c..2a77e7d0f 100644
--- a/internal/praefect/service/info/consistencycheck_test.go
+++ b/internal/praefect/service/info/consistencycheck_test.go
@@ -28,6 +28,18 @@ import (
"google.golang.org/grpc/status"
)
+func TestServer_ConsistencyCheck_repositorySpecificPrimariesUnsupported(t *testing.T) {
+ require.Equal(
+ t,
+ errRepositorySpecificPrimariesUnsupported,
+ NewServer(nil,
+ config.Config{
+ Failover: config.Failover{ElectionStrategy: config.ElectionStrategyPerRepository},
+ }, nil, nil, nil,
+ ).ConsistencyCheck(nil, nil),
+ )
+}
+
func TestServer_ConsistencyCheck(t *testing.T) {
cfg := gconfig.Config