Skip to content

Commit cbe6923

Browse files
committed
Add zero-allocation deployments to best plan logging
1 parent 3fb23fd commit cbe6923

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,12 @@ public String prettyPrint() {
344344
}
345345

346346
Map<Node, List<Tuple<Deployment, Integer>>> nodeToModel = new HashMap<>();
347+
Set<Deployment> zeroAllocationsDeployments = new HashSet<>();
347348
for (Deployment m : assignments.keySet()) {
349+
if (assignments.get(m).isEmpty()) {
350+
zeroAllocationsDeployments.add(m);
351+
continue;
352+
}
348353
for (Node n : assignments.get(m).keySet()) {
349354
List<Tuple<Deployment, Integer>> allocationsPerModel = nodeToModel.containsKey(n) ? nodeToModel.get(n) : new ArrayList<>();
350355
allocationsPerModel.add(Tuple.tuple(m, assignments.get(m).get(n)));
@@ -382,6 +387,11 @@ public String prettyPrint() {
382387
msg.append('\n');
383388
}
384389
}
390+
if (zeroAllocationsDeployments.isEmpty() == false) {
391+
msg.append('\n');
392+
msg.append("Deployments with zero allocations: ");
393+
msg.append(zeroAllocationsDeployments.stream().map(Deployment::deploymentId).collect(Collectors.joining(", ", "[", "]")));
394+
}
385395
return msg.toString();
386396
}
387397

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ public AssignmentPlan computePlan(boolean tryAssigningAllPreviouslyAllocatedMode
102102
}
103103
}
104104

105-
logger.debug(() -> "Best plan =\n" + bestPlan.prettyPrint());
106-
logger.debug(() -> prettyPrintOverallStats(bestPlan));
107-
108-
return bestPlan.withZeroAllocationDeployments(deploymentsWithZeroAllocations);
105+
bestPlan = bestPlan.withZeroAllocationDeployments(deploymentsWithZeroAllocations);
106+
if (logger.isDebugEnabled()) {
107+
logger.debug("Best plan =\n{}", bestPlan.prettyPrint());
108+
logger.debug("{}", prettyPrintOverallStats(bestPlan));
109+
}
110+
return bestPlan;
109111
}
110112

111113
/**

0 commit comments

Comments
 (0)