-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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 support for CPU ranges in desired nodes #86434
Merged
Merged
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c7eb3e2
Add support for CPU ranges in desired nodes
fcofdez 7384292
Fix mistake
fcofdez 4a6d0b9
Change backwards compatible policy
fcofdez 39f3603
Update desired nodes docs
fcofdez b2b4f26
Add a few tests
fcofdez 7751acb
Update docs/changelog/86434.yaml
fcofdez 6cd28c2
Reviews
fcofdez ab44132
Support processor ranges and processors as separate fields
fcofdez cb24fdb
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez 33964ec
Merge branch 'desired-nodes-processors' of github.com:fcofdez/elastic…
fcofdez 74d4ef8
Max is not rendered
fcofdez 32934e4
Take into account newer versions in upgrade test
fcofdez 5bb3f51
Spotless
fcofdez 9e1990f
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez 3cc813e
Clarification
fcofdez c922cc1
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez 493e241
Remove unused contains
fcofdez 4ac2461
Upgrade test
fcofdez 40190a4
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez f56b63e
Change size
fcofdez 2dfa5e7
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez 02dceff
Review comments
fcofdez 1142f69
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez 7016271
Docs
fcofdez 68c97cf
Fix docs
fcofdez 9906fe0
Merge remote-tracking branch 'origin/master' into desired-nodes-proce…
fcofdez ea58538
Update server/src/main/java/org/elasticsearch/cluster/metadata/Desire…
fcofdez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 86434 | ||
summary: Add support for CPU ranges in desired nodes | ||
area: Autoscaling | ||
type: enhancement | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.cluster.metadata.DesiredNode; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class DesiredNodesUpgradeIT extends AbstractRollingTestCase { | ||
public void testUpgradeDesiredNodes() throws Exception { | ||
// Desired nodes was introduced in 8.1 | ||
if (UPGRADE_FROM_VERSION.before(Version.V_8_1_0)) { | ||
return; | ||
} | ||
|
||
switch (CLUSTER_TYPE) { | ||
case OLD -> { | ||
var response = updateDesiredNodes(1, desiredNodesWithIntegerProcessor()); | ||
var statusCode = response.getStatusLine().getStatusCode(); | ||
assertThat(statusCode, equalTo(200)); | ||
} | ||
case MIXED -> { | ||
final var historyVersion = FIRST_MIXED_ROUND ? 2 : 3; | ||
if (UPGRADE_FROM_VERSION.onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { | ||
var response = updateDesiredNodes(historyVersion, desiredNodesWithRangeOrFloatProcessors()); | ||
var statusCode = response.getStatusLine().getStatusCode(); | ||
assertThat(statusCode, equalTo(200)); | ||
} else { | ||
// Processor ranges or float processors are forbidden during upgrades: 8.2 -> 8.3 clusters | ||
final var responseException = expectThrows( | ||
ResponseException.class, | ||
() -> updateDesiredNodes(historyVersion, desiredNodesWithRangeOrFloatProcessors()) | ||
); | ||
var statusCode = responseException.getResponse().getStatusLine().getStatusCode(); | ||
assertThat(statusCode, is(equalTo(400))); | ||
} | ||
} | ||
case UPGRADED -> { | ||
var response = updateDesiredNodes(4, desiredNodesWithRangeOrFloatProcessors()); | ||
var statusCode = response.getStatusLine().getStatusCode(); | ||
assertThat(statusCode, equalTo(200)); | ||
} | ||
} | ||
|
||
final var getDesiredNodesRequest = new Request("GET", "/_internal/desired_nodes/_latest"); | ||
Response response = client().performRequest(getDesiredNodesRequest); | ||
assertThat(response.getStatusLine().getStatusCode(), is(equalTo(200))); | ||
} | ||
|
||
private Response updateDesiredNodes(int version, String body) throws Exception { | ||
final var updateDesiredNodesRequest = new Request("PUT", "/_internal/desired_nodes/history/" + version); | ||
updateDesiredNodesRequest.setJsonEntity(body); | ||
return client().performRequest(updateDesiredNodesRequest); | ||
} | ||
|
||
private String desiredNodesWithRangeOrFloatProcessors() { | ||
if (randomBoolean()) { | ||
return """ | ||
{ | ||
"nodes" : [ | ||
{ | ||
"settings" : { | ||
"node.name" : "instance-000187" | ||
}, | ||
"processors_range" : {"min": 9.0, "max": 10.0}, | ||
"memory" : "58gb", | ||
"storage" : "1tb", | ||
"node_version" : "99.1.0" | ||
} | ||
] | ||
}"""; | ||
} else { | ||
return """ | ||
{ | ||
"nodes" : [ | ||
{ | ||
"settings" : { | ||
"node.name" : "instance-000187" | ||
}, | ||
"processors" : 9.5, | ||
"memory" : "58gb", | ||
"storage" : "1tb", | ||
"node_version" : "99.1.0" | ||
} | ||
] | ||
}"""; | ||
} | ||
} | ||
|
||
private String desiredNodesWithIntegerProcessor() { | ||
return """ | ||
{ | ||
"nodes" : [ | ||
{ | ||
"settings" : { | ||
"node.name" : "instance-000187" | ||
}, | ||
"processors" : 9, | ||
"memory" : "58gb", | ||
"storage" : "1tb", | ||
"node_version" : "99.1.0" | ||
} | ||
] | ||
}"""; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we would not want to keep the
processors: 8
case in the documentation (perhaps using8.0
instead). I think the best world is if we have just the one number rather than multiple and having that case be simpler for those orchestrations that can supply it seems desirable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us also mention that
processors
can be specified as a range, that makes it easier to see which releases the range syntax is supported in (and documents it).