Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [Bug] Add exists check for IOCs index. #1394

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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;

Check warning on line 258 in src/main/java/org/opensearch/securityanalytics/services/STIX2IOCFeedStore.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/services/STIX2IOCFeedStore.java#L256-L258

Added lines #L256 - L258 were not covered by tests
}
log.error("Failed to create system index {}", feedIndexName);
listener.onFailure(e);
}
Expand Down
Loading