Skip to content

Commit

Permalink
fix: update fixed limit once streams ownership re-checked (#13231)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
  • Loading branch information
vlad-diachenko authored Jun 18, 2024
1 parent 1086783 commit 7ac19f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/ingester/recalculate_owned_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (s *recalculateOwnedStreams) recalculate() {
if err != nil {
level.Error(s.logger).Log("msg", "failed to update owned streams", "err", err)
}
instance.ownedStreamsSvc.updateFixedLimit()
}
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/ingester/recalculate_owned_streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func Test_recalculateOwnedStreams_recalculate(t *testing.T) {
nil,
)
require.NoError(t, err)
require.Equal(t, 100, tenant.ownedStreamsSvc.getFixedLimit(), "MaxGlobalStreamsPerUser is 100 at this moment")
// not owned streams
createStream(t, tenant, 49)
createStream(t, tenant, 101)
Expand All @@ -100,9 +101,14 @@ func Test_recalculateOwnedStreams_recalculate(t *testing.T) {
mockTenantsSupplier := &mockTenantsSuplier{tenants: []*instance{tenant}}

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

service.recalculate()

if testData.featureEnabled {
require.Equal(t, 50, tenant.ownedStreamsSvc.getFixedLimit(), "fixed limit must be updated after recalculation")
}
require.Equal(t, testData.expectedOwnedStreamCount, tenant.ownedStreamsSvc.ownedStreamCount)
require.Equal(t, testData.expectedNotOwnedStreamCount, tenant.ownedStreamsSvc.notOwnedStreamCount)
})
Expand Down

0 comments on commit 7ac19f0

Please sign in to comment.