Skip to content

Commit

Permalink
Print thread dump when ES fails to start during Docker packaging tests (
Browse files Browse the repository at this point in the history
elastic#119477)

(cherry picked from commit 577d102)
  • Loading branch information
mark-vieira committed Jan 2, 2025
1 parent c296f36 commit 893fc5a
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,32 @@ public static void waitForElasticsearchToStart() {
ps output:
%s
stdout():
Stdout:
%s
Stderr:
%s
Thread dump:
%s\
""", psOutput, dockerLogs.stdout(), dockerLogs.stderr()));
""", psOutput, dockerLogs.stdout(), dockerLogs.stderr(), getThreadDump()));
}
}

/**
* @return output of jstack for currently running Java process
*/
private static String getThreadDump() {
try {
String pid = dockerShell.run("/usr/share/elasticsearch/jdk/bin/jps | grep -v 'Jps' | awk '{print $1}'").stdout();
if (pid.isEmpty() == false) {
return dockerShell.run("/usr/share/elasticsearch/jdk/bin/jstack " + Integer.parseInt(pid)).stdout();
}
} catch (Exception e) {
logger.error("Failed to get thread dump", e);
}

return "";
}

/**
Expand Down

0 comments on commit 893fc5a

Please sign in to comment.