Skip to content

Commit afffce4

Browse files
committed
[CI] Fixes issue with deleting repository
1 parent e028173 commit afffce4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

elasticsearch-api/api-spec-testing/test_file.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,17 @@ def clear_snapshots_and_repositories(client)
398398

399399
repositories.each_key do |repository|
400400
client.snapshot.delete(repository: repository, snapshot: '*', ignore: 404) if repositories[repository]['type'] == 'fs'
401-
client.snapshot.delete_repository(repository: repository, ignore: 404)
401+
begin
402+
response = client.perform_request('DELETE', "_snapshot/#{repository}", ignore: [500, 404])
403+
client.snapshot.delete_repository(repository: repository, ignore: 404)
404+
rescue Elasticsearch::Transport::Transport::Errors::InternalServerError => e
405+
regexp = /indices that use the repository: \[docs\/([a-zA-Z0-9]+)/
406+
raise e unless response.body['error']['root_cause'].first['reason'].match(regexp)
407+
408+
# Try again after clearing indices if we get a 500 error from delete repository
409+
clear_indices(client)
410+
client.snapshot.delete_repository(repository: repository, ignore: 404)
411+
end
402412
end
403413
end
404414

0 commit comments

Comments
 (0)