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

Gracefully handle concurrent zone decommission action #5542

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
767803e
Control concurrency and handle retries
imRishN Dec 13, 2022
743ca01
Fix spotless check
imRishN Dec 13, 2022
dbb404e
Add changelog
imRishN Dec 13, 2022
ee90987
Add request timeout param
imRishN Dec 14, 2022
5870737
Changes
imRishN Dec 16, 2022
8dd5899
Merge remote-tracking branch 'upstream/main' into decommission/handle…
imRishN Dec 16, 2022
4946914
Fix spotless check
imRishN Dec 16, 2022
4f5e73c
Fix
imRishN Dec 16, 2022
378e3d2
Refactor
imRishN Dec 27, 2022
dd1b19f
Refactor
imRishN Dec 27, 2022
e4107d5
Add test for request
imRishN Jan 5, 2023
7954fb2
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
imRishN Jan 5, 2023
3caed7b
Add tests for controller
imRishN Jan 5, 2023
8e4ab4d
Test for retry
imRishN Jan 5, 2023
a5c4e08
Fix spotless check
imRishN Jan 5, 2023
51743ce
Move check at rest layer
imRishN Jan 5, 2023
b63baf7
Fix spotless check
imRishN Jan 5, 2023
b8b1434
Minor fix
imRishN Jan 5, 2023
ad6207f
Fix spotless check
imRishN Jan 5, 2023
4801501
Fix
imRishN Jan 5, 2023
3a88fb1
Merge remote-tracking branch 'upstream/main' into decommission/handle…
imRishN Jan 9, 2023
eb5c393
Remove retry flag and use original flag
imRishN Jan 9, 2023
ed6bffb
Fix spotless check
imRishN Jan 9, 2023
c68cdc7
Refactor code
imRishN Jan 9, 2023
1368ff4
Clean up
imRishN Jan 9, 2023
8ddd128
Empty-Commit
imRishN Jan 9, 2023
aa5c4b4
Empty-Commit
imRishN Jan 9, 2023
3993de9
Empty-Commit
imRishN Jan 9, 2023
afe5f46
Cleanup
imRishN Jan 10, 2023
61c9e5d
Fix
imRishN Jan 10, 2023
0e8b76c
Throw exception in line
imRishN Jan 10, 2023
7395dff
Fixes
imRishN Jan 10, 2023
319b4b1
Add IT for concurrency
imRishN Jan 10, 2023
c46992c
Add request id to decommission request
imRishN Jan 10, 2023
d4670b7
Fix
imRishN Jan 10, 2023
7ecbe6e
Fix
imRishN Jan 10, 2023
88ec79d
Fix
imRishN Jan 10, 2023
2b40e12
Resolve comments
imRishN Jan 10, 2023
a6d0c3b
Fix test
imRishN Jan 10, 2023
927d0cc
Test fix
imRishN Jan 10, 2023
539d77a
Merge remote-tracking branch 'upstream/main' into decommission/handle…
imRishN Jan 10, 2023
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
Prev Previous commit
Next Next commit
Refactor code
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
  • Loading branch information
imRishN committed Jan 9, 2023
commit c68cdc7689a0de2a61c9b348ce2cdc6c7c2f441e
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
public class DecommissionRequest extends ClusterManagerNodeRequest<DecommissionRequest> {

public static final TimeValue DEFAULT_REQUEST_TIMEOUT = TimeValue.timeValueSeconds(120);
public static final TimeValue DEFAULT_NODE_DRAINING_TIMEOUT = TimeValue.timeValueSeconds(120);

private DecommissionAttribute decommissionAttribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import static java.util.Collections.singletonList;
import static org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionRequest.DEFAULT_REQUEST_TIMEOUT;
import static org.opensearch.rest.RestRequest.Method.PUT;

/**
Expand Down Expand Up @@ -61,14 +59,6 @@ DecommissionRequest createRequest(RestRequest request) throws IOException {
decommissionRequest.setDelayTimeout(delayTimeout);
}

if (request.hasParam("timeout")) {
TimeValue requestTimeout = request.paramAsTime("timeout", DEFAULT_REQUEST_TIMEOUT);
if (requestTimeout.getMillis() < DEFAULT_REQUEST_TIMEOUT.getMillis()) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "default request timeout has to be at least [%s]", DEFAULT_REQUEST_TIMEOUT)
);
}
}
return decommissionRequest.setDecommissionAttribute(new DecommissionAttribute(attributeName, attributeValue))
.originalRequest(false);
imRishN marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.action.ActionListener;
import org.opensearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction;
import org.opensearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction;
import org.opensearch.action.admin.cluster.decommission.awareness.put.TransportDecommissionAction;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState;
Expand Down Expand Up @@ -116,22 +115,6 @@ public void setTransportServiceAndDefaultClusterState() {
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY))
); // registers action

new TransportDecommissionAction(
transportService,
clusterService,
new DecommissionService(
nodeSettingsBuilder.build(),
clusterSettings,
clusterService,
transportService,
threadPool,
allocationService
),
threadPool,
new ActionFilters(emptySet()),
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY))
); // registers action

transportService.start();
transportService.acceptIncomingRequests();
decommissionController = new DecommissionController(clusterService, transportService, allocationService, threadPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,6 @@ public void testCreateRequestWithDelayTimeout() throws IOException {
assertEquals(deprecatedRequest.getHttpRequest().method(), RestRequest.Method.PUT);
}

public void testCreateRequestWithInvalidTimeout() throws IOException {
Map<String, String> params = new HashMap<>();
params.put("awareness_attribute_name", "zone");
params.put("awareness_attribute_value", "zone-1");
params.put("timeout", "1m");

RestRequest request = buildRestRequest(params);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> action.createRequest(request));
assertEquals("default request timeout has to be at least [2m]", e.getMessage());
}

private FakeRestRequest buildRestRequest(Map<String, String> params) {
return new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT)
.withPath("/_cluster/decommission/awareness/{awareness_attribute_name}/{awareness_attribute_value}")
Expand Down