From 733bb5a7a3ccc30d45d15419f53cfa398e0a0eb3 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Fri, 6 Oct 2023 17:19:54 +0100 Subject: [PATCH] [ML] Only log long time unassigned message if not empty (#100417) Followup to #100154 The log message about unassigned jobs is simply spam if there are no unassigned jobs, so it should only be logged if there's at least one item in the list. --- .../org/elasticsearch/xpack/ml/MlAssignmentNotifier.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java index 2378f0becd959..409c1e5d24fcd 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlAssignmentNotifier.java @@ -267,8 +267,9 @@ private void logLongTimeUnassigned(Instant now, ClusterState state) { } List itemsToReport = findLongTimeUnassignedTasks(now, tasks); - - logger.warn("ML persistent tasks unassigned for a long time [{}]", String.join("|", itemsToReport)); + if (itemsToReport.isEmpty() == false) { + logger.warn("ML persistent tasks unassigned for a long time [{}]", String.join("|", itemsToReport)); + } } /**