Skip to content

Commit f11bc98

Browse files
fix(opensearch): readable advice when both engines are unreachable (#37636)
The both-down message read "Neither Elasticsearch nor OpenSearch could not be reached", a double negative that states the opposite. It now says both could not be reached and gives each engine's reason. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 8cd63d6 commit f11bc98

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎dotCMS/src/main/java/com/dotcms/content/index/migration/MirrorStatus.java‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,19 @@ public static Verdict verdictFor(final EngineCopy es, final EngineCopy os) {
263263
*/
264264
public static String unmeasuredAdvice(final String what, final String name, final EngineCopy es,
265265
final EngineCopy os) {
266-
final String engines = !es.wasRead() && !os.wasRead()
267-
? "Neither Elasticsearch nor OpenSearch"
268-
: (!es.wasRead() ? ELASTICSEARCH : OPENSEARCH);
269-
final String reason = !es.wasRead() ? es.unavailableReason() : os.unavailableReason();
266+
final String engines;
267+
final String reason;
268+
if (!es.wasRead() && !os.wasRead()) {
269+
engines = "Both Elasticsearch and OpenSearch";
270+
reason = ELASTICSEARCH + ": " + es.unavailableReason() + "; " + OPENSEARCH + ": "
271+
+ os.unavailableReason();
272+
} else if (!es.wasRead()) {
273+
engines = ELASTICSEARCH;
274+
reason = es.unavailableReason();
275+
} else {
276+
engines = OPENSEARCH;
277+
reason = os.unavailableReason();
278+
}
270279
return String.format("%s could not be reached (%s), so the two copies of %s '%s' could not "
271280
+ "be compared. Restore access and re-run this check; do not rebuild the index on the "
272281
+ "strength of this reading.", engines, reason, what, name);

‎dotCMS/src/test/java/com/dotcms/content/index/migration/ContentIndexMirrorReconcilerTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,5 +583,9 @@ public void bothEnginesUnreachable_rowsStillReported() {
583583
assertEquals(Verdict.UNMEASURED, mirrors.statuses().get(0).verdict());
584584
assertFalse(mirrors.statuses().get(0).es().wasRead());
585585
assertFalse(mirrors.statuses().get(0).os().wasRead());
586+
final String advice = mirrors.statuses().get(0).recommendation();
587+
assertTrue(advice, advice.startsWith("Both Elasticsearch and OpenSearch could not be reached"));
588+
assertTrue(advice, advice.contains("Elasticsearch: es down"));
589+
assertTrue(advice, advice.contains("OpenSearch: os down"));
586590
}
587591
}

0 commit comments

Comments
 (0)