From 748a726fa073c7fa3ca1ea79d6ac1265656a9e01 Mon Sep 17 00:00:00 2001 From: Nick Pillitteri <56quarters@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:43:47 -0400 Subject: [PATCH] Fix metadata ingestion test flake (#7988) This change fixes a metadata ingestion test flake caused by metadata being ingested when it should have been rejected. The conversion of global to local limits only counts the number of ingesters with tokens when determining how to divide the global limit. When there are no ingesters with tokens due to race conditions, 0 is used for the global limit which causes 0 to be used for the local limit which is interpreted as "unlimited". Fixes #7979 Signed-off-by: Nick Pillitteri --- pkg/ingester/ingester_test.go | 7 ++++--- pkg/ingester/lifecycle_test.go | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/ingester/ingester_test.go b/pkg/ingester/ingester_test.go index 6627e9dcccc..d393d31beb4 100644 --- a/pkg/ingester/ingester_test.go +++ b/pkg/ingester/ingester_test.go @@ -2549,9 +2549,10 @@ func TestIngester_Push(t *testing.T) { ctx := user.InjectOrgID(context.Background(), userID) - // Wait until the ingester is healthy - test.Poll(t, 100*time.Millisecond, 1, func() interface{} { - return i.lifecycler.HealthyInstancesCount() + // Wait until the ingester is healthy and owns tokens. Note that the timeout here is set + // such that it is longer than the MinReadyDuration configuration for the ingester ring. + test.Poll(t, time.Second, nil, func() interface{} { + return i.lifecycler.CheckReady(context.Background()) }) // Push timeseries diff --git a/pkg/ingester/lifecycle_test.go b/pkg/ingester/lifecycle_test.go index 7cb0ab825b0..29c59ab61f4 100644 --- a/pkg/ingester/lifecycle_test.go +++ b/pkg/ingester/lifecycle_test.go @@ -45,6 +45,7 @@ func defaultIngesterTestConfig(t testing.TB) Config { cfg.IngesterRing.InstanceAddr = "localhost" cfg.IngesterRing.InstanceID = "localhost" cfg.IngesterRing.FinalSleep = 0 + cfg.IngesterRing.MinReadyDuration = 100 * time.Millisecond cfg.ActiveSeriesMetrics.Enabled = true return cfg