Skip to content

Commit b6c921f

Browse files
[ML] Prevent NPE if model assignment is removed while waiting to start (#115430) (#115560)
Co-authored-by: Elastic Machine <[email protected]>
1 parent dec43e3 commit b6c921f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/changelog/115430.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 115430
2+
summary: Prevent NPE if model assignment is removed while waiting to start
3+
area: Machine Learning
4+
type: bug
5+
issues: []

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartTrainedModelDeploymentAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,11 @@ public boolean test(ClusterState clusterState) {
671671
deploymentId
672672
).orElse(null);
673673
if (trainedModelAssignment == null) {
674-
// Something weird happened, it should NEVER be null...
674+
// The assignment may be null if it was stopped by another action while waiting
675+
this.exception = new ElasticsearchStatusException(
676+
"Error waiting for the model deployment to start. The trained model assignment was removed while waiting",
677+
RestStatus.BAD_REQUEST
678+
);
675679
logger.trace(() -> format("[%s] assignment was null while waiting for state [%s]", deploymentId, waitForState));
676680
return true;
677681
}

0 commit comments

Comments
 (0)