From cfaa9ba35d4ade50d3bc6456592ab65856e65715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 6 Mar 2024 11:53:30 +0100 Subject: [PATCH] fix(repair): fix repair plan host filtering Fixes #3736 --- pkg/service/repair/plan.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/service/repair/plan.go b/pkg/service/repair/plan.go index 07bd779913..cd15c8d933 100644 --- a/pkg/service/repair/plan.go +++ b/pkg/service/repair/plan.go @@ -49,18 +49,24 @@ func newPlan(ctx context.Context, target Target, client *scyllaclient.Client) (* } skip := false - for _, rep := range ring.ReplicaTokens { - rtr := scyllaclient.ReplicaTokenRanges{ - ReplicaSet: filteredReplicaSet(rep.ReplicaSet, filtered, target.Host), - Ranges: rep.Ranges, + for _, rtr := range ring.ReplicaTokens { + // Skip the whole keyspace based on repaired dcs only + // (unless it's a single node cluster). + replicas := 0 + for _, h := range rtr.ReplicaSet { + if slice.ContainsString(target.DC, ring.HostDC[h]) { + replicas++ + } } - - // Don't add keyspace with some ranges not replicated in filtered hosts, - // unless it's a single node cluster. - if len(rtr.ReplicaSet) <= 1 && len(status) > 1 { + if replicas <= 1 && len(status) > 1 { skip = true break } + // Skip given replica sets based on all filtering factors + rtr.ReplicaSet = filteredReplicaSet(rtr.ReplicaSet, filtered, target.Host) + if len(rtr.ReplicaSet) <= 1 && len(status) > 1 { + continue + } for _, r := range rtr.Ranges { kp.TokenRepIdx[r] = len(kp.Replicas) @@ -68,7 +74,7 @@ func newPlan(ctx context.Context, target Target, client *scyllaclient.Client) (* kp.Replicas = append(kp.Replicas, rtr) } - if skip { + if skip || len(kp.Replicas) == 0 { p.SkippedKeyspaces = append(p.SkippedKeyspaces, u.Keyspace) continue }