Skip to content

Commit

Permalink
[Bug] Add exists check for IOCs index. (#1392) (#1396)
Browse files Browse the repository at this point in the history
* Added check to prevent resource_already_exists_exception when indexing more than 10k iocs.



* Changed log message.



---------


(cherry picked from commit 4432b36)

Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 2b7d37d commit 4a7d588
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 @@ -34,6 +35,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 @@ -241,6 +243,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", feedIndexName);
listener.onResponse(null);
return;
}
log.error("Failed to create system index {}", feedIndexName);
listener.onFailure(e);
}
Expand Down

0 comments on commit 4a7d588

Please sign in to comment.