From 4b9846b90fd4ca977c9073e80b993a9259f70240 Mon Sep 17 00:00:00 2001 From: Rishabh Singh <6513075+findingrish@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:37:37 +0530 Subject: [PATCH] Improve exception message when DruidLeaderClient doesn't find leader node (#14775) The existing exception message No known server thrown in DruidLeaderClient is unhelpful. --- .../java/org/apache/druid/discovery/DruidLeaderClient.java | 6 +++++- .../org/apache/druid/discovery/DruidLeaderClientTest.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/druid/discovery/DruidLeaderClient.java b/server/src/main/java/org/apache/druid/discovery/DruidLeaderClient.java index 3bc29da40f4..d681004326c 100644 --- a/server/src/main/java/org/apache/druid/discovery/DruidLeaderClient.java +++ b/server/src/main/java/org/apache/druid/discovery/DruidLeaderClient.java @@ -264,7 +264,11 @@ public class DruidLeaderClient ); if (leader == null) { - throw new IOE("No known server"); + throw new IOE( + "A leader node could not be found for [%s] service. " + + "Check logs of service [%s] to confirm it is healthy.", + nodeRoleToWatch, nodeRoleToWatch + ); } else { return leader; } diff --git a/server/src/test/java/org/apache/druid/discovery/DruidLeaderClientTest.java b/server/src/test/java/org/apache/druid/discovery/DruidLeaderClientTest.java index 6b8f32ba190..cff1aeb9fb0 100644 --- a/server/src/test/java/org/apache/druid/discovery/DruidLeaderClientTest.java +++ b/server/src/test/java/org/apache/druid/discovery/DruidLeaderClientTest.java @@ -159,7 +159,9 @@ public class DruidLeaderClientTest extends BaseJettyTest druidLeaderClient.start(); expectedException.expect(IOException.class); - expectedException.expectMessage("No known server"); + expectedException.expectMessage( + "A leader node could not be found for [PEON] service. " + + "Check logs of service [PEON] to confirm it is healthy."); druidLeaderClient.makeRequest(HttpMethod.POST, "/simple/direct"); }