Skip to content

Commit

Permalink
Deprecate Master nonmenclature (#501) (#502)
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>

Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
(cherry picked from commit a9d04ec)

Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com>
  • Loading branch information
1 parent 99e59dd commit a050838
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package org.opensearch.indexmanagement.indexstatemanagement.resthandler

import org.apache.logging.log4j.LogManager
import org.opensearch.action.support.master.MasterNodeRequest
import org.opensearch.client.node.NodeClient
import org.opensearch.common.Strings
import org.opensearch.common.logging.DeprecationLogger
import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.ISM_BASE_URI
import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.LEGACY_ISM_BASE_URI
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.explain.ExplainAction
Expand All @@ -18,6 +18,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_INDEX_TY
import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_JOB_SORT_FIELD
import org.opensearch.indexmanagement.indexstatemanagement.util.SHOW_POLICY_QUERY_PARAM
import org.opensearch.indexmanagement.indexstatemanagement.util.TYPE_PARAM_KEY
import org.opensearch.indexmanagement.indexstatemanagement.util.parseClusterManagerTimeout
import org.opensearch.indexmanagement.util.getSearchParams
import org.opensearch.rest.BaseRestHandler
import org.opensearch.rest.BaseRestHandler.RestChannelConsumer
Expand Down Expand Up @@ -66,10 +67,14 @@ class RestExplainAction : BaseRestHandler() {

val indexType = request.param(TYPE_PARAM_KEY, DEFAULT_INDEX_TYPE)

val clusterManagerTimeout = parseClusterManagerTimeout(
request, DeprecationLogger.getLogger(RestExplainAction::class.java), name
)

val explainRequest = ExplainRequest(
indices.toList(),
request.paramAsBoolean("local", false),
request.paramAsTime("master_timeout", MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT),
clusterManagerTimeout,
searchParams,
request.paramAsBoolean(SHOW_POLICY_QUERY_PARAM, DEFAULT_EXPLAIN_SHOW_POLICY),
indexType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@

package org.opensearch.indexmanagement.indexstatemanagement.resthandler

import org.opensearch.action.support.master.MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT
import org.opensearch.client.node.NodeClient
import org.opensearch.common.Strings
import org.opensearch.common.logging.DeprecationLogger
import org.opensearch.common.xcontent.XContentHelper
import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.ISM_BASE_URI
import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.LEGACY_ISM_BASE_URI
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.retryfailedmanagedindex.RetryFailedManagedIndexAction
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.retryfailedmanagedindex.RetryFailedManagedIndexRequest
import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_INDEX_TYPE
import org.opensearch.indexmanagement.indexstatemanagement.util.TYPE_PARAM_KEY
import org.opensearch.indexmanagement.indexstatemanagement.util.parseClusterManagerTimeout
import org.opensearch.rest.BaseRestHandler
import org.opensearch.rest.BaseRestHandler.RestChannelConsumer
import org.opensearch.rest.RestHandler.ReplacedRoute
Expand Down Expand Up @@ -60,9 +61,13 @@ class RestRetryFailedManagedIndexAction : BaseRestHandler() {

val indexType = request.param(TYPE_PARAM_KEY, DEFAULT_INDEX_TYPE)

val clusterManagerTimeout = parseClusterManagerTimeout(
request, DeprecationLogger.getLogger(RestRetryFailedManagedIndexAction::class.java), name
)

val retryFailedRequest = RetryFailedManagedIndexRequest(
indices.toList(), body["state"] as String?,
request.paramAsTime("master_timeout", DEFAULT_MASTER_NODE_TIMEOUT),
clusterManagerTimeout,
indexType
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class TransportExplainAction @Inject constructor(
.indices(*indexNames.toTypedArray())
.metadata(true)
.local(request.local)
.masterNodeTimeout(request.clusterManagerTimeout)
.clusterManagerNodeTimeout(request.clusterManagerTimeout)

client.admin().cluster().state(
clusterStateRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TransportRetryFailedManagedIndexAction @Inject constructor(
.indices(*request.indices.toTypedArray())
.metadata(true)
.local(false)
.masterNodeTimeout(request.clusterManagerTimeout)
.clusterManagerNodeTimeout(request.clusterManagerTimeout)
.indicesOptions(strictExpandIndicesOptions)

client.threadPool().threadContext.stashContext().use {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package org.opensearch.indexmanagement.indexstatemanagement.transport.action.upd
import org.apache.logging.log4j.LogManager
import org.opensearch.action.ActionListener
import org.opensearch.action.support.ActionFilters
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction
import org.opensearch.action.support.master.AcknowledgedResponse
import org.opensearch.action.support.master.TransportMasterNodeAction
import org.opensearch.cluster.ClusterState
import org.opensearch.cluster.ClusterStateTaskConfig
import org.opensearch.cluster.ClusterStateTaskExecutor
Expand Down Expand Up @@ -39,7 +39,7 @@ class TransportUpdateManagedIndexMetaDataAction @Inject constructor(
actionFilters: ActionFilters,
val indexMetadataProvider: IndexMetadataProvider,
indexNameExpressionResolver: IndexNameExpressionResolver
) : TransportMasterNodeAction<UpdateManagedIndexMetaDataRequest, AcknowledgedResponse>(
) : TransportClusterManagerNodeAction<UpdateManagedIndexMetaDataRequest, AcknowledgedResponse>(
UpdateManagedIndexMetaDataAction.INSTANCE.name(),
transportService,
clusterService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
package org.opensearch.indexmanagement.indexstatemanagement.util

import org.apache.logging.log4j.Logger
import org.opensearch.OpenSearchParseException
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest
import org.opensearch.action.support.master.AcknowledgedResponse
import org.opensearch.client.Client
import org.opensearch.common.io.stream.StreamInput
import org.opensearch.common.io.stream.StreamOutput
import org.opensearch.common.io.stream.Writeable
import org.opensearch.common.logging.DeprecationLogger
import org.opensearch.common.unit.TimeValue
import org.opensearch.common.xcontent.ToXContent
import org.opensearch.common.xcontent.ToXContentFragment
import org.opensearch.common.xcontent.XContentBuilder
Expand All @@ -23,6 +27,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.transport.action.upda
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.updateindexmetadata.UpdateManagedIndexMetaDataRequest
import org.opensearch.indexmanagement.opensearchapi.optionalTimeField
import org.opensearch.indexmanagement.opensearchapi.suspendUntil
import org.opensearch.rest.RestRequest
import java.lang.Exception
import java.time.Instant

Expand Down Expand Up @@ -126,3 +131,20 @@ suspend fun removeClusterStateMetadatas(client: Client, logger: Logger, indices:
logger.error("Failed to clean cluster state metadata for $indices")
}
}

const val MASTER_TIMEOUT_DEPRECATED_MESSAGE =
"Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead."
const val DUPLICATE_PARAMETER_ERROR_MESSAGE =
"Please only use one of the request parameters [master_timeout, cluster_manager_timeout]."
fun parseClusterManagerTimeout(request: RestRequest, deprecationLogger: DeprecationLogger, restActionName: String): TimeValue {
var timeout = request.paramAsTime("cluster_manager_timeout", ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT)

if (request.hasParam("master_timeout")) {
deprecationLogger.deprecate(restActionName + "_master_timeout_parameter", MASTER_TIMEOUT_DEPRECATED_MESSAGE)
if (request.hasParam("cluster_manager_timeout")) {
throw OpenSearchParseException(DUPLICATE_PARAMETER_ERROR_MESSAGE)
}
timeout = request.paramAsTime("master_timeout", timeout)
}
return timeout
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.apache.logging.log4j.LogManager
import org.opensearch.action.ActionListener
import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction
import org.opensearch.action.support.master.AcknowledgedResponse
import org.opensearch.action.support.master.TransportMasterNodeAction
import org.opensearch.client.Client
import org.opensearch.cluster.ClusterState
import org.opensearch.cluster.block.ClusterBlockException
Expand Down Expand Up @@ -38,7 +38,7 @@ class TransportUpdateRollupMappingAction @Inject constructor(
actionFilters: ActionFilters,
indexNameExpressionResolver: IndexNameExpressionResolver,
val client: Client
) : TransportMasterNodeAction<UpdateRollupMappingRequest, AcknowledgedResponse>(
) : TransportClusterManagerNodeAction<UpdateRollupMappingRequest, AcknowledgedResponse>(
UpdateRollupMappingAction.INSTANCE.name(),
transportService,
clusterService,
Expand Down

0 comments on commit a050838

Please sign in to comment.