Skip to content

Commit 5997fc3

Browse files
authored
Introduce data stream options via dedicated classes (#117357)
In this PR we move the failure store configuration from the `data_stream` in a composable index template to the `template` section under the `data_stream_options`. The reason for this change is that we want to be able to compose the failure store configuration via component templates. **Previous composable index template** ``` { "index_patterns": [....], "template": { ...... }, "data_stream": { "failure_store": true } } ``` **New composable index template** ``` { "index_patterns": [....], "template": { "data_stream_options": { "failure_store": { "enabled": true } }, ...... }, "data_stream": {} } ``` **Composition logic** | Component Template A | Composable Index Template | Resolved data stream options | |-------------------------|-----------------------------|-------------------------------| | `{"failure_store": {"enabled": true}}` | - |`{"failure_store": {"enabled": true}}`| | `{"failure_store": {"enabled": true}}` | `{"failure_store": {"enabled": false}}` |`{"failure_store": {"enabled": false}}`| | - | `{"failure_store": {"enabled": true}}` |`{"failure_store": {"enabled": true}}`| | `{"failure_store": null}` | `{"failure_store": {"enabled": true}}` |`{"failure_store": {"enabled": true}}`| | `{"failure_store": {"enabled": true}}` | `{"failure_store": null}` |`{}`| More context and discussions can be found in the comments of #113863.
1 parent 2381559 commit 5997fc3

File tree

44 files changed

+1458
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1458
-264
lines changed

modules/data-streams/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,32 @@ if (buildParams.isSnapshotBuild() == false) {
4242

4343
tasks.named("yamlRestCompatTestTransform").configure({ task ->
4444
task.skipTest("data_stream/10_basic/Create hidden data stream", "warning does not exist for compatibility")
45+
46+
// Failure store configuration changed on 8.18 (earlier versions behind feature flag)
47+
task.skipTest("data_stream/10_basic/Create data stream with failure store", "Configuring the failure store via data stream templates is not supported anymore.")
48+
task.skipTest("data_stream/10_basic/Delete data stream with failure store", "Configuring the failure store via data stream templates is not supported anymore.")
49+
task.skipTest("data_stream/10_basic/Delete data stream with failure store uninitialized", "Configuring the failure store via data stream templates is not supported anymore.")
50+
51+
task.skipTest("data_stream/30_auto_create_data_stream/Don't initialize failure store during data stream auto-creation on successful index", "Configuring the failure store via data stream templates is not supported anymore.")
52+
53+
task.skipTest("data_stream/150_tsdb/TSDB failures go to failure store", "Configuring the failure store via data stream templates is not supported anymore.")
54+
55+
task.skipTest("data_stream/170_modify_data_stream/Modify a data stream's failure store", "Configuring the failure store via data stream templates is not supported anymore.")
56+
57+
task.skipTest("data_stream/190_failure_store_redirection/Failure redirects to original failure store during index change if final pipeline changes target", "Configuring the failure store via data stream templates is not supported anymore.")
58+
task.skipTest("data_stream/190_failure_store_redirection/Ensure failure is redirected to correct failure store after a reroute processor", "Configuring the failure store via data stream templates is not supported anymore.")
59+
task.skipTest("data_stream/190_failure_store_redirection/Test failure store status with bulk request", "Configuring the failure store via data stream templates is not supported anymore.")
60+
task.skipTest("data_stream/190_failure_store_redirection/Redirect ingest failure in data stream to failure store", "Configuring the failure store via data stream templates is not supported anymore.")
61+
task.skipTest("data_stream/190_failure_store_redirection/Failure redirects to correct failure store when pipeline loop is detected", "Configuring the failure store via data stream templates is not supported anymore.")
62+
task.skipTest("data_stream/190_failure_store_redirection/Failure redirects to correct failure store when index loop is detected", "Configuring the failure store via data stream templates is not supported anymore.")
63+
task.skipTest("data_stream/190_failure_store_redirection/Failure redirects to original failure store during index change if self referenced", "Configuring the failure store via data stream templates is not supported anymore.")
64+
task.skipTest("data_stream/190_failure_store_redirection/Redirect shard failure in data stream to failure store", "Configuring the failure store via data stream templates is not supported anymore.")
65+
task.skipTest("data_stream/190_failure_store_redirection/Version conflicts are not redirected to failure store", "Configuring the failure store via data stream templates is not supported anymore.")
66+
67+
task.skipTest("data_stream/200_rollover_failure_store/Lazily roll over a data stream's failure store after an ingest failure", "Configuring the failure store via data stream templates is not supported anymore.")
68+
task.skipTest("data_stream/200_rollover_failure_store/A failure store marked for lazy rollover should only be rolled over when there is a failure", "Configuring the failure store via data stream templates is not supported anymore.")
69+
task.skipTest("data_stream/200_rollover_failure_store/Roll over a data stream's failure store without conditions", "Configuring the failure store via data stream templates is not supported anymore.")
70+
task.skipTest("data_stream/200_rollover_failure_store/Lazily roll over a data stream's failure store after a shard failure", "Configuring the failure store via data stream templates is not supported anymore.")
71+
task.skipTest("data_stream/200_rollover_failure_store/Don't roll over a data stream's failure store when conditions aren't met", "Configuring the failure store via data stream templates is not supported anymore.")
72+
task.skipTest("data_stream/200_rollover_failure_store/Roll over a data stream's failure store with conditions", "Configuring the failure store via data stream templates is not supported anymore.")
4573
})

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.elasticsearch.cluster.metadata.DataStreamAction;
6868
import org.elasticsearch.cluster.metadata.DataStreamAlias;
6969
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
70+
import org.elasticsearch.cluster.metadata.DataStreamTestHelper;
7071
import org.elasticsearch.cluster.metadata.IndexMetadata;
7172
import org.elasticsearch.cluster.metadata.IndexMetadataStats;
7273
import org.elasticsearch.cluster.metadata.IndexWriteLoad;
@@ -2447,9 +2448,10 @@ static void putComposableIndexTemplate(
24472448
.mappings(mappings == null ? null : CompressedXContent.fromJSON(mappings))
24482449
.aliases(aliases)
24492450
.lifecycle(lifecycle)
2451+
.dataStreamOptions(DataStreamTestHelper.createDataStreamOptionsTemplate(withFailureStore))
24502452
)
24512453
.metadata(metadata)
2452-
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false, withFailureStore))
2454+
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate())
24532455
.build()
24542456
);
24552457
client().execute(TransportPutComposableIndexTemplateAction.TYPE, request).actionGet();

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/FailureStoreMetricsWithIncrementalBulkIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.elasticsearch.action.support.PlainActionFuture;
2222
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
2323
import org.elasticsearch.cluster.metadata.DataStream;
24+
import org.elasticsearch.cluster.metadata.DataStreamTestHelper;
2425
import org.elasticsearch.cluster.metadata.Template;
2526
import org.elasticsearch.common.compress.CompressedXContent;
2627
import org.elasticsearch.common.settings.Settings;
@@ -165,8 +166,8 @@ private void createDataStreamWithFailureStore() throws IOException {
165166
request.indexTemplate(
166167
ComposableIndexTemplate.builder()
167168
.indexPatterns(List.of(DATA_STREAM_NAME + "*"))
168-
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false, true))
169-
.template(new Template(null, new CompressedXContent("""
169+
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate())
170+
.template(Template.builder().mappings(new CompressedXContent("""
170171
{
171172
"dynamic": false,
172173
"properties": {
@@ -177,7 +178,7 @@ private void createDataStreamWithFailureStore() throws IOException {
177178
"type": "long"
178179
}
179180
}
180-
}"""), null))
181+
}""")).dataStreamOptions(DataStreamTestHelper.createDataStreamOptionsTemplate(true)))
181182
.build()
182183
);
183184
assertAcked(safeGet(client().execute(TransportPutComposableIndexTemplateAction.TYPE, request)));

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.action.support.IndicesOptions;
2424
import org.elasticsearch.action.support.WriteRequest;
2525
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
26+
import org.elasticsearch.cluster.metadata.DataStreamTestHelper;
2627
import org.elasticsearch.cluster.metadata.IndexMetadata;
2728
import org.elasticsearch.cluster.metadata.Template;
2829
import org.elasticsearch.common.compress.CompressedXContent;
@@ -283,8 +284,8 @@ private void putComposableIndexTemplate(boolean failureStore) throws IOException
283284
request.indexTemplate(
284285
ComposableIndexTemplate.builder()
285286
.indexPatterns(List.of(dataStream + "*"))
286-
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false, failureStore))
287-
.template(new Template(null, new CompressedXContent("""
287+
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate())
288+
.template(Template.builder().mappings(new CompressedXContent("""
288289
{
289290
"dynamic": false,
290291
"properties": {
@@ -295,7 +296,7 @@ private void putComposableIndexTemplate(boolean failureStore) throws IOException
295296
"type": "long"
296297
}
297298
}
298-
}"""), null))
299+
}""")).dataStreamOptions(DataStreamTestHelper.createDataStreamOptionsTemplate(failureStore)))
299300
.build()
300301
);
301302
client().execute(TransportPutComposableIndexTemplateAction.TYPE, request).actionGet();

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.elasticsearch.cluster.metadata.DataStream;
4141
import org.elasticsearch.cluster.metadata.DataStreamAction;
4242
import org.elasticsearch.cluster.metadata.DataStreamLifecycle;
43+
import org.elasticsearch.cluster.metadata.DataStreamTestHelper;
4344
import org.elasticsearch.cluster.metadata.IndexMetadata;
4445
import org.elasticsearch.cluster.metadata.Template;
4546
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -1226,9 +1227,10 @@ static void putComposableIndexTemplate(
12261227
.settings(settings)
12271228
.mappings(mappings == null ? null : CompressedXContent.fromJSON(mappings))
12281229
.lifecycle(lifecycle)
1230+
.dataStreamOptions(DataStreamTestHelper.createDataStreamOptionsTemplate(withFailureStore))
12291231
)
12301232
.metadata(metadata)
1231-
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false, withFailureStore))
1233+
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate())
12321234
.build()
12331235
);
12341236
client().execute(TransportPutComposableIndexTemplateAction.TYPE, request).actionGet();

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DataStreamOptionsIT.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
import org.elasticsearch.client.Request;
1313
import org.elasticsearch.client.Response;
14+
import org.elasticsearch.client.ResponseException;
1415
import org.junit.Before;
1516

1617
import java.io.IOException;
1718
import java.util.List;
1819
import java.util.Map;
1920

21+
import static org.hamcrest.Matchers.containsString;
2022
import static org.hamcrest.Matchers.equalTo;
2123
import static org.hamcrest.Matchers.is;
2224
import static org.hamcrest.Matchers.nullValue;
@@ -40,10 +42,14 @@ public void setup() throws IOException {
4042
"template": {
4143
"settings": {
4244
"number_of_replicas": 0
45+
},
46+
"data_stream_options": {
47+
"failure_store": {
48+
"enabled": true
49+
}
4350
}
4451
},
4552
"data_stream": {
46-
"failure_store": true
4753
}
4854
}
4955
""");
@@ -59,12 +65,63 @@ public void setup() throws IOException {
5965
assertThat(dataStreams.size(), is(1));
6066
Map<String, Object> dataStream = (Map<String, Object>) dataStreams.get(0);
6167
assertThat(dataStream.get("name"), equalTo(DATA_STREAM_NAME));
68+
assertThat(((Map<String, Object>) dataStream.get("failure_store")).get("enabled"), is(true));
6269
List<String> backingIndices = getIndices(dataStream);
6370
assertThat(backingIndices.size(), is(1));
6471
List<String> failureStore = getFailureStore(dataStream);
6572
assertThat(failureStore.size(), is(1));
6673
}
6774

75+
public void testExplicitlyResetDataStreamOptions() throws IOException {
76+
Request putComponentTemplateRequest = new Request("POST", "/_component_template/with-options");
77+
putComponentTemplateRequest.setJsonEntity("""
78+
{
79+
"template": {
80+
"data_stream_options": {
81+
"failure_store": {
82+
"enabled": true
83+
}
84+
}
85+
}
86+
}
87+
""");
88+
assertOK(client().performRequest(putComponentTemplateRequest));
89+
90+
Request invalidRequest = new Request("POST", "/_index_template/other-template");
91+
invalidRequest.setJsonEntity("""
92+
{
93+
"index_patterns": ["something-else"],
94+
"composed_of" : ["with-options"],
95+
"template": {
96+
"settings": {
97+
"number_of_replicas": 0
98+
}
99+
}
100+
}
101+
""");
102+
Exception error = expectThrows(ResponseException.class, () -> client().performRequest(invalidRequest));
103+
assertThat(
104+
error.getMessage(),
105+
containsString("specifies data stream options that can only be used in combination with a data stream")
106+
);
107+
108+
// Check that when we nullify the data stream options we can create use any component template in a non data stream template
109+
Request otherRequest = new Request("POST", "/_index_template/other-template");
110+
otherRequest.setJsonEntity("""
111+
{
112+
"index_patterns": ["something-else"],
113+
"composed_of" : ["with-options"],
114+
"template": {
115+
"settings": {
116+
"number_of_replicas": 0
117+
},
118+
"data_stream_options": null
119+
}
120+
}
121+
""");
122+
assertOK(client().performRequest(otherRequest));
123+
}
124+
68125
public void testEnableDisableFailureStore() throws IOException {
69126
{
70127
assertAcknowledged(client().performRequest(new Request("DELETE", "/_data_stream/" + DATA_STREAM_NAME + "/_options")));

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/FailureStoreQueryParamIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ public void setup() throws IOException {
4242
"template": {
4343
"settings": {
4444
"number_of_replicas": 0
45+
},
46+
"data_stream_options": {
47+
"failure_store": {
48+
"enabled": true
49+
}
4550
}
4651
},
4752
"data_stream": {
48-
"failure_store": true
4953
}
5054
}
5155
""");

modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/10_basic.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,12 @@ setup:
212212
---
213213
"Create data stream with failure store":
214214
- requires:
215-
cluster_features: ["gte_v8.15.0"]
216-
reason: "data stream failure stores default settings changed in 8.15+"
215+
test_runner_features: [ capabilities, allowed_warnings ]
216+
reason: "Data stream failure stores config in templates was added in 8.18+"
217+
capabilities:
218+
- method: POST
219+
path: /_index_template/{template}
220+
capabilities: [ 'failure_store_in_template' ]
217221

218222
- do:
219223
ingest.put_pipeline:
@@ -256,8 +260,7 @@ setup:
256260
name: my-template4
257261
body:
258262
index_patterns: [ failure-data-stream1, failure-data-stream2 ]
259-
data_stream:
260-
failure_store: true
263+
data_stream: {}
261264
template:
262265
settings:
263266
index:
@@ -269,6 +272,9 @@ setup:
269272
type: date
270273
count:
271274
type: long
275+
data_stream_options:
276+
failure_store:
277+
enabled: true
272278

273279
- do:
274280
indices.create_data_stream:
@@ -632,8 +638,12 @@ setup:
632638
---
633639
"Delete data stream with failure store":
634640
- requires:
635-
cluster_features: ["gte_v8.15.0"]
636-
reason: "data stream failure stores REST structure changed in 8.15+"
641+
reason: "Data stream failure stores config in templates was added in 8.18+"
642+
test_runner_features: [ allowed_warnings, capabilities ]
643+
capabilities:
644+
- method: POST
645+
path: /_index_template/{template}
646+
capabilities: [ 'failure_store_in_template' ]
637647

638648
- do:
639649
allowed_warnings:
@@ -642,15 +652,17 @@ setup:
642652
name: my-template4
643653
body:
644654
index_patterns: [ failure-data-stream1 ]
645-
data_stream:
646-
failure_store: true
655+
data_stream: {}
647656
template:
648657
mappings:
649658
properties:
650659
'@timestamp':
651660
type: date
652661
count:
653662
type: long
663+
data_stream_options:
664+
failure_store:
665+
enabled: true
654666

655667
- do:
656668
indices.create_data_stream:
@@ -722,8 +734,12 @@ setup:
722734
---
723735
"Delete data stream with failure store uninitialized":
724736
- requires:
725-
cluster_features: ["gte_v8.15.0"]
726-
reason: "data stream failure stores REST structure changed in 8.15+"
737+
reason: "Data stream failure stores config in templates was added in 8.18+"
738+
test_runner_features: [ capabilities, allowed_warnings ]
739+
capabilities:
740+
- method: POST
741+
path: /_index_template/{template}
742+
capabilities: [ 'failure_store_in_template' ]
727743

728744
- do:
729745
allowed_warnings:
@@ -732,8 +748,11 @@ setup:
732748
name: my-template4
733749
body:
734750
index_patterns: [ failure-data-stream1 ]
735-
data_stream:
736-
failure_store: true
751+
data_stream: {}
752+
template:
753+
data_stream_options:
754+
failure_store:
755+
enabled: true
737756

738757
- do:
739758
indices.create_data_stream:

modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/150_tsdb.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,20 @@ index without timestamp:
185185
---
186186
TSDB failures go to failure store:
187187
- requires:
188-
cluster_features: ["data_stream.failure_store.tsdb_fix"]
189-
reason: "tests tsdb failure store fixes in 8.16.0 that catch timestamp errors that happen earlier in the process and redirect them to the failure store."
190-
188+
reason: "Data stream failure stores config in templates was added in 8.18+"
189+
test_runner_features: [ capabilities, allowed_warnings ]
190+
capabilities:
191+
- method: POST
192+
path: /_index_template/{template}
193+
capabilities: [ 'failure_store_in_template' ]
191194
- do:
192195
allowed_warnings:
193196
- "index template [my-template2] has index patterns [fs-k8s*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template2] will take precedence during new index creation"
194197
indices.put_index_template:
195198
name: my-template2
196199
body:
197200
index_patterns: [ "fs-k8s*" ]
198-
data_stream:
199-
failure_store: true
201+
data_stream: {}
200202
template:
201203
settings:
202204
index:
@@ -207,6 +209,9 @@ TSDB failures go to failure store:
207209
time_series:
208210
start_time: 2021-04-28T00:00:00Z
209211
end_time: 2021-04-29T00:00:00Z
212+
data_stream_options:
213+
failure_store:
214+
enabled: true
210215
mappings:
211216
properties:
212217
"@timestamp":

0 commit comments

Comments
 (0)