Skip to content

Commit

Permalink
Fix per-tenant delete client (#6696) (#6698)
Browse files Browse the repository at this point in the history
- Don't make the request for a disabled tenant even if golbal deletion is allowed

(cherry picked from commit cd2ebeb)

Co-authored-by: Travis Patterson <[email protected]>
  • Loading branch information
grafanabot and MasslessParticle authored Jul 17, 2022
1 parent 252a214 commit a835c38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ func NewPerTenantDeleteRequestsClient(c DeleteRequestsClient, l retention.Limits

func (c *perTenantDeleteRequestsClient) GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]DeleteRequest, error) {
allLimits := c.limits.AllByUserID()
userLimits, ok := allLimits[userID]
if ok && userLimits.CompactorDeletionEnabled || c.limits.DefaultLimits().CompactorDeletionEnabled {
if userLimits, ok := allLimits[userID]; ok {
if userLimits.CompactorDeletionEnabled {
return c.client.GetAllDeleteRequestsForUser(ctx, userID)
}
return nil, nil
}

if c.limits.DefaultLimits().CompactorDeletionEnabled {
return c.client.GetAllDeleteRequestsForUser(ctx, userID)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ func TestTenantDeleteRequestsClient(t *testing.T) {
require.Empty(t, reqs)
})

t.Run("tenant disabled but default enabled", func(t *testing.T) {
limits.defaultLimit.compactorDeletionEnabled = true
reqs, err := perTenantClient.GetAllDeleteRequestsForUser(context.Background(), "2")
require.Nil(t, err)
require.Empty(t, reqs)
})

t.Run("default is enabled", func(t *testing.T) {
limits.defaultLimit.compactorDeletionEnabled = true
reqs, err := perTenantClient.GetAllDeleteRequestsForUser(context.Background(), "3")
Expand Down

0 comments on commit a835c38

Please sign in to comment.