Unverified Commit 4068968e authored by Goutham Veeramachaneni's avatar Goutham Veeramachaneni Committed by GitHub
Browse files

Protect retention from overflowing (#5112)



Also sanitise the max block duration to max a month.

Signed-off-by: default avatarGoutham Veeramachaneni <gouthamve@gmail.com>
parent 384cba12
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"crypto/md5" "crypto/md5"
"encoding/json" "encoding/json"
"fmt" "fmt"
"math"
"net" "net"
"net/http" "net/http"
_ "net/http/pprof" // Comment this line to disable pprof endpoint. _ "net/http/pprof" // Comment this line to disable pprof endpoint.
...@@ -266,8 +267,23 @@ func main() { ...@@ -266,8 +267,23 @@ func main() {
cfg.tsdb.RetentionDuration = chooseRetention(oldFlagRetentionDuration, newFlagRetentionDuration) cfg.tsdb.RetentionDuration = chooseRetention(oldFlagRetentionDuration, newFlagRetentionDuration)
// Check for overflows. This limits our max retention to ~292.5y.
if cfg.tsdb.RetentionDuration < 0 {
cfg.tsdb.RetentionDuration = math.MaxInt64
}
if cfg.tsdb.MaxBlockDuration == 0 { if cfg.tsdb.MaxBlockDuration == 0 {
cfg.tsdb.MaxBlockDuration = cfg.tsdb.RetentionDuration / 10 cfg.tsdb.MaxBlockDuration = cfg.tsdb.RetentionDuration / 10
// Prevent blocks from getting too big.
monthLong, err := model.ParseDuration("31d")
if err != nil {
panic(err)
}
if cfg.tsdb.MaxBlockDuration > monthLong {
cfg.tsdb.MaxBlockDuration = monthLong
}
} }
promql.LookbackDelta = time.Duration(cfg.lookbackDelta) promql.LookbackDelta = time.Duration(cfg.lookbackDelta)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment