Skip to content

Commit 5ff6bbf

Browse files
committed
export GetOverridesForUser method only
Signed-off-by: songjiayang <[email protected]>
1 parent a881cd1 commit 5ff6bbf

File tree

1 file changed

+58
-62
lines changed

1 file changed

+58
-62
lines changed

pkg/util/validation/limits.go

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func NewOverrides(defaults Limits, tenantLimits TenantLimits) (*Overrides, error
282282

283283
// IngestionRate returns the limit on ingester rate (samples per second).
284284
func (o *Overrides) IngestionRate(userID string) float64 {
285-
return o.getOverridesForUser(userID).IngestionRate
285+
return o.GetOverridesForUser(userID).IngestionRate
286286
}
287287

288288
// IngestionRateStrategy returns whether the ingestion rate limit should be individually applied
@@ -294,263 +294,263 @@ func (o *Overrides) IngestionRateStrategy() string {
294294

295295
// IngestionBurstSize returns the burst size for ingestion rate.
296296
func (o *Overrides) IngestionBurstSize(userID string) int {
297-
return o.getOverridesForUser(userID).IngestionBurstSize
297+
return o.GetOverridesForUser(userID).IngestionBurstSize
298298
}
299299

300300
// AcceptHASamples returns whether the distributor should track and accept samples from HA replicas for this user.
301301
func (o *Overrides) AcceptHASamples(userID string) bool {
302-
return o.getOverridesForUser(userID).AcceptHASamples
302+
return o.GetOverridesForUser(userID).AcceptHASamples
303303
}
304304

305305
// HAClusterLabel returns the cluster label to look for when deciding whether to accept a sample from a Prometheus HA replica.
306306
func (o *Overrides) HAClusterLabel(userID string) string {
307-
return o.getOverridesForUser(userID).HAClusterLabel
307+
return o.GetOverridesForUser(userID).HAClusterLabel
308308
}
309309

310310
// HAReplicaLabel returns the replica label to look for when deciding whether to accept a sample from a Prometheus HA replica.
311311
func (o *Overrides) HAReplicaLabel(userID string) string {
312-
return o.getOverridesForUser(userID).HAReplicaLabel
312+
return o.GetOverridesForUser(userID).HAReplicaLabel
313313
}
314314

315315
// DropLabels returns the list of labels to be dropped when ingesting HA samples for the user.
316316
func (o *Overrides) DropLabels(userID string) flagext.StringSlice {
317-
return o.getOverridesForUser(userID).DropLabels
317+
return o.GetOverridesForUser(userID).DropLabels
318318
}
319319

320320
// MaxLabelNameLength returns maximum length a label name can be.
321321
func (o *Overrides) MaxLabelNameLength(userID string) int {
322-
return o.getOverridesForUser(userID).MaxLabelNameLength
322+
return o.GetOverridesForUser(userID).MaxLabelNameLength
323323
}
324324

325325
// MaxLabelValueLength returns maximum length a label value can be. This also is
326326
// the maximum length of a metric name.
327327
func (o *Overrides) MaxLabelValueLength(userID string) int {
328-
return o.getOverridesForUser(userID).MaxLabelValueLength
328+
return o.GetOverridesForUser(userID).MaxLabelValueLength
329329
}
330330

331331
// MaxLabelNamesPerSeries returns maximum number of label/value pairs timeseries.
332332
func (o *Overrides) MaxLabelNamesPerSeries(userID string) int {
333-
return o.getOverridesForUser(userID).MaxLabelNamesPerSeries
333+
return o.GetOverridesForUser(userID).MaxLabelNamesPerSeries
334334
}
335335

336336
// MaxLabelsSizeBytes returns maximum number of label/value pairs timeseries.
337337
func (o *Overrides) MaxLabelsSizeBytes(userID string) int {
338-
return o.getOverridesForUser(userID).MaxLabelsSizeBytes
338+
return o.GetOverridesForUser(userID).MaxLabelsSizeBytes
339339
}
340340

341341
// MaxMetadataLength returns maximum length metadata can be. Metadata refers
342342
// to the Metric Name, HELP and UNIT.
343343
func (o *Overrides) MaxMetadataLength(userID string) int {
344-
return o.getOverridesForUser(userID).MaxMetadataLength
344+
return o.GetOverridesForUser(userID).MaxMetadataLength
345345
}
346346

347347
// RejectOldSamples returns true when we should reject samples older than certain
348348
// age.
349349
func (o *Overrides) RejectOldSamples(userID string) bool {
350-
return o.getOverridesForUser(userID).RejectOldSamples
350+
return o.GetOverridesForUser(userID).RejectOldSamples
351351
}
352352

353353
// RejectOldSamplesMaxAge returns the age at which samples should be rejected.
354354
func (o *Overrides) RejectOldSamplesMaxAge(userID string) time.Duration {
355-
return time.Duration(o.getOverridesForUser(userID).RejectOldSamplesMaxAge)
355+
return time.Duration(o.GetOverridesForUser(userID).RejectOldSamplesMaxAge)
356356
}
357357

358358
// CreationGracePeriod is misnamed, and actually returns how far into the future
359359
// we should accept samples.
360360
func (o *Overrides) CreationGracePeriod(userID string) time.Duration {
361-
return time.Duration(o.getOverridesForUser(userID).CreationGracePeriod)
361+
return time.Duration(o.GetOverridesForUser(userID).CreationGracePeriod)
362362
}
363363

364364
// MaxSeriesPerQuery returns the maximum number of series a query is allowed to hit.
365365
func (o *Overrides) MaxSeriesPerQuery(userID string) int {
366-
return o.getOverridesForUser(userID).MaxSeriesPerQuery
366+
return o.GetOverridesForUser(userID).MaxSeriesPerQuery
367367
}
368368

369369
// MaxLocalSeriesPerUser returns the maximum number of series a user is allowed to store in a single ingester.
370370
func (o *Overrides) MaxLocalSeriesPerUser(userID string) int {
371-
return o.getOverridesForUser(userID).MaxLocalSeriesPerUser
371+
return o.GetOverridesForUser(userID).MaxLocalSeriesPerUser
372372
}
373373

374374
// MaxLocalSeriesPerMetric returns the maximum number of series allowed per metric in a single ingester.
375375
func (o *Overrides) MaxLocalSeriesPerMetric(userID string) int {
376-
return o.getOverridesForUser(userID).MaxLocalSeriesPerMetric
376+
return o.GetOverridesForUser(userID).MaxLocalSeriesPerMetric
377377
}
378378

379379
// MaxGlobalSeriesPerUser returns the maximum number of series a user is allowed to store across the cluster.
380380
func (o *Overrides) MaxGlobalSeriesPerUser(userID string) int {
381-
return o.getOverridesForUser(userID).MaxGlobalSeriesPerUser
381+
return o.GetOverridesForUser(userID).MaxGlobalSeriesPerUser
382382
}
383383

384384
// MaxGlobalSeriesPerMetric returns the maximum number of series allowed per metric across the cluster.
385385
func (o *Overrides) MaxGlobalSeriesPerMetric(userID string) int {
386-
return o.getOverridesForUser(userID).MaxGlobalSeriesPerMetric
386+
return o.GetOverridesForUser(userID).MaxGlobalSeriesPerMetric
387387
}
388388

389389
// MaxChunksPerQueryFromStore returns the maximum number of chunks allowed per query when fetching
390390
// chunks from the long-term storage.
391391
func (o *Overrides) MaxChunksPerQueryFromStore(userID string) int {
392-
return o.getOverridesForUser(userID).MaxChunksPerQuery
392+
return o.GetOverridesForUser(userID).MaxChunksPerQuery
393393
}
394394

395395
func (o *Overrides) MaxChunksPerQuery(userID string) int {
396-
return o.getOverridesForUser(userID).MaxChunksPerQuery
396+
return o.GetOverridesForUser(userID).MaxChunksPerQuery
397397
}
398398

399399
// MaxFetchedSeriesPerQuery returns the maximum number of series allowed per query when fetching
400400
// chunks from ingesters and blocks storage.
401401
func (o *Overrides) MaxFetchedSeriesPerQuery(userID string) int {
402-
return o.getOverridesForUser(userID).MaxFetchedSeriesPerQuery
402+
return o.GetOverridesForUser(userID).MaxFetchedSeriesPerQuery
403403
}
404404

405405
// MaxFetchedChunkBytesPerQuery returns the maximum number of bytes for chunks allowed per query when fetching
406406
// chunks from ingesters and blocks storage.
407407
func (o *Overrides) MaxFetchedChunkBytesPerQuery(userID string) int {
408-
return o.getOverridesForUser(userID).MaxFetchedChunkBytesPerQuery
408+
return o.GetOverridesForUser(userID).MaxFetchedChunkBytesPerQuery
409409
}
410410

411411
// MaxFetchedDataBytesPerQuery returns the maximum number of bytes for all data allowed per query when fetching
412412
// from ingesters and blocks storage.
413413
func (o *Overrides) MaxFetchedDataBytesPerQuery(userID string) int {
414-
return o.getOverridesForUser(userID).MaxFetchedDataBytesPerQuery
414+
return o.GetOverridesForUser(userID).MaxFetchedDataBytesPerQuery
415415
}
416416

417417
// MaxQueryLookback returns the max lookback period of queries.
418418
func (o *Overrides) MaxQueryLookback(userID string) time.Duration {
419-
return time.Duration(o.getOverridesForUser(userID).MaxQueryLookback)
419+
return time.Duration(o.GetOverridesForUser(userID).MaxQueryLookback)
420420
}
421421

422422
// MaxQueryLength returns the limit of the length (in time) of a query.
423423
func (o *Overrides) MaxQueryLength(userID string) time.Duration {
424-
return time.Duration(o.getOverridesForUser(userID).MaxQueryLength)
424+
return time.Duration(o.GetOverridesForUser(userID).MaxQueryLength)
425425
}
426426

427427
// MaxCacheFreshness returns the period after which results are cacheable,
428428
// to prevent caching of very recent results.
429429
func (o *Overrides) MaxCacheFreshness(userID string) time.Duration {
430-
return time.Duration(o.getOverridesForUser(userID).MaxCacheFreshness)
430+
return time.Duration(o.GetOverridesForUser(userID).MaxCacheFreshness)
431431
}
432432

433433
// MaxQueriersPerUser returns the maximum number of queriers that can handle requests for this user.
434434
func (o *Overrides) MaxQueriersPerUser(userID string) int {
435-
return o.getOverridesForUser(userID).MaxQueriersPerTenant
435+
return o.GetOverridesForUser(userID).MaxQueriersPerTenant
436436
}
437437

438438
// QueryVerticalShardSize returns the number of shards to use when distributing shardable PromQL queries.
439439
func (o *Overrides) QueryVerticalShardSize(userID string) int {
440-
return o.getOverridesForUser(userID).QueryVerticalShardSize
440+
return o.GetOverridesForUser(userID).QueryVerticalShardSize
441441
}
442442

443443
// MaxQueryParallelism returns the limit to the number of split queries the
444444
// frontend will process in parallel.
445445
func (o *Overrides) MaxQueryParallelism(userID string) int {
446-
return o.getOverridesForUser(userID).MaxQueryParallelism
446+
return o.GetOverridesForUser(userID).MaxQueryParallelism
447447
}
448448

449449
// EnforceMetricName whether to enforce the presence of a metric name.
450450
func (o *Overrides) EnforceMetricName(userID string) bool {
451-
return o.getOverridesForUser(userID).EnforceMetricName
451+
return o.GetOverridesForUser(userID).EnforceMetricName
452452
}
453453

454454
// EnforceMetadataMetricName whether to enforce the presence of a metric name on metadata.
455455
func (o *Overrides) EnforceMetadataMetricName(userID string) bool {
456-
return o.getOverridesForUser(userID).EnforceMetadataMetricName
456+
return o.GetOverridesForUser(userID).EnforceMetadataMetricName
457457
}
458458

459459
// MaxLocalMetricsWithMetadataPerUser returns the maximum number of metrics with metadata a user is allowed to store in a single ingester.
460460
func (o *Overrides) MaxLocalMetricsWithMetadataPerUser(userID string) int {
461-
return o.getOverridesForUser(userID).MaxLocalMetricsWithMetadataPerUser
461+
return o.GetOverridesForUser(userID).MaxLocalMetricsWithMetadataPerUser
462462
}
463463

464464
// MaxLocalMetadataPerMetric returns the maximum number of metadata allowed per metric in a single ingester.
465465
func (o *Overrides) MaxLocalMetadataPerMetric(userID string) int {
466-
return o.getOverridesForUser(userID).MaxLocalMetadataPerMetric
466+
return o.GetOverridesForUser(userID).MaxLocalMetadataPerMetric
467467
}
468468

469469
// MaxGlobalMetricsWithMetadataPerUser returns the maximum number of metrics with metadata a user is allowed to store across the cluster.
470470
func (o *Overrides) MaxGlobalMetricsWithMetadataPerUser(userID string) int {
471-
return o.getOverridesForUser(userID).MaxGlobalMetricsWithMetadataPerUser
471+
return o.GetOverridesForUser(userID).MaxGlobalMetricsWithMetadataPerUser
472472
}
473473

474474
// MaxGlobalMetadataPerMetric returns the maximum number of metadata allowed per metric across the cluster.
475475
func (o *Overrides) MaxGlobalMetadataPerMetric(userID string) int {
476-
return o.getOverridesForUser(userID).MaxGlobalMetadataPerMetric
476+
return o.GetOverridesForUser(userID).MaxGlobalMetadataPerMetric
477477
}
478478

479479
// IngestionTenantShardSize returns the ingesters shard size for a given user.
480480
func (o *Overrides) IngestionTenantShardSize(userID string) int {
481-
return o.getOverridesForUser(userID).IngestionTenantShardSize
481+
return o.GetOverridesForUser(userID).IngestionTenantShardSize
482482
}
483483

484484
// EvaluationDelay returns the rules evaluation delay for a given user.
485485
func (o *Overrides) EvaluationDelay(userID string) time.Duration {
486-
return time.Duration(o.getOverridesForUser(userID).RulerEvaluationDelay)
486+
return time.Duration(o.GetOverridesForUser(userID).RulerEvaluationDelay)
487487
}
488488

489489
// CompactorBlocksRetentionPeriod returns the retention period for a given user.
490490
func (o *Overrides) CompactorBlocksRetentionPeriod(userID string) time.Duration {
491-
return time.Duration(o.getOverridesForUser(userID).CompactorBlocksRetentionPeriod)
491+
return time.Duration(o.GetOverridesForUser(userID).CompactorBlocksRetentionPeriod)
492492
}
493493

494494
// CompactorTenantShardSize returns shard size (number of rulers) used by this tenant when using shuffle-sharding strategy.
495495
func (o *Overrides) CompactorTenantShardSize(userID string) int {
496-
return o.getOverridesForUser(userID).CompactorTenantShardSize
496+
return o.GetOverridesForUser(userID).CompactorTenantShardSize
497497
}
498498

499499
// MetricRelabelConfigs returns the metric relabel configs for a given user.
500500
func (o *Overrides) MetricRelabelConfigs(userID string) []*relabel.Config {
501-
return o.getOverridesForUser(userID).MetricRelabelConfigs
501+
return o.GetOverridesForUser(userID).MetricRelabelConfigs
502502
}
503503

504504
// RulerTenantShardSize returns shard size (number of rulers) used by this tenant when using shuffle-sharding strategy.
505505
func (o *Overrides) RulerTenantShardSize(userID string) int {
506-
return o.getOverridesForUser(userID).RulerTenantShardSize
506+
return o.GetOverridesForUser(userID).RulerTenantShardSize
507507
}
508508

509509
// RulerMaxRulesPerRuleGroup returns the maximum number of rules per rule group for a given user.
510510
func (o *Overrides) RulerMaxRulesPerRuleGroup(userID string) int {
511-
return o.getOverridesForUser(userID).RulerMaxRulesPerRuleGroup
511+
return o.GetOverridesForUser(userID).RulerMaxRulesPerRuleGroup
512512
}
513513

514514
// RulerMaxRuleGroupsPerTenant returns the maximum number of rule groups for a given user.
515515
func (o *Overrides) RulerMaxRuleGroupsPerTenant(userID string) int {
516-
return o.getOverridesForUser(userID).RulerMaxRuleGroupsPerTenant
516+
return o.GetOverridesForUser(userID).RulerMaxRuleGroupsPerTenant
517517
}
518518

519519
// StoreGatewayTenantShardSize returns the store-gateway shard size for a given user.
520520
func (o *Overrides) StoreGatewayTenantShardSize(userID string) int {
521-
return o.getOverridesForUser(userID).StoreGatewayTenantShardSize
521+
return o.GetOverridesForUser(userID).StoreGatewayTenantShardSize
522522
}
523523

524524
// MaxHAClusters returns maximum number of clusters that HA tracker will track for a user.
525525
func (o *Overrides) MaxHAClusters(user string) int {
526-
return o.getOverridesForUser(user).HAMaxClusters
526+
return o.GetOverridesForUser(user).HAMaxClusters
527527
}
528528

529529
// S3SSEType returns the per-tenant S3 SSE type.
530530
func (o *Overrides) S3SSEType(user string) string {
531-
return o.getOverridesForUser(user).S3SSEType
531+
return o.GetOverridesForUser(user).S3SSEType
532532
}
533533

534534
// S3SSEKMSKeyID returns the per-tenant S3 KMS-SSE key id.
535535
func (o *Overrides) S3SSEKMSKeyID(user string) string {
536-
return o.getOverridesForUser(user).S3SSEKMSKeyID
536+
return o.GetOverridesForUser(user).S3SSEKMSKeyID
537537
}
538538

539539
// S3SSEKMSEncryptionContext returns the per-tenant S3 KMS-SSE encryption context.
540540
func (o *Overrides) S3SSEKMSEncryptionContext(user string) string {
541-
return o.getOverridesForUser(user).S3SSEKMSEncryptionContext
541+
return o.GetOverridesForUser(user).S3SSEKMSEncryptionContext
542542
}
543543

544544
// AlertmanagerReceiversBlockCIDRNetworks returns the list of network CIDRs that should be blocked
545545
// in the Alertmanager receivers for the given user.
546546
func (o *Overrides) AlertmanagerReceiversBlockCIDRNetworks(user string) []flagext.CIDR {
547-
return o.getOverridesForUser(user).AlertmanagerReceiversBlockCIDRNetworks
547+
return o.GetOverridesForUser(user).AlertmanagerReceiversBlockCIDRNetworks
548548
}
549549

550550
// AlertmanagerReceiversBlockPrivateAddresses returns true if private addresses should be blocked
551551
// in the Alertmanager receivers for the given user.
552552
func (o *Overrides) AlertmanagerReceiversBlockPrivateAddresses(user string) bool {
553-
return o.getOverridesForUser(user).AlertmanagerReceiversBlockPrivateAddresses
553+
return o.GetOverridesForUser(user).AlertmanagerReceiversBlockPrivateAddresses
554554
}
555555

556556
// Notification limits are special. Limits are returned in following order:
@@ -559,7 +559,7 @@ func (o *Overrides) AlertmanagerReceiversBlockPrivateAddresses(user string) bool
559559
// 3. per-tenant limits
560560
// 4. default limits
561561
func (o *Overrides) getNotificationLimitForUser(user, integration string) float64 {
562-
u := o.getOverridesForUser(user)
562+
u := o.GetOverridesForUser(user)
563563
if n, ok := u.NotificationRateLimitPerIntegration[integration]; ok {
564564
return n
565565
}
@@ -602,35 +602,31 @@ func (o *Overrides) NotificationBurstSize(user string, integration string) int {
602602
}
603603

604604
func (o *Overrides) AlertmanagerMaxConfigSize(userID string) int {
605-
return o.getOverridesForUser(userID).AlertmanagerMaxConfigSizeBytes
605+
return o.GetOverridesForUser(userID).AlertmanagerMaxConfigSizeBytes
606606
}
607607

608608
func (o *Overrides) AlertmanagerMaxTemplatesCount(userID string) int {
609-
return o.getOverridesForUser(userID).AlertmanagerMaxTemplatesCount
609+
return o.GetOverridesForUser(userID).AlertmanagerMaxTemplatesCount
610610
}
611611

612612
func (o *Overrides) AlertmanagerMaxTemplateSize(userID string) int {
613-
return o.getOverridesForUser(userID).AlertmanagerMaxTemplateSizeBytes
613+
return o.GetOverridesForUser(userID).AlertmanagerMaxTemplateSizeBytes
614614
}
615615

616616
func (o *Overrides) AlertmanagerMaxDispatcherAggregationGroups(userID string) int {
617-
return o.getOverridesForUser(userID).AlertmanagerMaxDispatcherAggregationGroups
617+
return o.GetOverridesForUser(userID).AlertmanagerMaxDispatcherAggregationGroups
618618
}
619619

620620
func (o *Overrides) AlertmanagerMaxAlertsCount(userID string) int {
621-
return o.getOverridesForUser(userID).AlertmanagerMaxAlertsCount
621+
return o.GetOverridesForUser(userID).AlertmanagerMaxAlertsCount
622622
}
623623

624624
func (o *Overrides) AlertmanagerMaxAlertsSizeBytes(userID string) int {
625-
return o.getOverridesForUser(userID).AlertmanagerMaxAlertsSizeBytes
625+
return o.GetOverridesForUser(userID).AlertmanagerMaxAlertsSizeBytes
626626
}
627627

628628
// GetOverridesForUser returns the per-tenant limits with overrides.
629629
func (o *Overrides) GetOverridesForUser(userID string) *Limits {
630-
return o.getOverridesForUser(userID)
631-
}
632-
633-
func (o *Overrides) getOverridesForUser(userID string) *Limits {
634630
if o.tenantLimits != nil {
635631
l := o.tenantLimits.ByUserID(userID)
636632
if l != nil {

0 commit comments

Comments
 (0)