diff --git a/security-analytics-commons-1.0.0.jar b/security-analytics-commons-1.0.0.jar index ea60e71e4..d82c59537 100644 Binary files a/security-analytics-commons-1.0.0.jar and b/security-analytics-commons-1.0.0.jar differ diff --git a/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java b/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java index 7ef2f353a..5903ec9d9 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java +++ b/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java @@ -724,19 +724,12 @@ private void deleteAllIocsAndSourceConfig(ActionListener listene saTifSourceConfigService.deleteAllIocIndices(concreteIndices, false, ActionListener.wrap( r -> { log.debug("Successfully deleted all ioc indices"); - saTifSourceConfigService.deleteJobSchedulerLockIfJobDisabled(updateSaTifSourceConfigResponse, ActionListener.wrap( - deleteLockResponse -> { - saTifSourceConfigService.deleteTIFSourceConfig(updateSaTifSourceConfigResponse, ActionListener.wrap( - deleteResponse -> { - log.debug("Successfully deleted threat intel source config [{}]", updateSaTifSourceConfigResponse.getId()); - listener.onResponse(deleteResponse); - }, e -> { - log.error("Failed to delete threat intel source config [{}]", saTifSourceConfig.getId()); - listener.onFailure(e); - } - )); + saTifSourceConfigService.deleteTIFSourceConfig(updateSaTifSourceConfigResponse, ActionListener.wrap( + deleteResponse -> { + log.debug("Successfully deleted threat intel source config [{}]", updateSaTifSourceConfigResponse.getId()); + listener.onResponse(deleteResponse); }, e -> { - log.error("Failed to delete threat intel job scheduler lock [{}]", saTifSourceConfig.getId()); + log.error("Failed to delete threat intel source config [{}]", saTifSourceConfig.getId()); listener.onFailure(e); } )); diff --git a/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigService.java b/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigService.java index 4d6a8944c..8240c62c4 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigService.java +++ b/src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigService.java @@ -71,7 +71,6 @@ import java.util.Set; import java.util.stream.Collectors; -import static org.opensearch.jobscheduler.spi.utils.LockService.LOCK_INDEX_NAME; import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.INDEX_TIMEOUT; import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.AVAILABLE; import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.REFRESHING; @@ -419,45 +418,6 @@ public void deleteTIFSourceConfig( )); } - // Manually delete threat intel job scheduler lock if job is disabled - public void deleteJobSchedulerLockIfJobDisabled( - SATIFSourceConfig saTifSourceConfig, - final ActionListener actionListener - ) { - if (saTifSourceConfig.isEnabled()) { - actionListener.onResponse(null); - return; - } - - // check to make sure the job scheduler lock index exists - if (clusterService.state().metadata().hasIndex(LOCK_INDEX_NAME) == false) { - actionListener.onResponse(null); - return; - } - - String id = SecurityAnalyticsPlugin.JOB_INDEX_NAME + "-" + saTifSourceConfig.getId(); - DeleteRequest request = new DeleteRequest(LOCK_INDEX_NAME, id) - .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) - .timeout(clusterSettings.get(INDEX_TIMEOUT)); - - client.delete(request, ActionListener.wrap( - deleteResponse -> { - if (deleteResponse.status().equals(RestStatus.OK)) { - log.info("Deleted threat intel job scheduler lock [{}] successfully", id); - actionListener.onResponse(deleteResponse); - } else if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) { - log.info("Threat intel job scheduler lock with id [{}] not found", id); - actionListener.onResponse(deleteResponse); - } else { - actionListener.onFailure(SecurityAnalyticsException.wrap(new OpenSearchStatusException(String.format(Locale.ROOT, "Failed to delete threat intel job scheduler lock with id [{%s}]", id), deleteResponse.status()))); - } - }, e -> { - log.error("Failed to delete threat intel job scheduler lock with id [{}]", id); - actionListener.onFailure(e); - } - )); - } - public void deleteAllIocIndices(Set indicesToDelete, Boolean backgroundJob, ActionListener listener) { if (indicesToDelete.isEmpty() == false) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indicesToDelete.toArray(new String[0])); diff --git a/src/test/java/org/opensearch/securityanalytics/resthandler/SourceConfigWithoutS3RestApiIT.java b/src/test/java/org/opensearch/securityanalytics/resthandler/SourceConfigWithoutS3RestApiIT.java index e642b29cb..2805e4313 100644 --- a/src/test/java/org/opensearch/securityanalytics/resthandler/SourceConfigWithoutS3RestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/resthandler/SourceConfigWithoutS3RestApiIT.java @@ -42,7 +42,6 @@ import java.util.Locale; import java.util.Map; -import static org.opensearch.jobscheduler.spi.utils.LockService.LOCK_INDEX_NAME; import static org.opensearch.securityanalytics.SecurityAnalyticsPlugin.JOB_INDEX_NAME; import static org.opensearch.securityanalytics.TestHelpers.oldThreatIntelJobMapping; import static org.opensearch.securityanalytics.services.STIX2IOCFeedStore.IOC_ALL_INDEX_PATTERN; @@ -732,10 +731,6 @@ public void testDeleteIocUploadSourceConfigAndAllIocs() throws IOException { // ensure all iocs are deleted hits = executeSearch(IOC_ALL_INDEX_PATTERN, request); Assert.assertEquals(0, hits.size()); - - // ensure that lock is deleted - hits = executeSearch(LOCK_INDEX_NAME,request); - Assert.assertEquals(0, hits.size()); } public void testRefreshIocUploadSourceConfigFailure() throws IOException {