Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommission api level support #4604

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8e1056a
Add changes for Recommission API
pranikum Sep 27, 2022
c614b9a
Update json file name
pranikum Sep 27, 2022
55c4b42
Add line for the file
pranikum Sep 27, 2022
74758e6
Delete decommission awareness
pranikum Sep 27, 2022
d76f281
Merge with latest
pranikum Sep 28, 2022
686a9a2
Resolve conflict
pranikum Sep 28, 2022
c74a18c
Merge branch 'main' into recommission-api-level-support-2
pranikum Sep 28, 2022
ebb0d1a
Conflict resolution
pranikum Sep 28, 2022
07cd63a
Spotless java check
pranikum Sep 28, 2022
746100a
Remove toxcontet implements
pranikum Sep 29, 2022
9d60fd6
Merge with main changes
pranikum Sep 29, 2022
1011f35
Merge branch 'main' into recommission-api-level-support-2
pranikum Sep 29, 2022
0aca81b
Update change log
pranikum Sep 29, 2022
091f2ea
Add todo tin transport for service call
pranikum Sep 29, 2022
9fddb62
Conflict with latest
pranikum Oct 3, 2022
3dde9b4
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 3, 2022
3ee67fc
Merge conflict with latest
pranikum Oct 3, 2022
7f988f8
Spotless Java check
pranikum Oct 3, 2022
4c3ed86
Merge changelog with latest
pranikum Oct 6, 2022
91d8a69
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 6, 2022
34d3989
Fix changelog
pranikum Oct 6, 2022
2117249
Merge with latest. Add call to service
pranikum Oct 6, 2022
1a80293
Merge with latest
pranikum Oct 10, 2022
201e64d
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 10, 2022
baae7fb
Merge back changelog
pranikum Oct 10, 2022
2695198
Fix comments
pranikum Oct 10, 2022
2fa306c
Remove unwanted change
pranikum Oct 11, 2022
e7388e3
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 11, 2022
a052dad
Merge changelog with latest
pranikum Oct 12, 2022
bfe13cb
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 12, 2022
0d98d0c
Resolve changelog cnflict
pranikum Oct 12, 2022
d572494
Merge with latest
pranikum Oct 12, 2022
97df22d
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 12, 2022
28e5c69
Resolve conflict
pranikum Oct 12, 2022
69a281a
Fix comments
pranikum Oct 12, 2022
2981de5
Merge with latest
pranikum Oct 13, 2022
9557048
Merge branch 'main' into recommission-api-level-support-2
pranikum Oct 13, 2022
9bd1717
Resolve conflict
pranikum Oct 13, 2022
760aaaf
Update comments
pranikum Oct 13, 2022
3d842ef
Empty commit
pranikum Oct 13, 2022
6305812
Empty commit
pranikum Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add BWC version 2.3.1 ([#4513](https://github.com/opensearch-project/OpenSearch/pull/4513))
- [Segment Replication] Add snapshot and restore tests for segment replication feature ([#3993](https://github.com/opensearch-project/OpenSearch/pull/3993))
- Added missing javadocs for `:example-plugins` modules ([#4540](https://github.com/opensearch-project/OpenSearch/pull/4540))
- Recommissioning of zone. REST layer support. ([#4321](https://github.com/opensearch-project/OpenSearch/pull/4321))
### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ public void testApiNamingConventions() throws Exception {
"nodes.usage",
"nodes.reload_secure_settings",
"search_shards",
"remote_store.restore", };
"remote_store.restore",
"cluster.delete_decommission_awareness", };
List<String> booleanReturnMethods = Arrays.asList("security.enable_user", "security.disable_user", "security.change_password");
Set<String> deprecatedMethods = new HashSet<>();
deprecatedMethods.add("indices.force_merge");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"cluster.delete_decommission_awareness": {
pranikum marked this conversation as resolved.
Show resolved Hide resolved
"documentation": {
"url": "https://opensearch.org/docs/latest/opensearch/rest-api/decommission/",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link redirects to docs. Is the documentation work in progress? or Am I missing something?

"description": "Delete any existing decommission."
},
"stability": "experimental",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it experimental?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will be marking this to stable once all meta issues are resolved we already have task identified for same.
#3957

"url": {
"paths": [
{
"path": "/_cluster/decommission/awareness/",
"methods": [
"DELETE"
]
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.opensearch.action.admin.cluster.configuration.ClearVotingConfigExclusionsAction;
import org.opensearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction;
import org.opensearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateAction;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.TransportDeleteDecommissionStateAction;
import org.opensearch.action.admin.cluster.health.ClusterHealthAction;
import org.opensearch.action.admin.cluster.health.TransportClusterHealthAction;
import org.opensearch.action.admin.cluster.node.hotthreads.NodesHotThreadsAction;
Expand Down Expand Up @@ -300,6 +302,7 @@
import org.opensearch.rest.action.admin.cluster.RestClusterStatsAction;
import org.opensearch.rest.action.admin.cluster.RestClusterUpdateSettingsAction;
import org.opensearch.rest.action.admin.cluster.RestCreateSnapshotAction;
import org.opensearch.rest.action.admin.cluster.RestDeleteDecommissionStateAction;
import org.opensearch.rest.action.admin.cluster.RestDeleteRepositoryAction;
import org.opensearch.rest.action.admin.cluster.RestDeleteSnapshotAction;
import org.opensearch.rest.action.admin.cluster.RestDeleteStoredScriptAction;
Expand Down Expand Up @@ -678,6 +681,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
actions.register(DeletePitAction.INSTANCE, TransportDeletePitAction.class);
actions.register(PitSegmentsAction.INSTANCE, TransportPitSegmentsAction.class);
actions.register(GetAllPitsAction.INSTANCE, TransportGetAllPitsAction.class);
actions.register(DeleteDecommissionStateAction.INSTANCE, TransportDeleteDecommissionStateAction.class);

// Remote Store
actions.register(RestoreRemoteStoreAction.INSTANCE, TransportRestoreRemoteStoreAction.class);
Expand Down Expand Up @@ -859,6 +863,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestDeletePitAction());
registerHandler.accept(new RestGetAllPitsAction(nodesInCluster));
registerHandler.accept(new RestPitSegmentsAction(nodesInCluster));
registerHandler.accept(new RestDeleteDecommissionStateAction());

for (ActionPlugin plugin : actionPlugins) {
for (RestHandler handler : plugin.getRestHandlers(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action.admin.cluster.decommission.awareness.delete;

import org.opensearch.action.ActionType;

/**
* Transport action delete decommission.
*
* @opensearch.internal
*/

public class DeleteDecommissionStateAction extends ActionType<DeleteDecommissionStateResponse> {
public static final DeleteDecommissionStateAction INSTANCE = new DeleteDecommissionStateAction();
public static final String NAME = "cluster:admin/decommission/awareness/delete";

private DeleteDecommissionStateAction() {
super(NAME, DeleteDecommissionStateResponse::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action.admin.cluster.decommission.awareness.delete;

import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;

import java.io.IOException;

/**
* Request for deleting decommission request.
*
* @opensearch.internal
*/
public class DeleteDecommissionStateRequest extends ClusterManagerNodeRequest<DeleteDecommissionStateRequest> {
pranikum marked this conversation as resolved.
Show resolved Hide resolved

public DeleteDecommissionStateRequest() {}

public DeleteDecommissionStateRequest(StreamInput in) throws IOException {
super(in);
}

@Override
public ActionRequestValidationException validate() {
return null;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action.admin.cluster.decommission.awareness.delete;

import org.opensearch.action.support.clustermanager.ClusterManagerNodeOperationRequestBuilder;
import org.opensearch.client.OpenSearchClient;

/**
* Builder for a Delete decommission request.
*
* @opensearch.internal
*/
public class DeleteDecommissionStateRequestBuilder extends ClusterManagerNodeOperationRequestBuilder<
DeleteDecommissionStateRequest,
DeleteDecommissionStateResponse,
DeleteDecommissionStateRequestBuilder> {

public DeleteDecommissionStateRequestBuilder(OpenSearchClient client, DeleteDecommissionStateAction action) {
super(client, action, new DeleteDecommissionStateRequest());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action.admin.cluster.decommission.awareness.delete;

import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.ToXContentObject;

import java.io.IOException;

/**
* Response returned after deletion of decommission request.
*
* @opensearch.internal
*/
public class DeleteDecommissionStateResponse extends AcknowledgedResponse implements ToXContentObject {
pranikum marked this conversation as resolved.
Show resolved Hide resolved

public DeleteDecommissionStateResponse(StreamInput in) throws IOException {
super(in);
}

public DeleteDecommissionStateResponse(boolean acknowledged) {
super(acknowledged);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.action.admin.cluster.decommission.awareness.delete;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionListener;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.block.ClusterBlockException;
import org.opensearch.cluster.block.ClusterBlockLevel;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

import java.io.IOException;

/**
* Transport action for delete decommission.
*
* @opensearch.internal
*/
public class TransportDeleteDecommissionStateAction extends TransportClusterManagerNodeAction<
DeleteDecommissionStateRequest,
DeleteDecommissionStateResponse> {

private static final Logger logger = LogManager.getLogger(TransportDeleteDecommissionStateAction.class);

@Inject
public TransportDeleteDecommissionStateAction(
TransportService transportService,
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
DeleteDecommissionStateAction.NAME,
transportService,
clusterService,
threadPool,
actionFilters,
DeleteDecommissionStateRequest::new,
indexNameExpressionResolver
);
}

@Override
protected String executor() {
return ThreadPool.Names.SAME;
}

@Override
protected DeleteDecommissionStateResponse read(StreamInput in) throws IOException {
return new DeleteDecommissionStateResponse(in);
}

@Override
protected ClusterBlockException checkBlock(DeleteDecommissionStateRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}

@Override
protected void clusterManagerOperation(
DeleteDecommissionStateRequest request,
ClusterState state,
ActionListener<DeleteDecommissionStateResponse> listener
) {
// TODO: Enable when service class change is merged
logger.info("Received delete decommission Request");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to put this in debug log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it as info only. Don't expect call to decommission/recommission be called frequently. It will be a nice checkpoint to track.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make it more verbose with the request details. This PR is still WIP, please also rename the PR appropriately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added request object in the log.

listener.onResponse(new DeleteDecommissionStateResponse(true));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/** Delete decommission transport handlers. */
package org.opensearch.action.admin.cluster.decommission.awareness.delete;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest;
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequestBuilder;
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateRequest;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateRequestBuilder;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateResponse;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
Expand Down Expand Up @@ -791,4 +794,19 @@ public interface ClusterAdminClient extends OpenSearchClient {
* Delete specified dangling indices.
*/
ActionFuture<AcknowledgedResponse> deleteDanglingIndex(DeleteDanglingIndexRequest request);

/**
* Deletes the decommission metadata.
*/
ActionFuture<DeleteDecommissionStateResponse> deleteDecommissionState(DeleteDecommissionStateRequest request);

/**
* Deletes the decommission metadata.
*/
void deleteDecommissionState(DeleteDecommissionStateRequest request, ActionListener<DeleteDecommissionStateResponse> listener);

/**
* Deletes the decommission metadata.
*/
DeleteDecommissionStateRequestBuilder prepareDeleteDecommissionRequest();
}
8 changes: 8 additions & 0 deletions server/src/main/java/org/opensearch/client/Requests.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.client;

import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateRequest;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest;
import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest;
import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest;
Expand Down Expand Up @@ -539,6 +540,13 @@ public static DeleteSnapshotRequest deleteSnapshotRequest(String repository, Str
return new DeleteSnapshotRequest(repository, snapshots);
}

/**
* Creates a new delete decommission request.
*/
public static DeleteDecommissionStateRequest deleteDecommissionStateRequest() {
return new DeleteDecommissionStateRequest();
}

/**
* Get status of snapshots
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest;
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequestBuilder;
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateAction;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateRequest;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateRequestBuilder;
import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateResponse;
import org.opensearch.action.admin.cluster.health.ClusterHealthAction;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
Expand Down Expand Up @@ -1272,6 +1276,24 @@ public ActionFuture<AcknowledgedResponse> deleteDanglingIndex(DeleteDanglingInde
return execute(DeleteDanglingIndexAction.INSTANCE, request);
}

@Override
public ActionFuture<DeleteDecommissionStateResponse> deleteDecommissionState(DeleteDecommissionStateRequest request) {
return execute(DeleteDecommissionStateAction.INSTANCE, request);
}

@Override
public void deleteDecommissionState(
DeleteDecommissionStateRequest request,
ActionListener<DeleteDecommissionStateResponse> listener
) {
execute(DeleteDecommissionStateAction.INSTANCE, request, listener);
}

@Override
public DeleteDecommissionStateRequestBuilder prepareDeleteDecommissionRequest() {
return new DeleteDecommissionStateRequestBuilder(this, DeleteDecommissionStateAction.INSTANCE);
}

@Override
public void deleteDanglingIndex(DeleteDanglingIndexRequest request, ActionListener<AcknowledgedResponse> listener) {
execute(DeleteDanglingIndexAction.INSTANCE, request, listener);
Expand Down
Loading