Skip to content

Commit e16a10b

Browse files
authored
Make sure the HA tracker only handles valid keys (#1677)
If the ring and the HA tracker share the same prefix then we will end up handling invalid keys. Fixes #1652 and #1628 Signed-off-by: Goutham Veeramachaneni <[email protected]>
1 parent 114312d commit e16a10b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/distributor/ha_tracker.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ func (c *haTracker) loop(ctx context.Context) {
150150
c.electedLock.Lock()
151151
defer c.electedLock.Unlock()
152152
chunks := strings.SplitN(key, "/", 2)
153+
154+
// The prefix has already been stripped, so a valid key would look like cluster/replica,
155+
// and a key without a / such as `ring` would be invalid.
156+
if len(chunks) != 2 {
157+
return true
158+
}
159+
153160
if replica.Replica != c.elected[key].Replica {
154161
electedReplicaChanges.WithLabelValues(chunks[0], chunks[1]).Inc()
155162
}

0 commit comments

Comments
 (0)