Skip to content

Commit 82e3350

Browse files
committed
Include timestamp in test cluster warn/error output
Previously the code to capture and dedup error and warn messages from test nodes would remove the timestamp from the message. This made debugging timing issues difficult. For example, the message would look like: ``` » WARN ][o.o.d.FileBasedSeedHostsProvider] [v2.19.5-0] expected, but did not find, a dynamic hosts list at [/home/ubuntu/workplace/opensearch-project/OpenSearch/qa/rolling-upgrade/build/testclusters/v2.19.5-0/config/unicast_hosts.txt] » ↑ repeated 2 times ↑ ``` With this change it looks like: ``` » [2026-02-18T20:04:29,167][WARN ][o.o.d.FileBasedSeedHostsProvider] [v2.19.5-0] expected, but did not find, a dynamic hosts list at [/home/ubuntu/workplace/opensearch-project/OpenSearch/qa/rolling-upgrade/build/testclusters/v2.19.5-0/config/unicast_hosts.txt] » ↑ repeated 2 times ↑ ``` Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent 628aa3d commit 82e3350

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ public class OpenSearchNode implements TestClusterConfiguration {
130130
private static final List<String> MESSAGES_WE_DONT_CARE_ABOUT = Arrays.asList(
131131
"Option UseConcMarkSweepGC was deprecated",
132132
"is a pre-release version of OpenSearch",
133-
"max virtual memory areas vm.max_map_count"
133+
"max virtual memory areas vm.max_map_count",
134+
"WARNING: A restricted method in java.lang.foreign.Linker has been called",
135+
"WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module",
136+
"WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module",
137+
"System::setSecurityManager",
138+
"Please consider reporting this to the maintainers of org.opensearch.bootstrap.OpenSearch",
139+
"net.bytebuddy.dynamic.loading.ClassInjector"
134140
);
135141
private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname";
136142
private static final String COMPUTERNAME_OVERRIDE = "WindowsComputername";
@@ -1001,7 +1007,7 @@ private void logProcessInfo(String prefix, ProcessHandle.Info info) {
10011007
}
10021008

10031009
private void logFileContents(String description, Path from) {
1004-
final Map<String, Integer> errorsAndWarnings = new LinkedHashMap<>();
1010+
final Map<LogMessage, Integer> errorsAndWarnings = new LinkedHashMap<>();
10051011
LinkedList<String> ring = new LinkedList<>();
10061012
try (LineNumberReader reader = new LineNumberReader(Files.newBufferedReader(from))) {
10071013
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
@@ -1013,10 +1019,12 @@ private void logFileContents(String description, Path from) {
10131019
lineToAdd = line;
10141020
// check to see if the previous message (possibly combined from multiple lines) was an error or
10151021
// warning as we want to show all of them
1016-
String previousMessage = normalizeLogLine(ring.getLast());
1017-
if (MESSAGES_WE_DONT_CARE_ABOUT.stream().noneMatch(previousMessage::contains)
1018-
&& (previousMessage.contains("ERROR") || previousMessage.contains("WARN"))) {
1019-
errorsAndWarnings.put(previousMessage, errorsAndWarnings.getOrDefault(previousMessage, 0) + 1);
1022+
String previousMessage = ring.getLast();
1023+
String normalizedMessage = normalizeLogLine(previousMessage);
1024+
if (MESSAGES_WE_DONT_CARE_ABOUT.stream().noneMatch(normalizedMessage::contains)
1025+
&& (normalizedMessage.contains("ERROR") || normalizedMessage.contains("WARN"))) {
1026+
LogMessage logMsg = new LogMessage(previousMessage, normalizedMessage);
1027+
errorsAndWarnings.put(logMsg, errorsAndWarnings.getOrDefault(logMsg, 0) + 1);
10201028
}
10211029
} else {
10221030
// We combine multi line log messages to make sure we never break exceptions apart
@@ -1037,8 +1045,8 @@ private void logFileContents(String description, Path from) {
10371045
}
10381046
if (errorsAndWarnings.isEmpty() == false) {
10391047
LOGGER.lifecycle("\n» ↓ errors and warnings from " + from + " ↓");
1040-
errorsAndWarnings.forEach((message, count) -> {
1041-
LOGGER.lifecycle("» " + message.replace("\n", "\n» "));
1048+
errorsAndWarnings.forEach((logMsg, count) -> {
1049+
LOGGER.lifecycle("» " + logMsg.fullMessage().replace("\n", "\n» "));
10421050
if (count > 1) {
10431051
LOGGER.lifecycle("» ↑ repeated " + count + " times ↑");
10441052
}
@@ -1049,11 +1057,24 @@ private void logFileContents(String description, Path from) {
10491057

10501058
if (ring.isEmpty() == false) {
10511059
LOGGER.lifecycle("» ↓ last " + TAIL_LOG_MESSAGES_COUNT + " non error or warning messages from " + from + " ↓");
1052-
ring.forEach(message -> {
1053-
if (errorsAndWarnings.containsKey(normalizeLogLine(message)) == false) {
1054-
LOGGER.lifecycle("» " + message.replace("\n", "\n» "));
1055-
}
1056-
});
1060+
ring.stream()
1061+
.filter(message -> !message.contains("ERROR") && !message.contains("WARN"))
1062+
.forEach(message -> LOGGER.lifecycle("» " + message.replace("\n", "\n» ")));
1063+
}
1064+
}
1065+
1066+
private record LogMessage(String fullMessage, String normalizedMessage) {
1067+
@Override
1068+
public boolean equals(Object o) {
1069+
if (this == o) return true;
1070+
if (o == null || getClass() != o.getClass()) return false;
1071+
LogMessage that = (LogMessage) o;
1072+
return normalizedMessage.equals(that.normalizedMessage);
1073+
}
1074+
1075+
@Override
1076+
public int hashCode() {
1077+
return normalizedMessage.hashCode();
10571078
}
10581079
}
10591080

0 commit comments

Comments
 (0)