Skip to content

Commit

Permalink
Added check to prevent resource_already_exists_exception when indexin…
Browse files Browse the repository at this point in the history
…g more than 10k iocs.

Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt committed Oct 25, 2024
1 parent 3d1fcd5 commit ef9edf8
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchException;
import org.opensearch.ResourceAlreadyExistsException;
import org.opensearch.action.DocWriteRequest;
import org.opensearch.action.StepListener;
import org.opensearch.action.admin.indices.create.CreateIndexRequest;
Expand All @@ -35,6 +36,7 @@
import org.opensearch.securityanalytics.threatIntel.common.StashedThreadContext;
import org.opensearch.securityanalytics.threatIntel.model.DefaultIocStoreConfig;
import org.opensearch.securityanalytics.threatIntel.model.SATIFSourceConfig;
import org.opensearch.transport.RemoteTransportException;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -250,6 +252,11 @@ private void initFeedIndex(String feedIndexName, ActionListener<CreateIndexRespo
listener.onResponse(r);
},
e -> {
if (e instanceof ResourceAlreadyExistsException || (e instanceof RemoteTransportException && e.getCause() instanceof ResourceAlreadyExistsException)) {
log.debug("index {} already exist", iocIndexMapping());
listener.onResponse(null);
return;
}
log.error("Failed to create system index {}", feedIndexName);
listener.onFailure(e);
}
Expand Down

0 comments on commit ef9edf8

Please sign in to comment.