just issue a warning when trying to delete an index which is not found

This commit is contained in:
Jörg Prante 2023-08-25 10:52:10 +02:00
parent f3a386076e
commit 68a35ea86f
2 changed files with 11 additions and 6 deletions

View file

@ -49,6 +49,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHit;
@ -163,12 +164,16 @@ public abstract class AbstractAdminClient extends AbstractBasicClient implements
return; return;
} }
ensureClientIsPresent(); ensureClientIsPresent();
try {
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest().indices(indexName); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest().indices(indexName);
AcknowledgedResponse acknowledgedResponse = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet(); AcknowledgedResponse acknowledgedResponse = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet();
if (acknowledgedResponse.isAcknowledged()) { if (acknowledgedResponse.isAcknowledged()) {
logger.info("index " + indexName + " deleted"); logger.info("index " + indexName + " deleted");
} }
waitForHealthyCluster(); waitForHealthyCluster();
} catch (IndexNotFoundException e) {
logger.log(Level.WARNING, "index " + indexName + " not found, skipping deletion");
}
} }
@Override @Override

View file

@ -1,5 +1,5 @@
group = org.xbib group = org.xbib
name = elx name = elx
version = 7.10.2.30 version = 7.10.2.31
org.gradle.warning.mode = ALL org.gradle.warning.mode = ALL