@@ -47,7 +47,7 @@ def self.run(client)
47
47
clear_sml_policies ( client )
48
48
wipe_searchable_snapshot_indices ( client )
49
49
end
50
- clear_snapshots_and_repositories ( client )
50
+ wipe_snapshots ( client )
51
51
wipe_datastreams ( client )
52
52
wipe_all_indices ( client )
53
53
if platinum?
@@ -257,22 +257,18 @@ def clear_index_templates(client)
257
257
end
258
258
end
259
259
260
- def clear_snapshots_and_repositories ( client )
260
+ def wipe_snapshots ( client )
261
261
return unless ( repositories = client . snapshot . get_repository ( repository : '_all' ) )
262
262
263
263
repositories . each_key do |repository |
264
- client . snapshot . delete ( repository : repository , snapshot : '*' , ignore : 404 ) if repositories [ repository ] [ 'type' ] == 'fs'
265
- begin
266
- response = client . perform_request ( 'DELETE' , "_snapshot/#{ repository } " , ignore : [ 500 , 404 ] )
267
- client . snapshot . delete_repository ( repository : repository , ignore : 404 )
268
- rescue Elastic ::Transport ::Transport ::Errors ::InternalServerError => e
269
- regexp = /indices that use the repository: \[ docs\/ ([a-zA-Z0-9]+)/
270
- raise e unless response . body [ 'error' ] [ 'root_cause' ] . first [ 'reason' ] . match ( regexp )
271
-
272
- # Try again after clearing indices if we get a 500 error from delete repository
273
- wipe_all_indices ( client )
274
- client . snapshot . delete_repository ( repository : repository , ignore : 404 )
264
+ if repositories [ repository ] [ 'type' ] == 'fs'
265
+ response = client . snapshot . get ( repository : repository , snapshot : '_all' , ignore_unavailable : true )
266
+ # response ={"snapshots"=>[], "total"=>0, "remaining"=>0}
267
+ response [ 'snapshots' ] . each do |snapshot |
268
+ client . snapshot . delete ( repository : repository , snapshot : snapshot [ 'snapshot' ] , ignore : 404 )
269
+ end
275
270
end
271
+ client . snapshot . delete_repository ( repository : repository , ignore : 404 )
276
272
end
277
273
end
278
274
@@ -304,6 +300,7 @@ def clear_ml_filters(client)
304
300
305
301
def wipe_all_indices ( client )
306
302
client . indices . delete ( index : '*,-.ds-ilm-history-*' , expand_wildcards : 'open,closed,hidden' , ignore : 404 )
303
+ client . indices . refresh ( expand_wildcards : 'open,hidden' )
307
304
end
308
305
309
306
def wipe_searchable_snapshot_indices ( client )
0 commit comments