Skip to content

Commit 0aefad9

Browse files
authored
Remove direct reference to Job-Scheduler Lock Index in SAP repo (#1577)
* Remove direct reference to Job-Scheduler Lock Index in SAP repo Signed-off-by: Craig Perkins <[email protected]> * Exclude error_prone_annotations from locally checked in shadow jar for commons Signed-off-by: Craig Perkins <[email protected]> * Include apache httpcomponents Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]>
1 parent 00362f1 commit 0aefad9

File tree

4 files changed

+5
-57
lines changed

4 files changed

+5
-57
lines changed
-15.5 KB
Binary file not shown.

src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -724,19 +724,12 @@ private void deleteAllIocsAndSourceConfig(ActionListener<DeleteResponse> listene
724724
saTifSourceConfigService.deleteAllIocIndices(concreteIndices, false, ActionListener.wrap(
725725
r -> {
726726
log.debug("Successfully deleted all ioc indices");
727-
saTifSourceConfigService.deleteJobSchedulerLockIfJobDisabled(updateSaTifSourceConfigResponse, ActionListener.wrap(
728-
deleteLockResponse -> {
729-
saTifSourceConfigService.deleteTIFSourceConfig(updateSaTifSourceConfigResponse, ActionListener.wrap(
730-
deleteResponse -> {
731-
log.debug("Successfully deleted threat intel source config [{}]", updateSaTifSourceConfigResponse.getId());
732-
listener.onResponse(deleteResponse);
733-
}, e -> {
734-
log.error("Failed to delete threat intel source config [{}]", saTifSourceConfig.getId());
735-
listener.onFailure(e);
736-
}
737-
));
727+
saTifSourceConfigService.deleteTIFSourceConfig(updateSaTifSourceConfigResponse, ActionListener.wrap(
728+
deleteResponse -> {
729+
log.debug("Successfully deleted threat intel source config [{}]", updateSaTifSourceConfigResponse.getId());
730+
listener.onResponse(deleteResponse);
738731
}, e -> {
739-
log.error("Failed to delete threat intel job scheduler lock [{}]", saTifSourceConfig.getId());
732+
log.error("Failed to delete threat intel source config [{}]", saTifSourceConfig.getId());
740733
listener.onFailure(e);
741734
}
742735
));

src/main/java/org/opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigService.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import java.util.Set;
7272
import java.util.stream.Collectors;
7373

74-
import static org.opensearch.jobscheduler.spi.utils.LockService.LOCK_INDEX_NAME;
7574
import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.INDEX_TIMEOUT;
7675
import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.AVAILABLE;
7776
import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.REFRESHING;
@@ -419,45 +418,6 @@ public void deleteTIFSourceConfig(
419418
));
420419
}
421420

422-
// Manually delete threat intel job scheduler lock if job is disabled
423-
public void deleteJobSchedulerLockIfJobDisabled(
424-
SATIFSourceConfig saTifSourceConfig,
425-
final ActionListener<DeleteResponse> actionListener
426-
) {
427-
if (saTifSourceConfig.isEnabled()) {
428-
actionListener.onResponse(null);
429-
return;
430-
}
431-
432-
// check to make sure the job scheduler lock index exists
433-
if (clusterService.state().metadata().hasIndex(LOCK_INDEX_NAME) == false) {
434-
actionListener.onResponse(null);
435-
return;
436-
}
437-
438-
String id = SecurityAnalyticsPlugin.JOB_INDEX_NAME + "-" + saTifSourceConfig.getId();
439-
DeleteRequest request = new DeleteRequest(LOCK_INDEX_NAME, id)
440-
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
441-
.timeout(clusterSettings.get(INDEX_TIMEOUT));
442-
443-
client.delete(request, ActionListener.wrap(
444-
deleteResponse -> {
445-
if (deleteResponse.status().equals(RestStatus.OK)) {
446-
log.info("Deleted threat intel job scheduler lock [{}] successfully", id);
447-
actionListener.onResponse(deleteResponse);
448-
} else if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) {
449-
log.info("Threat intel job scheduler lock with id [{}] not found", id);
450-
actionListener.onResponse(deleteResponse);
451-
} else {
452-
actionListener.onFailure(SecurityAnalyticsException.wrap(new OpenSearchStatusException(String.format(Locale.ROOT, "Failed to delete threat intel job scheduler lock with id [{%s}]", id), deleteResponse.status())));
453-
}
454-
}, e -> {
455-
log.error("Failed to delete threat intel job scheduler lock with id [{}]", id);
456-
actionListener.onFailure(e);
457-
}
458-
));
459-
}
460-
461421
public void deleteAllIocIndices(Set<String> indicesToDelete, Boolean backgroundJob, ActionListener<AcknowledgedResponse> listener) {
462422
if (indicesToDelete.isEmpty() == false) {
463423
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indicesToDelete.toArray(new String[0]));

src/test/java/org/opensearch/securityanalytics/resthandler/SourceConfigWithoutS3RestApiIT.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import java.util.Locale;
4343
import java.util.Map;
4444

45-
import static org.opensearch.jobscheduler.spi.utils.LockService.LOCK_INDEX_NAME;
4645
import static org.opensearch.securityanalytics.SecurityAnalyticsPlugin.JOB_INDEX_NAME;
4746
import static org.opensearch.securityanalytics.TestHelpers.oldThreatIntelJobMapping;
4847
import static org.opensearch.securityanalytics.services.STIX2IOCFeedStore.IOC_ALL_INDEX_PATTERN;
@@ -732,10 +731,6 @@ public void testDeleteIocUploadSourceConfigAndAllIocs() throws IOException {
732731
// ensure all iocs are deleted
733732
hits = executeSearch(IOC_ALL_INDEX_PATTERN, request);
734733
Assert.assertEquals(0, hits.size());
735-
736-
// ensure that lock is deleted
737-
hits = executeSearch(LOCK_INDEX_NAME,request);
738-
Assert.assertEquals(0, hits.size());
739734
}
740735

741736
public void testRefreshIocUploadSourceConfigFailure() throws IOException {

0 commit comments

Comments
 (0)