From 43588bd8946aae06093a153c87473bcfa211d67c Mon Sep 17 00:00:00 2001 From: Anand Rajagopal Date: Wed, 19 Feb 2025 01:26:06 +0000 Subject: [PATCH] Avoid liveness check seg-fault in 'New' state Signed-off-by: Anand Rajagopal --- pkg/ruler/ruler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/ruler/ruler.go b/pkg/ruler/ruler.go index 812fd4f15c6..7cce799b896 100644 --- a/pkg/ruler/ruler.go +++ b/pkg/ruler/ruler.go @@ -586,6 +586,9 @@ func ownsRuleGroupOrDisable(g *rulespb.RuleGroupDesc, disabledRuleGroups validat } func (r *Ruler) LivenessCheck(_ context.Context, request *LivenessCheckRequest) (*LivenessCheckResponse, error) { + if r.lifecycler.ServiceContext() == nil { + return nil, errors.New("ruler is not yet ready") + } if r.lifecycler.ServiceContext().Err() != nil || r.subservices.IsStopped() { return nil, errors.New("ruler's context is canceled and might be stopping soon") }