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

Add changes for graceful node decommission #4586

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
bdb6c6f
Add changes for graceful node decommission
pranikum Sep 25, 2022
afec689
Add WRRWeights class
pranikum Sep 25, 2022
3314ec3
Add logger message
pranikum Sep 25, 2022
bf622c4
Add tests
pranikum Sep 25, 2022
d933377
Remove unused code
pranikum Sep 26, 2022
bf4c217
Remove test annonation
pranikum Sep 26, 2022
c57530a
Fix spotless
pranikum Sep 26, 2022
7c43ad1
Add package info
pranikum Sep 26, 2022
ba8f500
Add weigh away status
pranikum Sep 26, 2022
8920480
PR comments
pranikum Sep 26, 2022
eeed711
Update changelog
pranikum Sep 26, 2022
ed1ccbc
Fix tests
pranikum Sep 26, 2022
7922291
Remove time check. Just we will schedule
pranikum Sep 27, 2022
bed942a
Set decommission status to In Progress on completion of timeout
pranikum Sep 27, 2022
67622a2
PR comments. Take latest changes for WRR API
pranikum Sep 27, 2022
b75b108
Add drain timeout to decommission request
pranikum Sep 27, 2022
f79b51d
Resolve merge conflicts
pranikum Sep 28, 2022
46a1b12
Merge conflict
pranikum Sep 28, 2022
afda24c
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Sep 28, 2022
509015e
Merge with latests
pranikum Sep 28, 2022
3f832f9
Fix tests and split set weights and weights population
pranikum Sep 28, 2022
b70370c
PR comments
pranikum Sep 28, 2022
5724ba8
Merging with latest
pranikum Sep 29, 2022
6d1ba1a
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Sep 29, 2022
e401908
Merge with latest.
pranikum Sep 29, 2022
289077f
Add changelog
pranikum Sep 29, 2022
0890c39
Merge with latest
pranikum Oct 3, 2022
ec0f0e1
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 3, 2022
2f10664
Merge on latest
pranikum Oct 3, 2022
daa0065
Spotless java check
pranikum Oct 3, 2022
e9e25f1
Fix compilation issue
pranikum Oct 3, 2022
4590da3
PR comments
pranikum Oct 3, 2022
abbec12
Fix logger check
pranikum Oct 3, 2022
bd6f485
PR comments
pranikum Oct 3, 2022
9c1b2aa
Fix PR comments
pranikum Oct 3, 2022
9aa4f37
Handle PR comments
pranikum Oct 6, 2022
fd9fabe
Merge with latest changes
pranikum Oct 6, 2022
79f06fc
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 6, 2022
0faa9b9
Merge graceful changes
pranikum Oct 6, 2022
adbc120
Make variable final
pranikum Oct 6, 2022
81d320b
Fix logger usage
pranikum Oct 6, 2022
de54abd
Merge changelog with latest
pranikum Oct 10, 2022
d2b0444
Update changelog Avoid joining during draining state
pranikum Oct 10, 2022
4ddaae4
Merge with latest
pranikum Oct 10, 2022
e5984f7
Add changelog
pranikum Oct 10, 2022
c600c6d
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 10, 2022
b97c83b
Handle node draining for node decommission
pranikum Oct 10, 2022
926c969
Fix changelog
pranikum Oct 10, 2022
abb9825
Changelog merge
pranikum Oct 12, 2022
26ba03e
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 12, 2022
8564208
Resolve conflict with latest
pranikum Oct 12, 2022
3e1c3b1
Merge to latest
pranikum Oct 14, 2022
01b208c
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 14, 2022
d8f0166
Merge with latest
pranikum Oct 14, 2022
f367f4f
Merge with Latest
pranikum Oct 14, 2022
e5ae1f3
Add changelog
pranikum Oct 14, 2022
d9d4904
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 14, 2022
f9ced18
Update Changelog
pranikum Oct 14, 2022
9881ef0
PR comments
pranikum Oct 15, 2022
1ed1b57
Fix validation message
pranikum Oct 15, 2022
dde8f48
Fix Tests
pranikum Oct 15, 2022
8453ca2
Add decommission State transition validation
pranikum Oct 16, 2022
3c417f5
Fix transition state
pranikum Oct 17, 2022
602ced2
Merge with latest
pranikum Oct 19, 2022
0574db5
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 19, 2022
3115772
checks valid weights and don't set it.
pranikum Oct 19, 2022
95fc853
Empty-Commit
pranikum Oct 19, 2022
165ce7d
Fix the integ tests
pranikum Oct 19, 2022
8e0f681
Merge with latest
pranikum Oct 20, 2022
460e96c
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 20, 2022
f3a7240
Resolve conflict
pranikum Oct 20, 2022
c147d15
PR comments
pranikum Oct 20, 2022
13c0c61
Spotless Fix and changes
pranikum Oct 20, 2022
56c48eb
Fix log message for logging
pranikum Oct 20, 2022
ce3cc6f
Fix spotless Apply
pranikum Oct 20, 2022
09aec9f
Fix logger usage
pranikum Oct 20, 2022
252a976
PR comments
pranikum Oct 20, 2022
60d4e87
Fix Tests
pranikum Oct 20, 2022
abdda72
Empty-Commit
pranikum Oct 20, 2022
1b8234c
Fix Tests
pranikum Oct 20, 2022
a4a2ff6
Empty-Commit
pranikum Oct 20, 2022
e410e45
Fix Integ tests
pranikum Oct 20, 2022
7d2f2df
Change dely for Draining check
pranikum Oct 20, 2022
e25e411
Lower delay to 100 mills
pranikum Oct 20, 2022
09b7cdc
Fix typo
pranikum Oct 20, 2022
878dad4
Take latest for main
pranikum Oct 20, 2022
9d28440
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 20, 2022
d2303c5
Merge with latest
pranikum Oct 20, 2022
b78b452
Fix spotless Java
pranikum Oct 20, 2022
d1bb936
Update delay to 300
pranikum Oct 20, 2022
a8a6032
Add no_Delay param. No need to use schedule when nodelay is true
pranikum Oct 21, 2022
b724464
Remove exposed param delay_timeout
pranikum Oct 21, 2022
10a6e5f
Update delay to 500 since still we see failure for cluster state
pranikum Oct 21, 2022
d2d171d
Empty-Commit
pranikum Oct 21, 2022
68e4e94
In case of no delay.. Avoid draining state
pranikum Oct 24, 2022
d6fe3c4
Merging with lates
pranikum Oct 24, 2022
ca0418f
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 24, 2022
04e4676
Resolve conflict with main
pranikum Oct 24, 2022
a6fbdb2
Fix test
pranikum Oct 24, 2022
811fe8e
Take latest file
pranikum Oct 25, 2022
97c93c1
Merge branch 'main' into graceful-node-decommission-wrr-2
pranikum Oct 25, 2022
122b16c
Resolve conflict
pranikum Oct 25, 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))
- Added changes for graceful node decommission ([#4586](https://github.com/opensearch-project/OpenSearch/pull/4586))
### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0

Expand Down
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.shards.routing.wrr.put;

import org.opensearch.action.ActionType;

/**
* Action to update weights for weighted round-robin shard routing policy.
*
* @opensearch.internal
*/
public final class ClusterPutWRRWeightsAction extends ActionType<ClusterPutWRRWeightsResponse> {

public static final ClusterPutWRRWeightsAction INSTANCE = new ClusterPutWRRWeightsAction();
public static final String NAME = "cluster:admin/routing/awareness/weights/put";

private ClusterPutWRRWeightsAction() {
super(NAME, ClusterPutWRRWeightsResponse::new);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* 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.shards.routing.wrr.put;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchGenerationException;
import org.opensearch.OpenSearchParseException;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
import org.opensearch.cluster.routing.WRRWeights;
import org.opensearch.common.bytes.BytesReference;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.DeprecationHandler;
import org.opensearch.common.xcontent.NamedXContentRegistry;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.common.xcontent.XContentType;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static org.opensearch.action.ValidateActions.addValidationError;

/**
* Request to update weights for weighted round-robin shard routing policy.
*
* @opensearch.internal
*/
public class ClusterPutWRRWeightsRequest extends ClusterManagerNodeRequest<ClusterPutWRRWeightsRequest> {
private static final Logger logger = LogManager.getLogger(ClusterPutWRRWeightsRequest.class);

private WRRWeights wrrWeight;
private String attributeName;

public WRRWeights wrrWeight() {
return wrrWeight;
}

public ClusterPutWRRWeightsRequest wrrWeight(WRRWeights wrrWeight) {
this.wrrWeight = wrrWeight;
return this;
}

public void attributeName(String attributeName) {
this.attributeName = attributeName;
}

public ClusterPutWRRWeightsRequest(StreamInput in) throws IOException {
super(in);
wrrWeight = new WRRWeights(in);
}

public ClusterPutWRRWeightsRequest() {

}

public void setWRRWeight(Map<String, String> source) {
try {
if (source.isEmpty()) {
throw new OpenSearchParseException(("Empty request body"));
}
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.map(source);
setWRRWeight(BytesReference.bytes(builder), builder.contentType());
} catch (IOException e) {
throw new OpenSearchGenerationException("Failed to generate [" + source + "]", e);
}
}

public void setWRRWeight(BytesReference source, XContentType contentType) {
try (
XContentParser parser = XContentHelper.createParser(
NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
source,
contentType
)
) {
String attrValue = null;
Map<String, Object> weights = new HashMap<>();
Object attrWeight = null;
XContentParser.Token token;
// move to the first alias
parser.nextToken();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
attrValue = parser.currentName();
} else if (token == XContentParser.Token.VALUE_STRING) {
attrWeight = parser.text();
weights.put(attrValue, attrWeight);
} else {
throw new OpenSearchParseException("failed to parse wrr request attribute [{}], unknown type", attrWeight);
}
}
this.wrrWeight = new WRRWeights(this.attributeName, weights);
} catch (IOException e) {
logger.error("error while parsing put wrr weights request object", e);
}
}

@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
if (wrrWeight == null) {
validationException = addValidationError("WRRWeights object is null", validationException);
}
if (wrrWeight.attributeName() == null || wrrWeight.attributeName().isEmpty()) {
validationException = addValidationError("Attribute name is missing", validationException);
}
if (wrrWeight.weights() == null || wrrWeight.weights().isEmpty()) {
validationException = addValidationError("Weights are missing", validationException);
}
int countValueWithZeroWeights = 0;
int weight;
try {
for (Object value : wrrWeight.weights().values()) {
if (value == null) {
validationException = addValidationError(("Weight is null"), validationException);
} else {
weight = Integer.parseInt(value.toString());
countValueWithZeroWeights = (weight == 0) ? countValueWithZeroWeights + 1 : countValueWithZeroWeights;
}
}
} catch (NumberFormatException e) {
validationException = addValidationError(("Weight is non-integer"), validationException);
}
if (countValueWithZeroWeights > 1) {
validationException = addValidationError(("More than one value has weight set as 0 "), validationException);
}

return validationException;
}

/**
* @param source weights definition from request body
* @return this request
*/
public ClusterPutWRRWeightsRequest source(Map<String, String> source) {
setWRRWeight(source);
return this;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
wrrWeight.writeTo(out);
}

@Override
public String toString() {
return "ClusterPutWRRWeightsRequest{" + "wrrWeight= " + wrrWeight.toString() + "}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.shards.routing.wrr.put;

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

import java.io.IOException;

/**
* Response from updating weights for weighted round-robin search routing policy.
*
* @opensearch.internal
*/
public class ClusterPutWRRWeightsResponse extends AcknowledgedResponse implements ToXContentObject {
public ClusterPutWRRWeightsResponse(boolean acknowledged) {
super(acknowledged);
}

public ClusterPutWRRWeightsResponse(StreamInput in) throws IOException {
super(in);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

/**
* WRR Weights request objects.
*/
package org.opensearch.action.admin.cluster.shards.routing.wrr.put;
Loading