Skip to content

Commit 3b79d1d

Browse files
authored
Move internal index templates to composable templates (#61457)
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 dc7153c commit 3b79d1d

File tree

14 files changed

+611
-574
lines changed

14 files changed

+611
-574
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ 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 String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
2223
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
2324
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";

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

Lines changed: 75 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,85 @@
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+
},
12+
"mappings": {
13+
"dynamic": false,
14+
"properties": {
15+
"@timestamp": {
16+
"type": "date",
17+
"format": "epoch_millis"
18+
},
19+
"policy": {
20+
"type": "keyword"
21+
},
22+
"index": {
23+
"type": "keyword"
24+
},
25+
"index_age": {
26+
"type": "long"
27+
},
28+
"success": {
29+
"type": "boolean"
30+
},
31+
"state": {
32+
"type": "object",
33+
"dynamic": true,
34+
"properties": {
35+
"phase": {
36+
"type": "keyword"
37+
},
38+
"action": {
39+
"type": "keyword"
40+
},
41+
"step": {
42+
"type": "keyword"
43+
},
44+
"failed_step": {
45+
"type": "keyword"
46+
},
47+
"is_auto-retryable_error": {
48+
"type": "keyword"
49+
},
50+
"creation_date": {
51+
"type": "date",
52+
"format": "epoch_millis"
53+
},
54+
"phase_time": {
55+
"type": "date",
56+
"format": "epoch_millis"
57+
},
58+
"action_time": {
59+
"type": "date",
60+
"format": "epoch_millis"
61+
},
62+
"step_time": {
63+
"type": "date",
64+
"format": "epoch_millis"
65+
},
66+
"phase_definition": {
67+
"type": "text"
68+
},
69+
"step_info": {
70+
"type": "text"
71+
}
7572
}
73+
},
74+
"error_details": {
75+
"type": "text"
7676
}
77-
},
78-
"error_details": {
79-
"type": "text"
8077
}
8178
}
82-
}
8379
},
80+
"_meta": {
81+
"description": "index template for ILM history indices",
82+
"managed": true
83+
},
84+
"priority": 2147483647,
8485
"version": ${xpack.ilm_history.template.version}
8586
}

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
}

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)