diff options
author | John Cai <jcai@gitlab.com> | 2022-06-14 00:22:09 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2022-06-14 00:22:09 +0300 |
commit | 5644e0d65368019af895bf5b64eb573458d4191d (patch) | |
tree | fcb9db0033932ec44bd2f34020db5e09eaac950b | |
parent | d89db46409cb8f1ac0fc732d674aedf934a6582d (diff) |
nodes: Add failover timeout configurationjc-sql-elector-timeout-config
Currently the failover timeout is hardcoded to 10 seconds. It'd be
beneficial for system administrators to be able to configure this.
Allow the failover timeout to be configured.
Changelog: changed
-rw-r--r-- | internal/praefect/config/config.go | 2 | ||||
-rw-r--r-- | internal/praefect/nodes/sql_elector.go | 2 | ||||
-rw-r--r-- | internal/praefect/nodes/sql_elector_test.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index 8b7c7750e..6c75a3448 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -54,7 +54,7 @@ type Failover struct { // MonitorInterval allows set a time duration that would be used after bootstrap is completed to execute health checks. // The default value is 3s. MonitorInterval config.Duration `toml:"monitor_interval,omitempty"` - FailoverTimeout time.Duration `toml:"failover_timeout,omitempty"` + Timeout time.Duration `toml:"timeout,omitempty"` } // ErrorThresholdsConfigured checks whether returns whether the errors thresholds are configured. If they diff --git a/internal/praefect/nodes/sql_elector.go b/internal/praefect/nodes/sql_elector.go index 8a23d0c4b..6003da95a 100644 --- a/internal/praefect/nodes/sql_elector.go +++ b/internal/praefect/nodes/sql_elector.go @@ -99,7 +99,7 @@ func newSQLElector(name string, c config.Config, db *sql.DB, log logrus.FieldLog nodes[i] = &sqlCandidate{Node: n} } - failoverTimeout := c.Failover.FailoverTimeout + failoverTimeout := c.Failover.Timeout if failoverTimeout == 0 { failoverTimeout = defaultFailoverTimeout } diff --git a/internal/praefect/nodes/sql_elector_test.go b/internal/praefect/nodes/sql_elector_test.go index 7e3dfd6f2..f22980be2 100644 --- a/internal/praefect/nodes/sql_elector_test.go +++ b/internal/praefect/nodes/sql_elector_test.go @@ -539,7 +539,7 @@ func TestFailoverTimeout(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { elector := newSQLElector("", config.Config{ Failover: config.Failover{ - FailoverTimeout: tc.failoverTimeout, + Timeout: tc.failoverTimeout, }, }, nil, testhelper.NewDiscardingLogEntry(t), []*nodeStatus{ {}, |