From 3b94693a9451690eede167bc8f0bd5e43ba015ef Mon Sep 17 00:00:00 2001 From: Austen McClernon Date: Tue, 4 Apr 2023 13:48:32 +0000 Subject: [PATCH] allocator: deflake full disk test In #97409 we introduced cluster settings to control the disk fullness threshold for rebalancing towards a store and shedding replicas off of the store. The `TestAllocatorFullDisks` assumes the total number of range bytes is equal or less than the rebalance threshold of the nodes, however the test was updated to use the shed threshold instead. This caused the test to flake occasionally as there was more than the expected amount of total range bytes. This patch changes the ranges per node calculation to use the rebalance threshold again, instead of the shed threshold Fixes: #100033 Release note: None --- .../kvserver/allocator/allocatorimpl/allocator_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go b/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go index fc8bac15aa1e..c4c43afcd5d7 100644 --- a/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go +++ b/pkg/kv/kvserver/allocator/allocatorimpl/allocator_test.go @@ -8475,7 +8475,14 @@ func TestAllocatorFullDisks(t *testing.T) { do := makeDiskCapacityOptions(&st.SV) - rangesPerNode := int(math.Floor(capacity * do.ShedAndBlockAllThreshold / rangeSize)) + // Each range is equally sized (16mb), we want the number of ranges per node, + // when their size is added, to be no greater than the full disk rebalance + // threshold (0.925%) e.g for below: + // capacity = 1024mb + // rangeSize = 16mb + // threshold = 0.925 + // rangesPerNode = ⌊1024mb * 0.925 / 16mb⌋ = 59 + rangesPerNode := int(math.Floor(capacity * do.RebalanceToThreshold / rangeSize)) rangesToAdd := rangesPerNode * nodes // Initialize testStores.