Skip to content

Commit c915fb8

Browse files
committed
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_doc_values_format_ff
2 parents c5b61da + 85094f2 commit c915fb8

File tree

21 files changed

+288
-192
lines changed

21 files changed

+288
-192
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
/**
1818
* Accessor for shared dependency versions used by elasticsearch, namely the elasticsearch and lucene versions.
1919
*
20-
* @deprecated use ext values set by {@link org.elasticsearch.gradle.internal.conventions.VersionPropertiesPlugin} or
21-
* {@link org.elasticsearch.gradle.internal.conventions.VersionPropertiesBuildService}
20+
* @deprecated use ext values set by org.elasticsearch.gradle.internal.conventions.VersionPropertiesPlugin or
21+
* org.elasticsearch.gradle.internal.conventions.VersionPropertiesBuildService
2222
*
2323
*/
2424
@Deprecated

docs/changelog/133919.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 133919
2+
summary: Fix double-counting of inference memory in the assignment rebalancer
3+
area: Machine Learning
4+
type: bug
5+
issues: []

docs/changelog/133930.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 133930
2+
summary: Improve memory estimation methods accuracy in `TrainedModelAssignmentRebalancer`
3+
and related classes
4+
area: Machine Learning
5+
type: bug
6+
issues: []

muted-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ tests:
537537
- class: org.elasticsearch.xpack.esql.action.RandomizedTimeSeriesIT
538538
method: testRateGroupBySubset
539539
issue: https://github.com/elastic/elasticsearch/issues/134019
540+
- class: org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDeciderIT
541+
method: testDesiredNodesAreTakenIntoAccountInAutoExpandReplicas
542+
issue: https://github.com/elastic/elasticsearch/issues/134049
543+
- class: org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDeciderIT
544+
method: testShardsAreKeptInPreferredTierUntilTheNextTierIsInItsFinalState
545+
issue: https://github.com/elastic/elasticsearch/issues/134050
540546

541547
# Examples:
542548
#

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.elasticsearch.watcher.ResourceWatcherService;
1717
import org.elasticsearch.xpack.core.security.authc.AuthenticationFailureHandler;
1818
import org.elasticsearch.xpack.core.security.authc.Realm;
19-
import org.elasticsearch.xpack.core.security.authc.apikey.CustomApiKeyAuthenticator;
19+
import org.elasticsearch.xpack.core.security.authc.apikey.CustomAuthenticator;
2020
import org.elasticsearch.xpack.core.security.authc.service.NodeLocalServiceAccountTokenStore;
2121
import org.elasticsearch.xpack.core.security.authc.service.ServiceAccountTokenStore;
2222
import org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper;
@@ -129,7 +129,7 @@ default ServiceAccountTokenStore getServiceAccountTokenStore(SecurityComponents
129129
return null;
130130
}
131131

132-
default CustomApiKeyAuthenticator getCustomApiKeyAuthenticator(SecurityComponents components) {
132+
default List<CustomAuthenticator> getCustomAuthenticators(SecurityComponents components) {
133133
return null;
134134
}
135135

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,18 @@ public static Authentication newRealmAuthentication(User user, RealmRef realmRef
13761376
return authentication;
13771377
}
13781378

1379+
public static Authentication newCloudAccessTokenAuthentication(
1380+
AuthenticationResult<User> authResult,
1381+
Authentication.RealmRef realmRef
1382+
) {
1383+
assert authResult.isAuthenticated() : "cloud access token authn result must be successful";
1384+
final User user = authResult.getValue();
1385+
return new Authentication(
1386+
new Subject(user, realmRef, TransportVersion.current(), authResult.getMetadata()),
1387+
AuthenticationType.TOKEN
1388+
);
1389+
}
1390+
13791391
public static Authentication newCloudApiKeyAuthentication(AuthenticationResult<User> authResult, String nodeName) {
13801392
assert authResult.isAuthenticated() : "cloud API Key authn result must be successful";
13811393
final User apiKeyUser = authResult.getValue();

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/apikey/CustomApiKeyAuthenticator.java

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.core.security.authc.apikey;
9+
10+
import org.elasticsearch.action.ActionListener;
11+
import org.elasticsearch.common.util.concurrent.ThreadContext;
12+
import org.elasticsearch.core.Nullable;
13+
import org.elasticsearch.xpack.core.security.authc.Authentication;
14+
import org.elasticsearch.xpack.core.security.authc.AuthenticationResult;
15+
import org.elasticsearch.xpack.core.security.authc.AuthenticationToken;
16+
17+
/**
18+
* An extension point to provide a custom authenticator implementation. For example, a custom API key or a custom OAuth2
19+
* token implementation. The implementation is wrapped by a core `Authenticator` class and included in the authenticator chain
20+
* _before_ the respective "standard" authenticator(s).
21+
*/
22+
public interface CustomAuthenticator {
23+
24+
boolean supports(AuthenticationToken token);
25+
26+
@Nullable
27+
AuthenticationToken extractToken(ThreadContext context);
28+
29+
void authenticate(@Nullable AuthenticationToken token, ActionListener<AuthenticationResult<Authentication>> listener);
30+
31+
}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ForecastJobActionRequestTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testSetDuration_GivenZero() {
5656
}
5757

5858
public void testSetDuration_GivenNegative() {
59-
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new Request().setDuration("-1s"));
59+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new Request().setDuration("-1"));
6060
assertThat(e.getMessage(), equalTo("[duration] must be positive: [-1]"));
6161
}
6262

@@ -67,7 +67,7 @@ public void testSetExpiresIn_GivenZero() {
6767
}
6868

6969
public void testSetExpiresIn_GivenNegative() {
70-
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new Request().setExpiresIn("-1s"));
70+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new Request().setExpiresIn("-1"));
7171
assertThat(e.getMessage(), equalTo("[expires_in] must be non-negative: [-1]"));
7272
}
7373
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/assignment/TrainedModelAssignmentRebalancer.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ private Map<List<String>, List<AssignmentPlan.Node>> createNodesByZoneMap() {
298298
nodes.add(
299299
new AssignmentPlan.Node(
300300
discoveryNode.getId(),
301-
// We subtract native inference memory as the planner expects available memory for
302-
// native inference including current assignments.
303-
getNodeFreeMemoryExcludingPerNodeOverheadAndNativeInference(load),
301+
load.getFreeMemoryExcludingPerNodeOverhead(),
304302
MlProcessors.get(discoveryNode, allocatedProcessorsScale).roundUp()
305303
)
306304
);
@@ -317,10 +315,6 @@ private Map<List<String>, List<AssignmentPlan.Node>> createNodesByZoneMap() {
317315
}));
318316
}
319317

320-
private static long getNodeFreeMemoryExcludingPerNodeOverheadAndNativeInference(NodeLoad load) {
321-
return load.getFreeMemoryExcludingPerNodeOverhead() - load.getAssignedNativeInferenceMemory();
322-
}
323-
324318
private TrainedModelAssignmentMetadata.Builder buildAssignmentsFromPlan(AssignmentPlan assignmentPlan) {
325319
TrainedModelAssignmentMetadata.Builder builder = TrainedModelAssignmentMetadata.Builder.empty();
326320
for (AssignmentPlan.Deployment deployment : assignmentPlan.deployments()) {
@@ -406,7 +400,28 @@ private Optional<String> explainAssignment(
406400
return Optional.of(load.getError());
407401
}
408402

409-
if (deployment.memoryBytes() > assignmentPlan.getRemainingNodeMemory(node.getId())) {
403+
// Find how many allocations already exist on this node
404+
// We need to search by node ID as assignmentPlan.assignments() returns a map
405+
// of AssignmentPlan.Node and the argument node of the DiscoveryNode
406+
int existingAllocationsOnNode = assignmentPlan.assignments(deployment)
407+
.map(
408+
assignments -> assignments.getOrDefault(
409+
assignments.keySet().stream().filter(n -> n.id().equals(node.getId())).findFirst().orElse(null),
410+
0
411+
)
412+
)
413+
.orElse(0);
414+
415+
// Calculate how many allocations remain to be assigned
416+
int unassignedAllocations = deployment.allocations() - assignmentPlan.totalAllocations(deployment);
417+
418+
// Check if there's enough memory for additional allocations
419+
long additionalMemory = deployment.estimateAdditionalMemoryUsageBytes(
420+
existingAllocationsOnNode,
421+
existingAllocationsOnNode + unassignedAllocations
422+
);
423+
long availableMemory = assignmentPlan.getRemainingNodeMemory(node.getId());
424+
if (additionalMemory > availableMemory) {
410425
// If any ML processes are running on a node we require some space to load the shared libraries.
411426
// So if none are currently running then this per-node overhead must be added to the requirement.
412427
// From node load we know if we had any jobs or models assigned before the rebalance.

0 commit comments

Comments
 (0)