From 52adda686ec634c1e5593e5310e9969be7442132 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Mon, 31 Oct 2022 15:33:12 +0100 Subject: [PATCH] Fixes a race in the usage reporter --- pkg/usagestats/reporter.go | 3 ++- pkg/usagestats/seed_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/usagestats/reporter.go b/pkg/usagestats/reporter.go index d66b8fb6c8..3783a6a45d 100644 --- a/pkg/usagestats/reporter.go +++ b/pkg/usagestats/reporter.go @@ -104,7 +104,8 @@ func (rep *Reporter) initLeader(ctx context.Context) ClusterSeed { return nil, false, nil } } - return &seed, true, nil + + return seed.Clone(), true, nil }); err != nil { level.Info(rep.logger).Log("msg", "failed to CAS cluster seed key", "err", err) continue diff --git a/pkg/usagestats/seed_test.go b/pkg/usagestats/seed_test.go index 5a6359c4ad..c6156e0b3a 100644 --- a/pkg/usagestats/seed_test.go +++ b/pkg/usagestats/seed_test.go @@ -59,7 +59,7 @@ func createMemberlist(t *testing.T, port, memberID int) *memberlist.KV { } func Test_Memberlist(t *testing.T) { - stabilityCheckInterval = time.Second + stabilityCheckInterval = 100 * time.Millisecond objectClient, err := client.NewBucket(context.Background(), client.Config{ StorageBackendConfig: client.StorageBackendConfig{