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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-19 12:28:43 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-19 19:44:10 +0300
commite7eeed02436d96b4a314cb260f46b9c35960a64d (patch)
tree99b75c4d55655399f88b4fd8451a86b9f8c1f022
parentc3a9fd04c1c8ed3b3cb9c2d0b837c2e44b7cbb3c (diff)
coordinator: Conditionally enable transactional config RPCs
Gitaly now supports transactional voting on `SetConfig()` and `DeleteConfig()`. Let's conditionally enable transactions for these RPCs if the feature flag is enabled.
-rw-r--r--internal/praefect/coordinator.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 107b61f1a..ea53a5fd4 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -38,6 +38,12 @@ type transactionsCondition func(context.Context) bool
func transactionsEnabled(context.Context) bool { return true }
func transactionsDisabled(context.Context) bool { return false }
+func transactionsFlag(flag featureflag.FeatureFlag) transactionsCondition {
+ return func(ctx context.Context) bool {
+ return featureflag.IsEnabled(ctx, flag)
+ }
+}
+
// transactionRPCs contains the list of repository-scoped mutating calls which may take part in
// transactions. An optional feature flag can be added to conditionally enable transactional
// behaviour. If none is given, it's always enabled.
@@ -82,6 +88,9 @@ var transactionRPCs = map[string]transactionsCondition{
"/gitaly.WikiService/WikiUpdatePage": transactionsEnabled,
"/gitaly.WikiService/WikiWritePage": transactionsEnabled,
+ "/gitaly.RepositoryService/SetConfig": transactionsFlag(featureflag.TxConfig),
+ "/gitaly.RepositoryService/DeleteConfig": transactionsFlag(featureflag.TxConfig),
+
// The following RPCs don't perform any reference updates and thus
// shouldn't use transactions.
"/gitaly.ObjectPoolService/CreateObjectPool": transactionsDisabled,
@@ -92,7 +101,6 @@ var transactionRPCs = map[string]transactionsCondition{
"/gitaly.ObjectPoolService/UnlinkRepositoryFromObjectPool": transactionsDisabled,
"/gitaly.RefService/PackRefs": transactionsDisabled,
"/gitaly.RepositoryService/Cleanup": transactionsDisabled,
- "/gitaly.RepositoryService/DeleteConfig": transactionsDisabled,
"/gitaly.RepositoryService/GarbageCollect": transactionsDisabled,
"/gitaly.RepositoryService/MidxRepack": transactionsDisabled,
"/gitaly.RepositoryService/OptimizeRepository": transactionsDisabled,
@@ -101,7 +109,6 @@ var transactionRPCs = map[string]transactionsCondition{
"/gitaly.RepositoryService/RepackFull": transactionsDisabled,
"/gitaly.RepositoryService/RepackIncremental": transactionsDisabled,
"/gitaly.RepositoryService/RestoreCustomHooks": transactionsDisabled,
- "/gitaly.RepositoryService/SetConfig": transactionsDisabled,
"/gitaly.RepositoryService/WriteCommitGraph": transactionsDisabled,
// These shouldn't ever use transactions for the sake of not creating