Skip to content

Commit be931ff

Browse files
committed
better fix
1 parent 3f7fb81 commit be931ff

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static GetDeploymentStatsAction.Response addFailedRoutes(
231231
}
232232
}
233233

234-
updatedNodeStats.sort(Comparator.comparing(n -> n.getNode() != null ? n.getNode().getId() : ""));
234+
updatedNodeStats.sort(Comparator.comparing(n -> n.getNode().getId()));
235235
updatedAssignmentStats.add(
236236
new AssignmentStats(
237237
stat.getDeploymentId(),
@@ -261,16 +261,18 @@ static GetDeploymentStatsAction.Response addFailedRoutes(
261261
List<AssignmentStats.NodeStats> nodeStats = new ArrayList<>();
262262

263263
for (var routingEntry : nonStartedEntries.getValue().entrySet()) {
264-
nodeStats.add(
265-
AssignmentStats.NodeStats.forNotStartedState(
266-
nodes.get(routingEntry.getKey()),
267-
routingEntry.getValue().getState(),
268-
routingEntry.getValue().getReason()
269-
)
270-
);
264+
if (nodes.nodeExists(routingEntry.getKey())) {
265+
nodeStats.add(
266+
AssignmentStats.NodeStats.forNotStartedState(
267+
nodes.get(routingEntry.getKey()),
268+
routingEntry.getValue().getState(),
269+
routingEntry.getValue().getReason()
270+
)
271+
);
272+
}
271273
}
272274

273-
nodeStats.sort(Comparator.comparing(n -> n.getNode() != null ? n.getNode().getId() : ""));
275+
nodeStats.sort(Comparator.comparing(n -> n.getNode().getId()));
274276

275277
updatedAssignmentStats.add(
276278
new AssignmentStats(

0 commit comments

Comments
 (0)