Skip to content

Commit

Permalink
Merge branch '2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenlan-amzn authored May 26, 2023
2 parents a127af7 + 168073e commit b4c4461
Show file tree
Hide file tree
Showing 21 changed files with 2,309 additions and 1 deletion.
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ configurations.testImplementation {
exclude module: "securemock"
}

tasks.named('forbiddenApisTest').configure {
//we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
bundledSignatures -= 'jdk-non-portable'
bundledSignatures += 'jdk-internal'
}

ext {
projectSubstitutions = [:]
}
Expand Down Expand Up @@ -567,6 +573,11 @@ integTest {
if (System.getProperty("tests.clustername") != null) {
exclude 'org/opensearch/indexmanagement/indexstatemanagement/MetadataRegressionIT.class'
}

// remove from running with remote cluster
if (usingRemoteCluster) {
exclude 'org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListenerIT.class'
}
}

task integTestRemote(type: RestIntegTestTask) {
Expand Down
18 changes: 18 additions & 0 deletions release-notes/opensearch-index-management.release-notes-2.8.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Version 2.8.0.0 2023-06-06

Compatible with OpenSearch 2.8.0

### Maintenance
* Upgrade to gradle 8.1.1. ([#777](https://github.com/opensearch-project/index-management/pull/777))
* Bump version to 2.8. ([#759](https://github.com/opensearch-project/index-management/pull/759))

### Features
* Support notification integration with long running operations. ([#790, 791, 793](https://github.com/opensearch-project/index-management/pull/793))

### Bug fixes
* Remove recursion call when checking permission on indices. ([#785](https://github.com/opensearch-project/index-management/pull/785))
* Added trimming of nanos part of "epoch_millis" timestamp when date_histogram type used is date_nanos. ([#782](https://github.com/opensearch-project/index-management/pull/782))
* Added proper resolving of sourceIndex inside RollupInterceptor, it's required for QueryStringQuery parsing. ([#773](https://github.com/opensearch-project/index-management/pull/773))

### Documentation
* Added 2.8 release notes. ([#794](https://github.com/opensearch-project/index-management/pull/794))
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager
import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionResponse
import org.opensearch.action.support.ActionFilter
import org.opensearch.action.support.ActiveShardsObserver
import org.opensearch.client.Client
import org.opensearch.cluster.metadata.IndexNameExpressionResolver
import org.opensearch.cluster.node.DiscoveryNodes
Expand Down Expand Up @@ -36,6 +37,7 @@ import org.opensearch.indexmanagement.controlcenter.notification.action.get.GetL
import org.opensearch.indexmanagement.controlcenter.notification.action.get.TransportGetLRONConfigAction
import org.opensearch.indexmanagement.controlcenter.notification.action.index.IndexLRONConfigAction
import org.opensearch.indexmanagement.controlcenter.notification.action.index.TransportIndexLRONConfigAction
import org.opensearch.indexmanagement.controlcenter.notification.filter.IndexOperationActionFilter
import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestDeleteLRONConfigAction
import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestGetLRONConfigAction
import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestIndexLRONConfigAction
Expand Down Expand Up @@ -211,6 +213,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
private var customIndexUUIDSetting: String? = null
private val extensions = mutableSetOf<String>()
private val extensionCheckerMap = mutableMapOf<String, StatusChecker>()
lateinit var indexOperationActionFilter: IndexOperationActionFilter

companion object {
const val PLUGINS_BASE_URI = "/_plugins"
Expand Down Expand Up @@ -463,6 +466,12 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin

val pluginVersionSweepCoordinator = PluginVersionSweepCoordinator(skipFlag, settings, threadPool, clusterService)

indexOperationActionFilter = IndexOperationActionFilter(
client, clusterService,
ActiveShardsObserver(clusterService, client.threadPool()),
indexNameExpressionResolver,
)

return listOf(
managedIndexRunner,
rollupRunner,
Expand Down Expand Up @@ -604,7 +613,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
}

override fun getActionFilters(): List<ActionFilter> {
return listOf(fieldCapsFilter)
return listOf(fieldCapsFilter, indexOperationActionFilter)
}

override fun getSystemIndexDescriptors(settings: Settings): Collection<SystemIndexDescriptor> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import java.io.IOException
const val DEFAULT_PAGINATION_SIZE = 20
const val DEFAULT_PAGINATION_FROM = 0
const val DEFAULT_SORT_ORDER = "asc"
const val SORT_ORDER_DESC = "desc"
const val DEFAULT_QUERY_STRING = "*"

data class SearchParams(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.indexmanagement.controlcenter.notification.filter

import org.apache.logging.log4j.LogManager
import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionResponse
import org.opensearch.action.support.ActionFilter
import org.opensearch.action.support.ActionFilterChain
import org.opensearch.action.support.ActiveShardsObserver
import org.opensearch.client.Client
import org.opensearch.cluster.metadata.IndexNameExpressionResolver
import org.opensearch.cluster.service.ClusterService
import org.opensearch.indexmanagement.controlcenter.notification.util.supportedActions
import org.opensearch.tasks.Task
import org.opensearch.tasks.TaskId

class IndexOperationActionFilter(
val client: Client,
val clusterService: ClusterService,
val activeShardsObserver: ActiveShardsObserver,
val indexNameExpressionResolver: IndexNameExpressionResolver
) : ActionFilter {

private val logger = LogManager.getLogger(IndexOperationActionFilter::class.java)

override fun order() = Integer.MAX_VALUE
override fun <Request : ActionRequest, Response : ActionResponse> apply(
task: Task,
action: String,
request: Request,
listener: ActionListener<Response>,
chain: ActionFilterChain<Request, Response>
) {
chain.proceed(task, action, request, wrapActionListener(task, action, request, listener))
}

fun <Request : ActionRequest, Response : ActionResponse> wrapActionListener(
task: Task,
action: String,
request: Request,
listener: ActionListener<Response>,
): ActionListener<Response> {
var wrappedListener = listener
if (supportedActions.contains(action)) {
if (task.parentTaskId.isSet == false) {
val taskId = TaskId(clusterService.localNode().id, task.id)
logger.info("Add notification action listener for tasks: {} and action: {} ", taskId.toString(), action)
wrappedListener = NotificationActionListener(
delegate = listener,
client = client,
action = action,
clusterService = clusterService,
task = task,
request = request,
activeShardsObserver = activeShardsObserver,
indexNameExpressionResolver = indexNameExpressionResolver
)
}
}
return wrappedListener
}
}
Loading

0 comments on commit b4c4461

Please sign in to comment.