Skip to content

Commit 42ddb68

Browse files
authored
fix: Revert "feat: Assert for bad max_query_lookback config (#16362)" (#16441)
1 parent 23258ef commit 42ddb68

File tree

2 files changed

+1
-56
lines changed

2 files changed

+1
-56
lines changed

‎production/ksonnet/loki/common.libsonnet

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,6 @@ local k = import 'ksonnet-util/kausal.libsonnet';
4444
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
4545
container.mixin.readinessProbe.withInitialDelaySeconds(15) +
4646
container.mixin.readinessProbe.withTimeoutSeconds(1),
47-
48-
parseDuration(duration)::
49-
if std.endsWith(duration, 's') then
50-
std.parseInt(std.substr(duration, 0, std.length(duration) - 1))
51-
else if std.endsWith(duration, 'm') then
52-
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 60
53-
else if std.endsWith(duration, 'h') then
54-
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 3600
55-
else if std.endsWith(duration, 'd') then
56-
std.parseInt(std.substr(duration, 0, std.length(duration) - 1)) * 86400
57-
else
58-
error 'unable to parse duration %s' % duration,
5947
},
6048

6149
// functions for k8s objects
Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local common = import 'common.libsonnet';
21
local k = import 'ksonnet-util/kausal.libsonnet';
2+
33
{
44
_config+: {
55
overrides: {
@@ -39,47 +39,4 @@ local k = import 'ksonnet-util/kausal.libsonnet';
3939
+ (if std.length($._config.multi_kv_config) > 0 then { multi_kv_config: $._config.multi_kv_config } else {}),
4040
),
4141
}),
42-
43-
local checkRetentionStreams(retentionStreams, maxQueryLookback) =
44-
std.foldl(
45-
function(acc, retentionStream) acc && common.parseDuration(retentionStream.period) <= common.parseDuration(maxQueryLookback),
46-
retentionStreams,
47-
true
48-
),
49-
50-
isLookbackLongerThanRetention(tenantCfg)::
51-
local retentionPeriod = tenantCfg.retention_period;
52-
local lookback = tenantCfg.max_query_lookback;
53-
if std.objectHas(tenantCfg, 'max_query_lookback') &&
54-
std.objectHas(tenantCfg, 'retention_period') then
55-
common.parseDuration(lookback) >= common.parseDuration(retentionPeriod)
56-
else
57-
true,
58-
59-
isLookbackLongerThanStreamRetention(tenantCfg)::
60-
local retentionStream = tenantCfg.retention_stream;
61-
local lookback = tenantCfg.max_query_lookback;
62-
if std.objectHas(tenantCfg, 'max_query_lookback') &&
63-
std.objectHas(tenantCfg, 'retention_stream') then
64-
checkRetentionStreams(retentionStream, lookback)
65-
else
66-
true,
67-
68-
checkTenantRetention(tenant)::
69-
local tenantCfg = $._config.overrides[tenant];
70-
if $.isLookbackLongerThanRetention(tenantCfg) &&
71-
$.isLookbackLongerThanStreamRetention(tenantCfg) then
72-
true
73-
else
74-
false,
75-
76-
local tenants = std.objectFields($._config.overrides),
77-
78-
local validRetentionsCheck = std.foldl(
79-
function(acc, tenant) if !$.checkTenantRetention(tenant) then { valid: false, failedTenant: [tenant] + acc.failedTenant } else acc,
80-
tenants,
81-
{ valid: true, failedTenant: [] }
82-
),
83-
84-
assert validRetentionsCheck.valid : 'retention period longer than max_query_lookback for tenants %s' % std.join(', ', validRetentionsCheck.failedTenant),
8542
}

0 commit comments

Comments
 (0)