Skip to content

Commit bb357f6

Browse files
authored
[7.x] Move internal index templates to composable templates (#61457) (#61661)
This change moves watcher, ILM history and SLM history templates to composable templates. Versions are updated to reflect the switch. Only change to the templates themselves is added `_meta` to mark them as managed
1 parent ebd1569 commit bb357f6

File tree

20 files changed

+2104
-588
lines changed

20 files changed

+2104
-588
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/slm/history/SnapshotLifecycleTemplateRegistry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class SnapshotLifecycleTemplateRegistry extends IndexTemplateRegistry {
3636
// history (please add a comment why you increased the version here)
3737
// version 1: initial
3838
// version 2: converted to hidden index
39-
public static final int INDEX_TEMPLATE_VERSION = 2;
39+
// version 3: templates moved to composable templates
40+
public static final int INDEX_TEMPLATE_VERSION = 3;
4041

4142
public static final String SLM_TEMPLATE_VERSION_VARIABLE = "xpack.slm.template.version";
4243
public static final String SLM_TEMPLATE_NAME = ".slm-history";
@@ -69,7 +70,7 @@ public SnapshotLifecycleTemplateRegistry(Settings nodeSettings, ClusterService c
6970
}
7071

7172
@Override
72-
protected List<IndexTemplateConfig> getLegacyTemplateConfigs() {
73+
protected List<IndexTemplateConfig> getComposableTemplateConfigs() {
7374
if (slmHistoryEnabled == false) {
7475
return Collections.emptyList();
7576
}
@@ -90,9 +91,9 @@ protected String getOrigin() {
9091
}
9192

9293
public boolean validate(ClusterState state) {
93-
boolean allTemplatesPresent = getLegacyTemplateConfigs().stream()
94+
boolean allTemplatesPresent = getComposableTemplateConfigs().stream()
9495
.map(IndexTemplateConfig::getTemplateName)
95-
.allMatch(name -> state.metadata().getTemplates().containsKey(name));
96+
.allMatch(name -> state.metadata().templatesV2().containsKey(name));
9697

9798
Optional<Map<String, LifecyclePolicy>> maybePolicies = Optional
9899
.<IndexLifecycleMetadata>ofNullable(state.metadata().custom(IndexLifecycleMetadata.TYPE))

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherIndexTemplateRegistryField.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ public final class WatcherIndexTemplateRegistryField {
1616
// version 9: add a user field defining which user executed the watch
1717
// version 10: add support for foreach path in actions
1818
// version 11: watch history indices are hidden
19+
// version 12: templates changed to composable templates
1920
// Note: if you change this, also inform the kibana team around the watcher-ui
20-
public static final int INDEX_TEMPLATE_VERSION = 11;
21+
public static final int INDEX_TEMPLATE_VERSION = 12;
2122
public static final int INDEX_TEMPLATE_VERSION_10 = 10;
23+
public static final int INDEX_TEMPLATE_VERSION_11 = 11;
2224
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
2325
public static final String HISTORY_TEMPLATE_NAME_10 = ".watch-history-" + INDEX_TEMPLATE_VERSION_10;
26+
public static final String HISTORY_TEMPLATE_NAME_11 = ".watch-history-" + INDEX_TEMPLATE_VERSION_11;
2427
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
2528
public static final String HISTORY_TEMPLATE_NAME_NO_ILM_10 = ".watch-history-no-ilm-10";
29+
public static final String HISTORY_TEMPLATE_NAME_NO_ILM_11 = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION_11;
2630
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
31+
public static final String TRIGGERED_TEMPLATE_NAME_11 = ".triggered_watches-11";
2732
public static final String WATCHES_TEMPLATE_NAME = ".watches";
33+
public static final String WATCHES_TEMPLATE_NAME_11 = ".watches-11";
2834
public static final String[] TEMPLATE_NAMES = new String[] {
2935
HISTORY_TEMPLATE_NAME, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
3036
};

x-pack/plugin/core/src/main/resources/ilm-history.json

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,88 @@
22
"index_patterns": [
33
"ilm-history-${xpack.ilm_history.template.version}*"
44
],
5-
"order": 2147483647,
6-
"settings": {
7-
"index.number_of_shards": 1,
8-
"index.number_of_replicas": 0,
9-
"index.auto_expand_replicas": "0-1",
10-
"index.lifecycle.name": "ilm-history-ilm-policy",
11-
"index.lifecycle.rollover_alias": "ilm-history-${xpack.ilm_history.template.version}",
12-
"index.hidden": true,
13-
"index.format": 1
14-
},
15-
"mappings": {
16-
"_doc": {
17-
"dynamic": false,
18-
"properties": {
19-
"@timestamp": {
20-
"type": "date",
21-
"format": "epoch_millis"
22-
},
23-
"policy": {
24-
"type": "keyword"
25-
},
26-
"index": {
27-
"type": "keyword"
28-
},
29-
"index_age":{
30-
"type": "long"
31-
},
32-
"success": {
33-
"type": "boolean"
34-
},
35-
"state": {
36-
"type": "object",
37-
"dynamic": true,
38-
"properties": {
39-
"phase": {
40-
"type": "keyword"
41-
},
42-
"action": {
43-
"type": "keyword"
44-
},
45-
"step": {
46-
"type": "keyword"
47-
},
48-
"failed_step": {
49-
"type": "keyword"
50-
},
51-
"is_auto-retryable_error": {
52-
"type": "keyword"
53-
},
54-
"creation_date": {
55-
"type": "date",
56-
"format": "epoch_millis"
57-
},
58-
"phase_time": {
59-
"type": "date",
60-
"format": "epoch_millis"
61-
},
62-
"action_time": {
63-
"type": "date",
64-
"format": "epoch_millis"
65-
},
66-
"step_time": {
67-
"type": "date",
68-
"format": "epoch_millis"
69-
},
70-
"phase_definition": {
71-
"type": "text"
72-
},
73-
"step_info": {
74-
"type": "text"
5+
"template": {
6+
"settings": {
7+
"index.number_of_shards": 1,
8+
"index.number_of_replicas": 0,
9+
"index.auto_expand_replicas": "0-1",
10+
"index.lifecycle.name": "ilm-history-ilm-policy",
11+
"index.lifecycle.rollover_alias": "ilm-history-${xpack.ilm_history.template.version}",
12+
"index.hidden": true,
13+
"index.format": 1
14+
},
15+
"mappings": {
16+
"dynamic": false,
17+
"properties": {
18+
"@timestamp": {
19+
"type": "date",
20+
"format": "epoch_millis"
21+
},
22+
"policy": {
23+
"type": "keyword"
24+
},
25+
"index": {
26+
"type": "keyword"
27+
},
28+
"index_age": {
29+
"type": "long"
30+
},
31+
"success": {
32+
"type": "boolean"
33+
},
34+
"state": {
35+
"type": "object",
36+
"dynamic": true,
37+
"properties": {
38+
"phase": {
39+
"type": "keyword"
40+
},
41+
"action": {
42+
"type": "keyword"
43+
},
44+
"step": {
45+
"type": "keyword"
46+
},
47+
"failed_step": {
48+
"type": "keyword"
49+
},
50+
"is_auto-retryable_error": {
51+
"type": "keyword"
52+
},
53+
"creation_date": {
54+
"type": "date",
55+
"format": "epoch_millis"
56+
},
57+
"phase_time": {
58+
"type": "date",
59+
"format": "epoch_millis"
60+
},
61+
"action_time": {
62+
"type": "date",
63+
"format": "epoch_millis"
64+
},
65+
"step_time": {
66+
"type": "date",
67+
"format": "epoch_millis"
68+
},
69+
"phase_definition": {
70+
"type": "text"
71+
},
72+
"step_info": {
73+
"type": "text"
74+
}
7575
}
76+
},
77+
"error_details": {
78+
"type": "text"
7679
}
77-
},
78-
"error_details": {
79-
"type": "text"
8080
}
8181
}
82-
}
8382
},
83+
"_meta": {
84+
"description": "index template for ILM history indices",
85+
"managed": true
86+
},
87+
"priority": 2147483647,
8488
"version": ${xpack.ilm_history.template.version}
8589
}

x-pack/plugin/core/src/main/resources/slm-history.json

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"index_patterns": [
33
".slm-history-${xpack.slm.template.version}*"
44
],
5-
"order": 2147483647,
6-
"settings": {
7-
"index.number_of_shards": 1,
8-
"index.number_of_replicas": 0,
9-
"index.auto_expand_replicas": "0-1",
10-
"index.lifecycle.name": "slm-history-ilm-policy",
11-
"index.lifecycle.rollover_alias": ".slm-history-${xpack.slm.template.version}",
12-
"index.hidden": true,
13-
"index.format": 1
14-
},
15-
"mappings": {
16-
"_doc": {
5+
"priority": 2147483647,
6+
"template": {
7+
"settings": {
8+
"index.number_of_shards": 1,
9+
"index.number_of_replicas": 0,
10+
"index.auto_expand_replicas": "0-1",
11+
"index.lifecycle.name": "slm-history-ilm-policy",
12+
"index.lifecycle.rollover_alias": ".slm-history-${xpack.slm.template.version}",
13+
"index.hidden": true,
14+
"index.format": 1
15+
},
16+
"mappings": {
1717
"dynamic": false,
1818
"properties": {
1919
"@timestamp": {
@@ -26,7 +26,7 @@
2626
"repository": {
2727
"type": "keyword"
2828
},
29-
"snapshot_name":{
29+
"snapshot_name": {
3030
"type": "keyword"
3131
},
3232
"operation": {
@@ -57,5 +57,9 @@
5757
}
5858
}
5959
},
60+
"_meta": {
61+
"description": "index template for SLM history indices",
62+
"managed": true
63+
},
6064
"version": ${xpack.slm.template.version}
6165
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"index_patterns": [ ".triggered_watches*" ],
3+
"order": 2147483647,
4+
"settings": {
5+
"index.number_of_shards": 1,
6+
"index.auto_expand_replicas": "0-1",
7+
"index.refresh_interval" : "-1",
8+
"index.format": 6,
9+
"index.priority": 900
10+
},
11+
"mappings": {
12+
"_doc": {
13+
"dynamic" : "strict",
14+
"properties": {
15+
"trigger_event": {
16+
"type": "object",
17+
"dynamic": true,
18+
"enabled" : false,
19+
"properties": {
20+
"schedule": {
21+
"type": "object",
22+
"dynamic": true,
23+
"properties": {
24+
"triggered_time": {
25+
"type": "date"
26+
},
27+
"scheduled_time": {
28+
"type": "date"
29+
}
30+
}
31+
}
32+
}
33+
},
34+
"state": {
35+
"type": "keyword"
36+
}
37+
}
38+
}
39+
},
40+
"version": 11
41+
}

x-pack/plugin/core/src/main/resources/triggered-watches.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"index_patterns": [ ".triggered_watches*" ],
3-
"order": 2147483647,
4-
"settings": {
5-
"index.number_of_shards": 1,
6-
"index.auto_expand_replicas": "0-1",
7-
"index.refresh_interval" : "-1",
8-
"index.format": 6,
9-
"index.priority": 900
10-
},
11-
"mappings": {
12-
"_doc": {
13-
"dynamic" : "strict",
3+
"priority": 2147483647,
4+
"template": {
5+
"settings": {
6+
"index.number_of_shards": 1,
7+
"index.auto_expand_replicas": "0-1",
8+
"index.refresh_interval": "-1",
9+
"index.format": 6,
10+
"index.priority": 900
11+
},
12+
"mappings": {
13+
"dynamic": "strict",
1414
"properties": {
1515
"trigger_event": {
1616
"type": "object",
1717
"dynamic": true,
18-
"enabled" : false,
18+
"enabled": false,
1919
"properties": {
2020
"schedule": {
2121
"type": "object",
@@ -37,5 +37,9 @@
3737
}
3838
}
3939
},
40+
"_meta": {
41+
"description": "index template for triggered watches indices",
42+
"managed": true
43+
},
4044
"version": ${xpack.watcher.template.version}
4145
}

0 commit comments

Comments
 (0)