From 8de39be9b6452119443988d65b4a262c1600e690 Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Sat, 24 Feb 2024 01:15:08 -0800 Subject: [PATCH] unwrap remote transport exception Signed-off-by: Surya Sashank Nistala --- .../org/opensearch/alerting/DocumentLevelMonitorRunner.kt | 7 +++++-- .../kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt index b34541a62..c127381b9 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/DocumentLevelMonitorRunner.kt @@ -324,8 +324,11 @@ object DocumentLevelMonitorRunner : MonitorRunner() { } override fun onFailure(e: Exception) { - logger.info("Fan out failed") - cont.resumeWithException(e) + logger.info("Fan out failed", e) + if (e.cause is Exception) // unwrap remote transport exception + cont.resumeWithException(e.cause as Exception) + else + cont.resumeWithException(e) } }, nodeMap.size diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt index 7eee2dadf..f86625082 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt @@ -645,7 +645,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { .get() Assert.assertTrue(getAlertsResponse != null) Assert.assertTrue(getAlertsResponse.alerts.size == 1) - Assert.assertTrue(getAlertsResponse.alerts[0].errorMessage == "IndexClosedException[closed]") + Assert.assertTrue(getAlertsResponse.alerts[0].errorMessage!!.contains("IndexClosedException[closed]")) // Reopen index client().admin().indices().open(OpenIndexRequest(index)).get() // Close queryIndex