diff options
author | John Cai <jcai@gitlab.com> | 2020-06-25 20:40:09 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2020-08-31 17:24:54 +0300 |
commit | 1320783bf1f353850c7837aac3e51f7d3331a107 (patch) | |
tree | 7462e6e237c6e03724356f95a4b8a5f3196e5da7 /internal/praefect/config | |
parent | 1f0b1740e98525102b3b1c6650a01cd57fe311c7 (diff) |
Use error tracker to determine if node is healthy
Hooks up the error tracker in the node manager so it checks if a certain
backend node has reached a threshold of errors. If it has, then it will
be deemed unhealthy.
Diffstat (limited to 'internal/praefect/config')
-rw-r--r-- | internal/praefect/config/config.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index 3b447f977..2c8836e32 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -28,6 +28,28 @@ type Failover struct { MonitorInterval config.Duration `toml:"monitor_interval"` } +// ErrorThresholdsConfigured checks whether returns whether the errors thresholds are configured. If they +// are configured but in an invalid way, an error is returned. +func (f Failover) ErrorThresholdsConfigured() (bool, error) { + if f.ErrorThresholdWindow == 0 && f.WriteErrorThresholdCount == 0 && f.ReadErrorThresholdCount == 0 { + return false, nil + } + + if f.ErrorThresholdWindow == 0 { + return false, errors.New("threshold window not set") + } + + if f.WriteErrorThresholdCount == 0 { + return false, errors.New("write error threshold not set") + } + + if f.ReadErrorThresholdCount == 0 { + return false, errors.New("read error threshold not set") + } + + return true, nil +} + const sqlFailoverValue = "sql" // Replication contains replication specific configuration options. |