Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 714a966

Browse files
authored
Chunks blocks migration (#148)
* Allow configuring querier with second store engine. * Introduced newIngesterStatefulSet and newIngesterPdb functions. * Rename parameters to be more clear.
1 parent 796e073 commit 714a966

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

cortex/config.libsonnet

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
// Use the Cortex chunks storage engine by default, while giving the ability
5959
// to switch to tsdb storage.
6060
storage_engine: 'chunks',
61+
// Secondary storage engine is only used for querying.
62+
querier_second_storage_engine: null,
6163
storage_tsdb_bucket_name: error 'must specify GCS bucket name to store TSDB blocks',
6264

6365
store_gateway_replication_factor: 3,
@@ -113,7 +115,7 @@
113115

114116
storeConfig: self.storeMemcachedChunksConfig,
115117

116-
storeMemcachedChunksConfig: if $._config.memcached_chunks_enabled && $._config.storage_engine == 'chunks' then
118+
storeMemcachedChunksConfig: if $._config.memcached_chunks_enabled && ($._config.storage_engine == 'chunks' || $._config.querier_second_storage_engine == 'chunks') then
117119
{
118120
'store.chunks-cache.memcached.hostname': 'memcached.%s.svc.cluster.local' % $._config.namespace,
119121
'store.chunks-cache.memcached.service': 'memcached-client',
@@ -131,8 +133,8 @@
131133
// TSDB blocks storage configuration, used only when 'tsdb' storage
132134
// engine is explicitly enabled.
133135
storageTSDBConfig: (
134-
if $._config.storage_engine != 'tsdb' then {} else {
135-
'store.engine': 'tsdb',
136+
if $._config.storage_engine == 'tsdb' || $._config.querier_second_storage_engine == 'tsdb' then {
137+
'store.engine': $._config.storage_engine, // May still be chunks
136138
'experimental.tsdb.dir': '/data/tsdb',
137139
'experimental.tsdb.bucket-store.sync-dir': '/data/tsdb',
138140
'experimental.tsdb.bucket-store.ignore-deletion-marks-delay': '1h',
@@ -147,7 +149,7 @@
147149
'experimental.store-gateway.sharding-ring.consul.hostname': 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
148150
'experimental.store-gateway.sharding-ring.prefix': '',
149151
'experimental.store-gateway.replication-factor': $._config.store_gateway_replication_factor,
150-
}
152+
} else {}
151153
),
152154

153155
// Shared between the Ruler and Querier

cortex/ingester.libsonnet

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@
7575

7676
local podDisruptionBudget = $.policy.v1beta1.podDisruptionBudget,
7777

78-
ingester_pdb:
78+
newIngesterPdb(pdbName, ingesterName)::
7979
podDisruptionBudget.new() +
80-
podDisruptionBudget.mixin.metadata.withName('ingester-pdb') +
81-
podDisruptionBudget.mixin.metadata.withLabels({ name: 'ingester-pdb' }) +
82-
podDisruptionBudget.mixin.spec.selector.withMatchLabels({ name: name }) +
80+
podDisruptionBudget.mixin.metadata.withName(pdbName) +
81+
podDisruptionBudget.mixin.metadata.withLabels({ name: pdbName }) +
82+
podDisruptionBudget.mixin.spec.selector.withMatchLabels({ name: ingesterName }) +
8383
podDisruptionBudget.mixin.spec.withMaxUnavailable(1),
84+
85+
ingester_pdb: self.newIngesterPdb('ingester-pdb', name),
8486
}

cortex/querier.libsonnet

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
target: 'querier',
1212

13-
// Increase HTTP server response write timeout, as we were seeing some
13+
// Increase HTTP server response write timeout, as we were seeing some
1414
// queries that return a lot of data timeing out.
1515
'server.http-write-timeout': '1m',
1616

@@ -22,6 +22,8 @@
2222
'querier.frontend-address': 'query-frontend-discovery.%(namespace)s.svc.cluster.local:9095' % $._config,
2323
'querier.frontend-client.grpc-max-send-msg-size': 100 << 20,
2424

25+
'querier.second-store-engine': $._config.querier_second_storage_engine,
26+
2527
'log.level': 'debug',
2628
},
2729

cortex/tsdb.libsonnet

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,17 @@
8484
'ingester.tokens-file-path': '/data/tokens',
8585
},
8686

87-
ingester_container+::
88-
container.withVolumeMountsMixin([
89-
volumeMount.new('ingester-data', '/data'),
90-
]),
91-
92-
ingester_statefulset:
93-
statefulSet.new('ingester', 3, [$.ingester_container], ingester_data_pvc) +
94-
statefulSet.mixin.spec.withServiceName('ingester') +
87+
newIngesterStatefulSet(name, container)::
88+
statefulSet.new(name, 3, [
89+
container + $.core.v1.container.withVolumeMountsMixin([
90+
volumeMount.new('ingester-data', '/data'),
91+
]),
92+
], ingester_data_pvc) +
93+
statefulSet.mixin.spec.withServiceName(name) +
9594
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
96-
statefulSet.mixin.metadata.withLabels({ name: 'ingester' }) +
97-
statefulSet.mixin.spec.template.metadata.withLabels({ name: 'ingester' } + $.ingester_deployment_labels) +
98-
statefulSet.mixin.spec.selector.withMatchLabels({ name: 'ingester' }) +
95+
statefulSet.mixin.metadata.withLabels({ name: name }) +
96+
statefulSet.mixin.spec.template.metadata.withLabels({ name: name } + $.ingester_deployment_labels) +
97+
statefulSet.mixin.spec.selector.withMatchLabels({ name: name }) +
9998
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
10099
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(600) +
101100
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
@@ -108,6 +107,8 @@
108107
// ready).
109108
statefulSet.mixin.spec.withPodManagementPolicy('Parallel'),
110109

110+
ingester_statefulset: self.newIngesterStatefulSet('ingester', $.ingester_container),
111+
111112
ingester_service:
112113
$.util.serviceFor($.ingester_statefulset, $.ingester_service_ignored_labels),
113114

0 commit comments

Comments
 (0)