|
1 |
| -local common = import 'common.libsonnet'; |
2 | 1 | local k = import 'ksonnet-util/kausal.libsonnet';
|
| 2 | + |
3 | 3 | {
|
4 | 4 | _config+: {
|
5 | 5 | overrides: {
|
@@ -39,47 +39,4 @@ local k = import 'ksonnet-util/kausal.libsonnet';
|
39 | 39 | + (if std.length($._config.multi_kv_config) > 0 then { multi_kv_config: $._config.multi_kv_config } else {}),
|
40 | 40 | ),
|
41 | 41 | }),
|
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), |
85 | 42 | }
|
0 commit comments