summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2021-06-18 14:06:18 +0200
committerArnstein Ressem <aressem@verizonmedia.com>2021-06-18 14:06:18 +0200
commitc24cda4150e45d83cf04662f0593821f6ea57036 (patch)
tree26d26f66e351291d216802b86b019e6e8ed6f92f /node-admin
parent1b174eb0bbeb53896816fbba6aaf98c55da4523f (diff)
Make sure this works for RHEL 7 with devtools 9 and 10 and RHEL 8 with devtools 10.
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollector.java17
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java33
2 files changed, 31 insertions, 19 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollector.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollector.java
index ec55d814e03..ce8fed0aa70 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollector.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollector.java
@@ -29,7 +29,8 @@ public class CoreCollector {
private static final Pattern CORE_GENERATOR_PATH_PATTERN = Pattern.compile("^Core was generated by `(?<path>.*?)'.$");
private static final Pattern EXECFN_PATH_PATTERN = Pattern.compile("^.* execfn: '(?<path>.*?)'");
private static final Pattern FROM_PATH_PATTERN = Pattern.compile("^.* from '(?<path>.*?)'");
- static final String GDB_PATH_RHEL7 = "/opt/rh/devtoolset-10/root/bin/gdb";
+ static final String GDB_PATH_RHEL7_DT9 = "/opt/rh/devtoolset-9/root/bin/gdb";
+ static final String GDB_PATH_RHEL7_DT10 = "/opt/rh/devtoolset-10/root/bin/gdb";
static final String GDB_PATH_RHEL8 = "/opt/rh/gcc-toolset-10/root/bin/gdb";
static final Map<String, Object> JAVA_HEAP_DUMP_METADATA =
@@ -42,11 +43,17 @@ public class CoreCollector {
}
String getGdbPath(NodeAgentContext context) {
- String[] command = {"stat", GDB_PATH_RHEL7};
- ProcessResult result = docker.executeCommandInContainerAsRoot(context, command);
- if (result.getExitStatus() == 0) {
- return GDB_PATH_RHEL7;
+ // TODO: Remove when we do not have any devtoolset-9 installs left
+ String[] command_rhel7_dt9 = {"stat", GDB_PATH_RHEL7_DT9};
+ if (docker.executeCommandInContainerAsRoot(context, command_rhel7_dt9).getExitStatus() == 0) {
+ return GDB_PATH_RHEL7_DT9;
+ }
+
+ String[] command_rhel7_dt10 = {"stat", GDB_PATH_RHEL7_DT10};
+ if (docker.executeCommandInContainerAsRoot(context, command_rhel7_dt10).getExitStatus() == 0) {
+ return GDB_PATH_RHEL7_DT10;
}
+
return GDB_PATH_RHEL8;
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java
index bfa1ea6ca2b..d61ab9e53b8 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoreCollectorTest.java
@@ -12,7 +12,8 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
-import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.GDB_PATH_RHEL7;
+import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.GDB_PATH_RHEL7_DT9;
+import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.GDB_PATH_RHEL7_DT10;
import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.GDB_PATH_RHEL8;
import static com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoreCollector.JAVA_HEAP_DUMP_METADATA;
import static org.junit.Assert.assertEquals;
@@ -61,10 +62,10 @@ public class CoreCollectorTest {
"execfn: '/usr/bin/program', platform: 'x86_64");
assertEquals(TEST_BIN_PATH, coreCollector.readBinPath(context, TEST_CORE_PATH));
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "The stat output");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "The stat output");
Path fallbackResponse = Paths.get("/response/from/fallback");
- mockExec(new String[]{"/bin/sh", "-c", GDB_PATH_RHEL7 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"},
+ mockExec(new String[]{"/bin/sh", "-c", GDB_PATH_RHEL7_DT9 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"},
"Core was generated by `/response/from/fallback'.");
mockExec(cmd,
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style");
@@ -76,10 +77,11 @@ public class CoreCollectorTest {
@Test
public void extractsBinaryPathUsingGdbTest() {
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "The stat output");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "", "stat: No such file or directory");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT10}, "The stat output");
final String[] cmd = new String[]{"/bin/sh", "-c",
- GDB_PATH_RHEL7 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"};
+ GDB_PATH_RHEL7_DT10 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"};
mockExec(cmd, "Core was generated by `/usr/bin/program-from-gdb --identity foo/search/cluster.content_'.");
assertEquals(Paths.get("/usr/bin/program-from-gdb"), coreCollector.readBinPathFallback(context, TEST_CORE_PATH));
@@ -96,28 +98,28 @@ public class CoreCollectorTest {
@Test
public void extractsBacktraceUsingGdb() {
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "The stat output");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "The stat output");
- mockExec(new String[]{GDB_PATH_RHEL7, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH_RHEL7_DT9, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
assertEquals(GDB_BACKTRACE, coreCollector.readBacktrace(context, TEST_CORE_PATH, TEST_BIN_PATH, false));
- mockExec(new String[]{GDB_PATH_RHEL7, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH_RHEL7_DT9, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
"", "Failure");
try {
coreCollector.readBacktrace(context, TEST_CORE_PATH, TEST_BIN_PATH, false);
fail("Expected not to be able to read backtrace");
} catch (RuntimeException e) {
assertEquals("Failed to read backtrace ProcessResult { exitStatus=1 output= errors=Failure }, Command: " +
- "[/opt/rh/devtoolset-10/root/bin/gdb, -n, -ex, bt, -batch, /usr/bin/program, /tmp/core.1234]", e.getMessage());
+ "[" + GDB_PATH_RHEL7_DT9 + ", -n, -ex, bt, -batch, /usr/bin/program, /tmp/core.1234]", e.getMessage());
}
}
@Test
public void extractsBacktraceFromAllThreadsUsingGdb() {
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "The stat output");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "The stat output");
- mockExec(new String[]{GDB_PATH_RHEL7, "-n", "-ex", "thread apply all bt", "-batch",
+ mockExec(new String[]{GDB_PATH_RHEL7_DT9, "-n", "-ex", "thread apply all bt", "-batch",
"/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
assertEquals(GDB_BACKTRACE, coreCollector.readBacktrace(context, TEST_CORE_PATH, TEST_BIN_PATH, true));
@@ -128,7 +130,8 @@ public class CoreCollectorTest {
mockExec(new String[]{"file", TEST_CORE_PATH.toString()},
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " +
"'/usr/bin/program'");
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "", "stat: No such file or directory");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "", "stat: No such file or directory");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT10}, "", "stat: No such file or directory");
mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
mockExec(new String[]{GDB_PATH_RHEL8, "-n", "-ex", "thread apply all bt", "-batch",
@@ -147,7 +150,8 @@ public class CoreCollectorTest {
mockExec(new String[]{"file", TEST_CORE_PATH.toString()},
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " +
"'/usr/bin/program'");
- mockExec(new String[]{GDB_PATH_RHEL7 + " -n -ex bt -batch /usr/bin/program /tmp/core.1234"},
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "The stat output");
+ mockExec(new String[]{GDB_PATH_RHEL7_DT9 + " -n -ex bt -batch /usr/bin/program /tmp/core.1234"},
"", "Failure");
Map<String, Object> expectedData = Map.of("bin_path", TEST_BIN_PATH.toString());
@@ -159,7 +163,8 @@ public class CoreCollectorTest {
mockExec(new String[]{"file", TEST_CORE_PATH.toString()},
"dump.core.5954: ELF 64-bit LSB core file x86-64, version 1 (SYSV), too many program header sections (33172)");
- mockExec(new String[]{"stat", GDB_PATH_RHEL7}, "", "stat: No such file or directory");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT9}, "", "stat: No such file or directory");
+ mockExec(new String[]{"stat", GDB_PATH_RHEL7_DT10}, "", "stat: No such file or directory");
mockExec(new String[]{"/bin/sh", "-c", GDB_PATH_RHEL8 + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"},
"Core was generated by `" + JDK_PATH + " -Dconfig.id=default/container.11 -XX:+Pre'.");