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-05-26 13:46:52 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-05-26 14:25:06 +0300
commit54948e21921527e0b455a56b601854d152e58ba2 (patch)
treee08f767dcdf4d4d0efc8bf6a6ef07aef4d4abda6
parent6e58da454633a53c86d14a59587ee7a6a9d11031 (diff)
Prevent usage of other election strategies than per_repository
Praefect's legacy election strategies have been deprecated in 13.12 and are scheduled for removal in 14.0. This commit switches the `per_repository` to be the default election strategy and ignores the `failover.election_strategy` configuration key. As there are still some tests in Gitaly's repo and in GitLab's repo which are not configured to use the database, there's an additional configuration key added which allows for still configuring the other election strategies. Changelog: removed
-rw-r--r--cmd/praefect/main.go4
-rw-r--r--config.praefect.toml.example1
-rw-r--r--internal/praefect/config/config.go3
-rw-r--r--internal/praefect/config/config_test.go4
-rw-r--r--internal/testhelper/testserver/gitaly.go3
5 files changed, 10 insertions, 5 deletions
diff --git a/cmd/praefect/main.go b/cmd/praefect/main.go
index 3f8ee04d1..96c58bd3f 100644
--- a/cmd/praefect/main.go
+++ b/cmd/praefect/main.go
@@ -188,6 +188,10 @@ func initConfig() (config.Config, error) {
return config.Config{}, err
}
+ if !conf.AllowLegacyElectors {
+ conf.Failover.ElectionStrategy = config.ElectionStrategyPerRepository
+ }
+
if !conf.Failover.Enabled && conf.Failover.ElectionStrategy != "" {
logger.WithField("election_strategy", conf.Failover.ElectionStrategy).Warn(
"ignoring configured election strategy as failover is disabled")
diff --git a/config.praefect.toml.example b/config.praefect.toml.example
index 1afb7f890..afe0f9153 100644
--- a/config.praefect.toml.example
+++ b/config.praefect.toml.example
@@ -48,7 +48,6 @@ histogram_buckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]
[failover]
enabled = true
-election_strategy = "sql" # Options: local, sql, per_repository. Defaults to 'sql'.
[[virtual_storage]]
name = 'praefect'
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go
index a82d35729..3acc17047 100644
--- a/internal/praefect/config/config.go
+++ b/internal/praefect/config/config.go
@@ -106,6 +106,7 @@ func DefaultReplicationConfig() Replication {
// Config is a container for everything found in the TOML config file
type Config struct {
+ AllowLegacyElectors bool `toml:"i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning"`
Reconciliation Reconciliation `toml:"reconciliation"`
Replication Replication `toml:"replication"`
ListenAddr string `toml:"listen_addr"`
@@ -149,7 +150,7 @@ func FromFile(filePath string) (Config, error) {
Reconciliation: DefaultReconciliationConfig(),
Replication: DefaultReplicationConfig(),
// Sets the default Failover, to be overwritten when deserializing the TOML
- Failover: Failover{Enabled: true, ElectionStrategy: ElectionStrategySQL},
+ Failover: Failover{Enabled: true, ElectionStrategy: ElectionStrategyPerRepository},
}
if err := toml.Unmarshal(b, conf); err != nil {
return Config{}, err
diff --git a/internal/praefect/config/config_test.go b/internal/praefect/config/config_test.go
index 9bcfe56fb..f8f803b07 100644
--- a/internal/praefect/config/config_test.go
+++ b/internal/praefect/config/config_test.go
@@ -295,7 +295,7 @@ func TestConfigParsing(t *testing.T) {
Replication: Replication{BatchSize: 1},
Failover: Failover{
Enabled: true,
- ElectionStrategy: ElectionStrategySQL,
+ ElectionStrategy: ElectionStrategyPerRepository,
ErrorThresholdWindow: config.Duration(20 * time.Second),
WriteErrorThresholdCount: 1500,
ReadErrorThresholdCount: 100,
@@ -331,7 +331,7 @@ func TestConfigParsing(t *testing.T) {
Replication: DefaultReplicationConfig(),
Failover: Failover{
Enabled: true,
- ElectionStrategy: ElectionStrategySQL,
+ ElectionStrategy: ElectionStrategyPerRepository,
BootstrapInterval: config.Duration(time.Second),
MonitorInterval: config.Duration(3 * time.Second),
},
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 0735636d0..90d74a620 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -59,7 +59,8 @@ func runPraefectProxy(t testing.TB, cfg config.Cfg, gitalyAddr, praefectBinPath
praefectServerSocketPath := "unix://" + testhelper.GetTemporaryGitalySocketFileName(t)
conf := praefectconfig.Config{
- SocketPath: praefectServerSocketPath,
+ AllowLegacyElectors: true,
+ SocketPath: praefectServerSocketPath,
Auth: auth.Config{
Token: cfg.Auth.Token,
},