Skip to content

Commit 7ac19f0

Browse files
fix: update fixed limit once streams ownership re-checked (#13231)
Signed-off-by: Vladyslav Diachenko <[email protected]>
1 parent 1086783 commit 7ac19f0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/ingester/recalculate_owned_streams.go

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (s *recalculateOwnedStreams) recalculate() {
6464
if err != nil {
6565
level.Error(s.logger).Log("msg", "failed to update owned streams", "err", err)
6666
}
67+
instance.ownedStreamsSvc.updateFixedLimit()
6768
}
6869
}
6970

pkg/ingester/recalculate_owned_streams_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func Test_recalculateOwnedStreams_recalculate(t *testing.T) {
8383
nil,
8484
)
8585
require.NoError(t, err)
86+
require.Equal(t, 100, tenant.ownedStreamsSvc.getFixedLimit(), "MaxGlobalStreamsPerUser is 100 at this moment")
8687
// not owned streams
8788
createStream(t, tenant, 49)
8889
createStream(t, tenant, 101)
@@ -100,9 +101,14 @@ func Test_recalculateOwnedStreams_recalculate(t *testing.T) {
100101
mockTenantsSupplier := &mockTenantsSuplier{tenants: []*instance{tenant}}
101102

102103
service := newRecalculateOwnedStreams(mockTenantsSupplier.get, "ingester-0", mockRing, 50*time.Millisecond, log.NewNopLogger())
104+
//change the limit to assert that fixed limit is updated after the recalculation
105+
limits.DefaultLimits().MaxGlobalStreamsPerUser = 50
103106

104107
service.recalculate()
105108

109+
if testData.featureEnabled {
110+
require.Equal(t, 50, tenant.ownedStreamsSvc.getFixedLimit(), "fixed limit must be updated after recalculation")
111+
}
106112
require.Equal(t, testData.expectedOwnedStreamCount, tenant.ownedStreamsSvc.ownedStreamCount)
107113
require.Equal(t, testData.expectedNotOwnedStreamCount, tenant.ownedStreamsSvc.notOwnedStreamCount)
108114
})

0 commit comments

Comments
 (0)