vmauth: add broken backend backoff flag (#4416)

vmauth: allow configuring deadline for a backend to be excluded from the rotation

The new flag `-failTimeout` allows overriding default time for a bad backend
to be excluded from rotation. The override option could be useful for systems
where it is expected for backends to be off for significant periods of time. 

Co-authored-by: Zakhar Bessarab <zekker6@gmail.com>
This commit is contained in:
SunKyu Lee 2023-08-02 21:30:21 +09:00 committed by Aliaksandr Valialkin
parent d443ab5ae1
commit 1d2f0e8c7b
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
3 changed files with 4 additions and 1 deletions

View file

@ -351,6 +351,8 @@ See the docs at https://docs.victoriametrics.com/vmauth.html .
Prefix for environment variables if -envflag.enable is set
-eula
By specifying this flag, you confirm that you have an enterprise license and accept the EULA https://victoriametrics.com/assets/VM_EULA.pdf . This flag is available only in VictoriaMetrics enterprise. See https://docs.victoriametrics.com/enterprise.html
-failTimeout duration
Sets a delay period for load balancing to skip a malfunctioning backend. (defaults 3s)
-flagsAuthKey string
Auth key for /flags endpoint. It must be passed via authKey query arg. It overrides httpAuth.* settings
-fs.disableMmap

View file

@ -134,7 +134,7 @@ func (bu *backendURL) isBroken() bool {
}
func (bu *backendURL) setBroken() {
deadline := fasttime.UnixTimestamp() + 3
deadline := fasttime.UnixTimestamp() + uint64((*failTimeout).Seconds())
atomic.StoreUint64(&bu.brokenDeadline, deadline)
}

View file

@ -41,6 +41,7 @@ var (
reloadAuthKey = flag.String("reloadAuthKey", "", "Auth key for /-/reload http endpoint. It must be passed as authKey=...")
logInvalidAuthTokens = flag.Bool("logInvalidAuthTokens", false, "Whether to log requests with invalid auth tokens. "+
`Such requests are always counted at vmauth_http_request_errors_total{reason="invalid_auth_token"} metric, which is exposed at /metrics page`)
failTimeout = flag.Duration("failTimeout", 3*time.Second, "Sets a delay period for load balancing to skip a malfunctioning backend.")
)
func main() {