Skip to content

Commit

Permalink
fix: Revert "feat: Assert for bad max_query_lookback config (#16362)…
Browse files Browse the repository at this point in the history
…" (#16441)
  • Loading branch information
DylanGuedes authored Feb 25, 2025
1 parent 23258ef commit 42ddb68
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 56 deletions.
12 changes: 0 additions & 12 deletions production/ksonnet/loki/common.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ local k = import 'ksonnet-util/kausal.libsonnet';
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
container.mixin.readinessProbe.withInitialDelaySeconds(15) +
container.mixin.readinessProbe.withTimeoutSeconds(1),

parseDuration(duration)::
if std.endsWith(duration, 's') then
std.parseInt(std.substr(duration, 0, std.length(duration) - 1))
else if std.endsWith(duration, 'm') then
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 60
else if std.endsWith(duration, 'h') then
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 3600
else if std.endsWith(duration, 'd') then
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 86400
else
error 'unable to parse duration %s' % duration,
},

// functions for k8s objects
Expand Down
45 changes: 1 addition & 44 deletions production/ksonnet/loki/overrides.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local common = import 'common.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';

{
_config+: {
overrides: {
Expand Down Expand Up @@ -39,47 +39,4 @@ local k = import 'ksonnet-util/kausal.libsonnet';
+ (if std.length($._config.multi_kv_config) > 0 then { multi_kv_config: $._config.multi_kv_config } else {}),
),
}),

local checkRetentionStreams(retentionStreams, maxQueryLookback) =
std.foldl(
function(acc, retentionStream) acc && common.parseDuration(retentionStream.period) <= common.parseDuration(maxQueryLookback),
retentionStreams,
true
),

isLookbackLongerThanRetention(tenantCfg)::
local retentionPeriod = tenantCfg.retention_period;
local lookback = tenantCfg.max_query_lookback;
if std.objectHas(tenantCfg, 'max_query_lookback') &&
std.objectHas(tenantCfg, 'retention_period') then
common.parseDuration(lookback) >= common.parseDuration(retentionPeriod)
else
true,

isLookbackLongerThanStreamRetention(tenantCfg)::
local retentionStream = tenantCfg.retention_stream;
local lookback = tenantCfg.max_query_lookback;
if std.objectHas(tenantCfg, 'max_query_lookback') &&
std.objectHas(tenantCfg, 'retention_stream') then
checkRetentionStreams(retentionStream, lookback)
else
true,

checkTenantRetention(tenant)::
local tenantCfg = $._config.overrides[tenant];
if $.isLookbackLongerThanRetention(tenantCfg) &&
$.isLookbackLongerThanStreamRetention(tenantCfg) then
true
else
false,

local tenants = std.objectFields($._config.overrides),

local validRetentionsCheck = std.foldl(
function(acc, tenant) if !$.checkTenantRetention(tenant) then { valid: false, failedTenant: [tenant] + acc.failedTenant } else acc,
tenants,
{ valid: true, failedTenant: [] }
),

assert validRetentionsCheck.valid : 'retention period longer than max_query_lookback for tenants %s' % std.join(', ', validRetentionsCheck.failedTenant),
}

0 comments on commit 42ddb68

Please sign in to comment.