diff --git a/alerting/build.gradle b/alerting/build.gradle index bb44c8e62..5a53f45d7 100644 --- a/alerting/build.gradle +++ b/alerting/build.gradle @@ -102,7 +102,12 @@ configurations.all { resolutionStrategy { force "joda-time:joda-time:${versions.joda}" force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" + force "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}" + force "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson_annotations}" force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}" + force "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}" + force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}" + force "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}" force "commons-logging:commons-logging:${versions.commonslogging}" // force the version until OpenSearch upgrade to an invulnerable one, https://www.whitesourcesoftware.com/vulnerability-database/WS-2019-0379 force "commons-codec:commons-codec:1.13" diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeAlertAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeAlertAction.kt index 6cc60732a..ae6581824 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeAlertAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeAlertAction.kt @@ -45,6 +45,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.rest.RestRequest import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.search.fetch.subphase.FetchSourceContext @@ -64,7 +65,8 @@ class TransportAcknowledgeAlertAction @Inject constructor( actionFilters: ActionFilters, val settings: Settings, val xContentRegistry: NamedXContentRegistry, - val transportGetMonitorAction: TransportGetMonitorAction + val transportGetMonitorAction: TransportGetMonitorAction, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.ACKNOWLEDGE_ALERTS_ACTION_NAME, transportService, actionFilters, ::AcknowledgeAlertRequest ) { diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeChainedAlertAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeChainedAlertAction.kt index 1d94cc2f8..1752de0df 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeChainedAlertAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportAcknowledgeChainedAlertAction.kt @@ -52,6 +52,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task import org.opensearch.transport.TransportService @@ -69,6 +70,7 @@ class TransportAcknowledgeChainedAlertAction @Inject constructor( actionFilters: ActionFilters, val settings: Settings, val xContentRegistry: NamedXContentRegistry, + val sdkClient: SdkClient, ) : HandledTransportAction( AlertingActions.ACKNOWLEDGE_CHAINED_ALERTS_ACTION_NAME, transportService, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteAlertingCommentAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteAlertingCommentAction.kt index 09f8d2e00..fbf3ac423 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteAlertingCommentAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteAlertingCommentAction.kt @@ -38,6 +38,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task import org.opensearch.transport.TransportService @@ -52,7 +53,8 @@ class TransportDeleteAlertingCommentAction @Inject constructor( actionFilters: ActionFilters, val clusterService: ClusterService, settings: Settings, - val xContentRegistry: NamedXContentRegistry + val xContentRegistry: NamedXContentRegistry, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.DELETE_COMMENT_ACTION_NAME, transportService, actionFilters, ::DeleteCommentRequest ), diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteMonitorAction.kt index b28311bd0..464992cfe 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportDeleteMonitorAction.kt @@ -36,6 +36,7 @@ import org.opensearch.commons.utils.recreateObject import org.opensearch.core.action.ActionListener import org.opensearch.core.rest.RestStatus import org.opensearch.core.xcontent.NamedXContentRegistry +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.tasks.Task import org.opensearch.transport.TransportService import org.opensearch.transport.client.Client @@ -49,7 +50,8 @@ class TransportDeleteMonitorAction @Inject constructor( actionFilters: ActionFilters, val clusterService: ClusterService, settings: Settings, - val xContentRegistry: NamedXContentRegistry + val xContentRegistry: NamedXContentRegistry, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.DELETE_MONITOR_ACTION_NAME, transportService, actionFilters, ::DeleteMonitorRequest ), diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt index f2769ad70..27c55b3db 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt @@ -39,6 +39,7 @@ import org.opensearch.commons.authuser.User import org.opensearch.core.action.ActionListener import org.opensearch.core.rest.RestStatus import org.opensearch.core.xcontent.NamedXContentRegistry +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.tasks.Task import org.opensearch.transport.TransportService import org.opensearch.transport.client.Client @@ -56,7 +57,8 @@ class TransportExecuteMonitorAction @Inject constructor( actionFilters: ActionFilters, val xContentRegistry: NamedXContentRegistry, private val docLevelMonitorQueries: DocLevelMonitorQueries, - private val settings: Settings + private val settings: Settings, + private val sdkClient: SdkClient ) : HandledTransportAction ( ExecuteMonitorAction.NAME, transportService, actionFilters, ::ExecuteMonitorRequest ) { diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt index 1fc3ef83a..6b37ba9a4 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt @@ -44,6 +44,7 @@ import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.BoolQueryBuilder import org.opensearch.index.query.Operator import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.search.sort.SortBuilders import org.opensearch.search.sort.SortOrder @@ -62,7 +63,8 @@ class TransportGetAlertsAction @Inject constructor( actionFilters: ActionFilters, val settings: Settings, val xContentRegistry: NamedXContentRegistry, - val namedWriteableRegistry: NamedWriteableRegistry + val namedWriteableRegistry: NamedWriteableRegistry, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.GET_ALERTS_ACTION_NAME, transportService, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetDestinationsAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetDestinationsAction.kt index 60e5edb9d..df3c12ce4 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetDestinationsAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetDestinationsAction.kt @@ -33,6 +33,7 @@ import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.Operator import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.search.fetch.subphase.FetchSourceContext import org.opensearch.search.sort.SortBuilders @@ -50,7 +51,8 @@ class TransportGetDestinationsAction @Inject constructor( clusterService: ClusterService, actionFilters: ActionFilters, val settings: Settings, - val xContentRegistry: NamedXContentRegistry + val xContentRegistry: NamedXContentRegistry, + val sdkClient: SdkClient ) : HandledTransportAction ( GetDestinationsAction.NAME, transportService, actionFilters, ::GetDestinationsRequest ), diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetMonitorAction.kt index 97e65ec50..aabf0d2af 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetMonitorAction.kt @@ -43,6 +43,7 @@ import org.opensearch.core.rest.RestStatus import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.index.IndexNotFoundException import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task import org.opensearch.transport.RemoteTransportException @@ -59,6 +60,7 @@ class TransportGetMonitorAction @Inject constructor( val xContentRegistry: NamedXContentRegistry, val clusterService: ClusterService, settings: Settings, + val sdkClient: SdkClient, ) : HandledTransportAction( AlertingActions.GET_MONITOR_ACTION_NAME, transportService, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetWorkflowAlertsAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetWorkflowAlertsAction.kt index dd26bf032..8d8d9f917 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetWorkflowAlertsAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetWorkflowAlertsAction.kt @@ -40,6 +40,7 @@ import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.Operator import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.search.sort.SortBuilders import org.opensearch.search.sort.SortOrder @@ -58,6 +59,7 @@ class TransportGetWorkflowAlertsAction @Inject constructor( actionFilters: ActionFilters, val settings: Settings, val xContentRegistry: NamedXContentRegistry, + val sdkClient: SdkClient, ) : HandledTransportAction( AlertingActions.GET_WORKFLOW_ALERTS_ACTION_NAME, transportService, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexAlertingCommentAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexAlertingCommentAction.kt index 8592c505c..367e118bb 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexAlertingCommentAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexAlertingCommentAction.kt @@ -50,6 +50,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.rest.RestRequest import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task @@ -72,6 +73,7 @@ constructor( val settings: Settings, val xContentRegistry: NamedXContentRegistry, val namedWriteableRegistry: NamedWriteableRegistry, + val sdkClient: SdkClient, ) : HandledTransportAction( AlertingActions.INDEX_COMMENT_ACTION_NAME, transportService, diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexMonitorAction.kt index bbce5b2ac..9d914d676 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportIndexMonitorAction.kt @@ -79,6 +79,7 @@ import org.opensearch.index.query.QueryBuilders import org.opensearch.index.reindex.BulkByScrollResponse import org.opensearch.index.reindex.DeleteByQueryAction import org.opensearch.index.reindex.DeleteByQueryRequestBuilder +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.rest.RestRequest import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task @@ -101,6 +102,7 @@ class TransportIndexMonitorAction @Inject constructor( val settings: Settings, val xContentRegistry: NamedXContentRegistry, val namedWriteableRegistry: NamedWriteableRegistry, + val sdkClient: SdkClient, ) : HandledTransportAction( AlertingActions.INDEX_MONITOR_ACTION_NAME, transportService, actionFilters, ::IndexMonitorRequest ), diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchAlertingCommentAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchAlertingCommentAction.kt index 9e8c3d153..fd30e9bf4 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchAlertingCommentAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchAlertingCommentAction.kt @@ -40,6 +40,7 @@ import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.index.query.BoolQueryBuilder import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.builder.SearchSourceBuilder import org.opensearch.tasks.Task import org.opensearch.transport.TransportService @@ -55,7 +56,8 @@ class TransportSearchAlertingCommentAction @Inject constructor( val client: Client, clusterService: ClusterService, actionFilters: ActionFilters, - val namedWriteableRegistry: NamedWriteableRegistry + val namedWriteableRegistry: NamedWriteableRegistry, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.SEARCH_COMMENTS_ACTION_NAME, transportService, actionFilters, ::SearchRequest ), diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchMonitorAction.kt index 21c633553..307f9eb7e 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportSearchMonitorAction.kt @@ -36,6 +36,7 @@ import org.opensearch.index.query.BoolQueryBuilder import org.opensearch.index.query.ExistsQueryBuilder import org.opensearch.index.query.MatchQueryBuilder import org.opensearch.index.query.QueryBuilders +import org.opensearch.remote.metadata.client.SdkClient import org.opensearch.search.SearchHits import org.opensearch.search.aggregations.InternalAggregations import org.opensearch.search.internal.InternalSearchResponse @@ -55,7 +56,8 @@ class TransportSearchMonitorAction @Inject constructor( val client: Client, clusterService: ClusterService, actionFilters: ActionFilters, - val namedWriteableRegistry: NamedWriteableRegistry + val namedWriteableRegistry: NamedWriteableRegistry, + val sdkClient: SdkClient ) : HandledTransportAction( AlertingActions.SEARCH_MONITORS_ACTION_NAME, transportService, actionFilters, ::SearchMonitorRequest ), diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorTests.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorTests.kt index f6ed78541..64f007a91 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorTests.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorTests.kt @@ -31,17 +31,18 @@ class MonitorTests : OpenSearchTestCase() { } fun `test max triggers`() { + // Monitor no longer validates trigger count at construction time. + // Trigger count validation is now handled at the transport action level + // via the configurable MAX_TRIGGERS_PER_MONITOR setting. val monitor = randomQueryLevelMonitor() - val tooManyTriggers = mutableListOf() + val manyTriggers = mutableListOf() for (i in 0..10) { - tooManyTriggers.add(randomQueryLevelTrigger()) + manyTriggers.add(randomQueryLevelTrigger()) } - try { - monitor.copy(triggers = tooManyTriggers) - fail("Monitor with too many triggers should be rejected.") - } catch (e: IllegalArgumentException) { - } + // Should not throw — validation moved to transport layer + val monitorWithManyTriggers = monitor.copy(triggers = manyTriggers) + assertEquals(11, monitorWithManyTriggers.triggers.size) } } diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/util/IndexUtilsTests.kt b/alerting/src/test/kotlin/org/opensearch/alerting/util/IndexUtilsTests.kt index 03f03abeb..a800a40d9 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/util/IndexUtilsTests.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/util/IndexUtilsTests.kt @@ -53,7 +53,7 @@ class IndexUtilsTests : OpenSearchTestCase() { fun `test should update index without original version`() { val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," + "\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," + - "\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," + + "\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," + "\"settings_version\":123,\"aliases_version\":1,\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}}" val newMapping = "{\"_meta\":{\"schema_version\":10},\"properties\":{\"name\":{\"type\":\"keyword\"}}}" val index: IndexMetadata = IndexMetadata.fromXContent(parser(indexContent)) @@ -65,7 +65,7 @@ class IndexUtilsTests : OpenSearchTestCase() { fun `test should update index with lagged version`() { val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," + "\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," + - "\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," + + "\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," + "\"settings_version\":123,\"aliases_version\":1,\"mappings\":{\"_doc\":{\"_meta\":{\"schema_version\":1},\"properties\":" + "{\"name\":{\"type\":\"keyword\"}}}}}}" val newMapping = "{\"_meta\":{\"schema_version\":10},\"properties\":{\"name\":{\"type\":\"keyword\"}}}" @@ -78,7 +78,7 @@ class IndexUtilsTests : OpenSearchTestCase() { fun `test should update index with same version`() { val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," + "\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," + - "\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":\"1\"," + + "\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":\"1\"," + "\"settings_version\":\"1\",\"aliases_version\":\"1\",\"mappings\":" + "{\"_doc\":{\"_meta\":{\"schema_version\":1},\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}}" val newMapping = "{\"_meta\":{\"schema_version\":1},\"properties\":{\"name\":{\"type\":\"keyword\"}}}"