Skip to content

Commit cccfd73

Browse files
Make LivenessCheck Timeout Configurable (#6227)
1 parent a54da24 commit cccfd73

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/configuration/config-file-reference.md

+6
Original file line numberDiff line numberDiff line change
@@ -4480,6 +4480,12 @@ ring:
44804480
# Enable high availability
44814481
# CLI flag: -ruler.enable-ha-evaluation
44824482
[enable_ha_evaluation: <boolean> | default = false]
4483+
4484+
# Timeout duration for non-primary rulers during liveness checks. If the check
4485+
# times out, the non-primary ruler will evaluate the rule group. Applicable when
4486+
# ruler.enable-ha-evaluation is true.
4487+
# CLI flag: -ruler.liveness-check-timeout
4488+
[liveness_check_timeout: <duration> | default = 1s]
44834489
```
44844490

44854491
### `ruler_storage_config`

pkg/ruler/ruler.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ const (
8181
unknownHealthFilter string = "unknown"
8282
okHealthFilter string = "ok"
8383
errHealthFilter string = "err"
84-
85-
livenessCheckTimeout = 100 * time.Millisecond
8684
)
8785

8886
type DisabledRuleGroupErr struct {
@@ -161,7 +159,8 @@ type Config struct {
161159
EnableQueryStats bool `yaml:"query_stats_enabled"`
162160
DisableRuleGroupLabel bool `yaml:"disable_rule_group_label"`
163161

164-
EnableHAEvaluation bool `yaml:"enable_ha_evaluation"`
162+
EnableHAEvaluation bool `yaml:"enable_ha_evaluation"`
163+
LivenessCheckTimeout time.Duration `yaml:"liveness_check_timeout"`
165164
}
166165

167166
// Validate config and returns error on failure
@@ -238,6 +237,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
238237
f.BoolVar(&cfg.DisableRuleGroupLabel, "ruler.disable-rule-group-label", false, "Disable the rule_group label on exported metrics")
239238

240239
f.BoolVar(&cfg.EnableHAEvaluation, "ruler.enable-ha-evaluation", false, "Enable high availability")
240+
f.DurationVar(&cfg.LivenessCheckTimeout, "ruler.liveness-check-timeout", 1*time.Second, "Timeout duration for non-primary rulers during liveness checks. If the check times out, the non-primary ruler will evaluate the rule group. Applicable when ruler.enable-ha-evaluation is true.")
241241

242242
cfg.RingCheckPeriod = 5 * time.Second
243243
}
@@ -590,7 +590,7 @@ func (r *Ruler) nonPrimaryInstanceOwnsRuleGroup(g *rulespb.RuleGroupDesc, replic
590590
responseChan := make(chan *LivenessCheckResponse, len(jobs))
591591

592592
ctx := user.InjectOrgID(context.Background(), userID)
593-
ctx, cancel := context.WithTimeout(ctx, livenessCheckTimeout)
593+
ctx, cancel := context.WithTimeout(ctx, r.cfg.LivenessCheckTimeout)
594594
defer cancel()
595595

596596
err := concurrency.ForEach(ctx, jobs, len(jobs), func(ctx context.Context, job interface{}) error {

0 commit comments

Comments
 (0)