@@ -73,13 +73,6 @@ def wipe_cluster(client, elasticsearch_api_key):
73
73
wipe_data_streams (client )
74
74
wipe_indices (client )
75
75
76
- if is_xpack :
77
- wipe_xpack_templates (client )
78
- else :
79
- client .indices .delete_template (name = "*" )
80
- client .indices .delete_index_template (name = "*" )
81
- client .cluster .delete_component_template (name = "*" )
82
-
83
76
if is_xpack :
84
77
wipe_transforms (client )
85
78
@@ -104,29 +97,6 @@ def wipe_indices(client):
104
97
)
105
98
106
99
107
- def wipe_xpack_templates (client ):
108
- # Delete component templates, need to retry because sometimes
109
- # indices aren't cleaned up in time before we issue the delete.
110
- templates = client .cluster .get_component_template ()["component_templates" ]
111
- templates_to_delete = [
112
- template for template in templates if not is_xpack_template (template ["name" ])
113
- ]
114
- for _ in range (3 ):
115
- for template in list (templates_to_delete ):
116
- try :
117
- client .cluster .delete_component_template (
118
- name = template ["name" ],
119
- )
120
- except RequestError :
121
- pass
122
- else :
123
- templates_to_delete .remove (template )
124
-
125
- if not templates_to_delete :
126
- break
127
- time .sleep (0.01 )
128
-
129
-
130
100
def wipe_transforms (client : Elasticsearch , timeout = 30 ):
131
101
end_time = time .time () + timeout
132
102
while time .time () < end_time :
@@ -142,44 +112,6 @@ def wipe_transforms(client: Elasticsearch, timeout=30):
142
112
)
143
113
144
114
145
- def is_xpack_template (name ):
146
- if name .startswith (".monitoring-" ):
147
- return True
148
- elif name .startswith (".watch" ) or name .startswith (".triggered_watches" ):
149
- return True
150
- elif name .startswith (".data-frame-" ):
151
- return True
152
- elif name .startswith (".ml-" ):
153
- return True
154
- elif name .startswith (".transform-" ):
155
- return True
156
- elif name .startswith (".deprecation-" ):
157
- return True
158
- if name in {
159
- ".watches" ,
160
- "security_audit_log" ,
161
- ".slm-history" ,
162
- ".async-search" ,
163
- "saml-service-provider" ,
164
- "logs" ,
165
- "logs-settings" ,
166
- "logs-mappings" ,
167
- "metrics" ,
168
- "metrics-settings" ,
169
- "metrics-mappings" ,
170
- "synthetics" ,
171
- "synthetics-settings" ,
172
- "synthetics-mappings" ,
173
- ".snapshot-blob-cache" ,
174
- "ilm-history" ,
175
- "logstash-index-template" ,
176
- "security-index-template" ,
177
- "data-streams-mappings" ,
178
- }:
179
- return True
180
- return False
181
-
182
-
183
115
def es_api_key () -> str :
184
116
"""
185
117
Gets Elasticsearch API key ID and secret from environment variables, raises ValueError if none found
0 commit comments