Skip to content

Commit

Permalink
considere leaving ruler as healthy when listrules
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Xu <[email protected]>
  • Loading branch information
wenxu1024 committed Dec 12, 2023
1 parent 3565a31 commit f9c26d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/ruler/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ func (r *Ruler) getShardedRules(ctx context.Context, userID string, rulesRequest
ring = r.ring.ShuffleShard(userID, shardSize)
}

rulers, err := ring.GetReplicationSetForOperation(RingOp)
rulers, err := ring.GetReplicationSetForOperation(ListRuleRingOp)
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/ruler/ruler_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ var RingOp = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, func(s ring.InstanceS
return s != ring.ACTIVE
})

// ListRuleRingOp is the operation used for getting rule groups from rulers.
var ListRuleRingOp = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, func(s ring.InstanceState) bool {
// Although LEAVING ruler does not get any rule groups. If it is excluded, list rule will fail because not enough healthy instance.
// So we still try to read from the LEAVING ruler, although it might return empty result
return s != ring.ACTIVE && s != ring.LEAVING
})

// RingConfig masks the ring lifecycler config which contains
// many options not really required by the rulers ring. This config
// is used to strip down the config to the minimum, and avoid confusion
Expand Down

0 comments on commit f9c26d0

Please sign in to comment.