Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanGuedes committed Jan 6, 2025
1 parent f5559b8 commit 67ded00
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
9 changes: 0 additions & 9 deletions pkg/distributor/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@ func (v Validator) ShouldBlockScopeIngestion(ctx validationContext, scope string
return now.Before(ts), ts, ctx.blockScopeIngestionStatusCode[scope]
}

func (v Validator) hasEnforcedLabels(enforcedLabels []string, stream logproto.Stream) bool {
for _, label := range enforcedLabels {
if !stream.Labels.Has(label) {
return false
}
}
return true
}

func updateMetrics(reason, userID string, stream logproto.Stream) {
validation.DiscardedSamples.WithLabelValues(reason, userID).Add(float64(len(stream.Entries)))
bytes := util.EntriesTotalSize(stream.Entries)
Expand Down
7 changes: 4 additions & 3 deletions pkg/validation/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,6 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {
f.Var(&l.BlockIngestionUntil, "limits.block-ingestion-until", "Block ingestion until the configured date. The time should be in RFC3339 format.")
f.IntVar(&l.BlockIngestionStatusCode, "limits.block-ingestion-status-code", defaultBlockedIngestionStatusCode, "HTTP status code to return when ingestion is blocked. If 200, the ingestion will be blocked without returning an error to the client. By Default, a custom status code (260) is returned to the client along with an error message.")

// TODO: how to do flags with maps?
// f.Var(&l.BlockScopeIngestionUntil, "limits.block-scope-ingestion-until", "Block ingestion until the configured date. The time should be in RFC3339 format.")
// f.IntVar(&l.BlockScopeIngestionStatusCode, "limits.block-scope-ingestion-status-code", defaultBlockedIngestionStatusCode, "HTTP status code to return when ingestion is blocked. If 200, the ingestion will be blocked without returning an error to the client. By Default, a custom status code (260) is returned to the client along with an error message.")
f.StringVar(&l.ScopeIngestionLabel, "limits.scope-ingestion-label", "", "Label to use for scope ingestion. This label will be used to identify the scope of the ingestion.")

f.IntVar(&l.IngestionPartitionsTenantShardSize, "limits.ingestion-partition-tenant-shard-size", 0, "The number of partitions a tenant's data should be sharded to when using kafka ingestion. Tenants are sharded across partitions using shuffle-sharding. 0 disables shuffle sharding and tenant is sharded across all partitions.")
Expand Down Expand Up @@ -624,6 +621,10 @@ func (o *Overrides) ScopeIngestionLabel(userID string) string {
return o.getOverridesForUser(userID).ScopeIngestionLabel
}

func (o *Overrides) EnforcedLabels(userID string) []string {
return o.getOverridesForUser(userID).EnforcedLabels
}

// MaxLabelNameLength returns maximum length a label name can be.
func (o *Overrides) MaxLabelNameLength(userID string) int {
return o.getOverridesForUser(userID).MaxLabelNameLength
Expand Down
5 changes: 5 additions & 0 deletions pkg/validation/limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ ruler_remote_write_headers:
OTLPConfig: defaultOTLPConfig,
BlockScopeIngestionUntil: map[string]flagext.Time{},
BlockScopeIngestionStatusCode: map[string]int{},
EnforcedLabels: []string{},
},
},
{
Expand All @@ -249,6 +250,7 @@ ruler_remote_write_headers:
OTLPConfig: defaultOTLPConfig,
BlockScopeIngestionUntil: map[string]flagext.Time{},
BlockScopeIngestionStatusCode: map[string]int{},
EnforcedLabels: []string{},
},
},
{
Expand All @@ -273,6 +275,7 @@ retention_stream:
OTLPConfig: defaultOTLPConfig,
BlockScopeIngestionUntil: map[string]flagext.Time{},
BlockScopeIngestionStatusCode: map[string]int{},
EnforcedLabels: []string{},
},
},
{
Expand All @@ -296,6 +299,7 @@ reject_old_samples: true
OTLPConfig: defaultOTLPConfig,
BlockScopeIngestionUntil: map[string]flagext.Time{},
BlockScopeIngestionStatusCode: map[string]int{},
EnforcedLabels: []string{},
},
},
{
Expand All @@ -320,6 +324,7 @@ query_timeout: 5m
OTLPConfig: defaultOTLPConfig,
BlockScopeIngestionUntil: map[string]flagext.Time{},
BlockScopeIngestionStatusCode: map[string]int{},
EnforcedLabels: []string{},
},
},
} {
Expand Down

0 comments on commit 67ded00

Please sign in to comment.