Skip to content

Commit

Permalink
Collect core dumps (#229)
Browse files Browse the repository at this point in the history
* Include debug symbols for golang and dqlite builds

We need the debug symbols to analyze core dumps or live processes
using debuggers such as gdb or delve.

The size increase is reasonable, so we'll include them by default.

* Get detailed inspection reports

* Collect core dumps from perf tests

We're experiencing some dqlite crashes. The collected core dumps
should allow us to pinpoint the issue.

* perf test: upload the snaps in case of failure

We'll upload the snaps in case of perf test failures so that we
can further analyse the snap or potential core dumps.
  • Loading branch information
petrutlucian94 authored Jan 29, 2025
1 parent 2dc2de5 commit 9e917c8
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,15 @@ jobs:
with:
name: ${{ env.artifact_name }}
path: ${{ github.workspace }}/inspection-reports.tar.gz
- name: Upload base-code.snap
if: failure()
uses: actions/upload-artifact@v4
with:
name: base
path: ${{ github.workspace }}/base-code.snap
- name: Upload head.snap
if: failure()
uses: actions/upload-artifact@v4
with:
name: base
path: ${{ github.workspace }}/head.snap
2 changes: 1 addition & 1 deletion hack/dynamic-dqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if [ ! -f "${BUILD_DIR}/dqlite/libdqlite.la" ]; then
cd dqlite
autoreconf -i > /dev/null
./configure --enable-build-raft \
CFLAGS="-I${BUILD_DIR}/sqlite -I${BUILD_DIR}/libuv/include -I${BUILD_DIR}/lz4/lib -Werror=implicit-function-declaration" \
CFLAGS="-g -I${BUILD_DIR}/sqlite -I${BUILD_DIR}/libuv/include -I${BUILD_DIR}/lz4/lib -Werror=implicit-function-declaration" \
LDFLAGS=" -L${BUILD_DIR}/libuv/.libs -L${BUILD_DIR}/lz4/lib -L${BUILD_DIR}/libnsl/src" \
UV_CFLAGS="-I${BUILD_DIR}/libuv/include" \
UV_LIBS="-L${BUILD_DIR}/libuv/.libs" \
Expand Down
2 changes: 1 addition & 1 deletion hack/dynamic-go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ DIR="$(realpath `dirname "${0}"`)"

go build \
-tags libsqlite3 \
-ldflags '-s -w -extldflags "-Wl,-rpath,$ORIGIN/lib -Wl,-rpath,$ORIGIN/../lib"' \
-ldflags '-extldflags "-Wl,-rpath,$ORIGIN/lib -Wl,-rpath,$ORIGIN/../lib"' \
"${@}"
2 changes: 1 addition & 1 deletion hack/static-dqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if [ ! -f "${BUILD_DIR}/dqlite/libdqlite.la" ]; then
cd dqlite
autoreconf -i > /dev/null
./configure --disable-shared --enable-build-raft \
CFLAGS="${CFLAGS} -I${BUILD_DIR}/sqlite -I${BUILD_DIR}/libuv/include -I${BUILD_DIR}/lz4/lib -I${INSTALL_DIR}/musl/include -Werror=implicit-function-declaration" \
CFLAGS="-g ${CFLAGS} -I${BUILD_DIR}/sqlite -I${BUILD_DIR}/libuv/include -I${BUILD_DIR}/lz4/lib -I${INSTALL_DIR}/musl/include -Werror=implicit-function-declaration" \
LDFLAGS="${LDFLAGS} -L${BUILD_DIR}/libuv/.libs -L${BUILD_DIR}/lz4/lib -L${BUILD_DIR}/libnsl/src" \
UV_CFLAGS="-I${BUILD_DIR}/libuv/include" \
UV_LIBS="-L${BUILD_DIR}/libuv/.libs" \
Expand Down
2 changes: 1 addition & 1 deletion hack/static-go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ DIR="$(realpath `dirname "${0}"`)"

go build \
-tags libsqlite3 \
-ldflags '-s -w -linkmode "external" -extldflags "-static"' \
-ldflags '-linkmode "external" -extldflags "-static"' \
"${@}"
11 changes: 10 additions & 1 deletion test/performance/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ def _generate_inspection_report(h: harness.Harness, instance_id: str):
inspection_path = Path(config.INSPECTION_REPORTS_DIR)
result = h.exec(
instance_id,
["/snap/k8s/current/k8s/scripts/inspect.sh", "/inspection-report.tar.gz"],
[
"/snap/k8s/current/k8s/scripts/inspect.sh",
"--all-namespaces",
"--num-snap-log-entries",
"1000000",
"--core-dump-dir",
config.CORE_DUMP_DIR,
"/inspection-report.tar.gz",
],
capture_output=True,
text=True,
check=False,
Expand Down Expand Up @@ -159,6 +167,7 @@ def instances(
instance = h.new_instance(network_type=network_type)
instances.append(instance)
if not no_setup:
util.setup_core_dumps(instance)
util.setup_k8s_snap(instance, tmp_path, snap)

if not disable_k8s_bootstrapping and not no_setup:
Expand Down
4 changes: 4 additions & 0 deletions test/performance/tests/test_util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
# after the tests complete.
SKIP_CLEANUP = (os.getenv("TEST_SKIP_CLEANUP") or "") == "1"

# Note that when using containers, this will override the host configuration.
CORE_DUMP_PATTERN = (os.getenv("TEST_CORE_DUMP_PATTERN")) or r"core-%e.%p.%h"
CORE_DUMP_DIR = (os.getenv("TEST_CORE_DUMP_DIR")) or "/var/crash"

# SNAP is the path to the snap under test.
SNAP = os.getenv("TEST_SNAP") or ""

Expand Down
9 changes: 9 additions & 0 deletions test/performance/tests/test_util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ipaddress
import json
import logging
import os
import re
import shlex
import subprocess
Expand Down Expand Up @@ -146,6 +147,14 @@ def _as_int(value: Optional[str]) -> Optional[int]:
return None


def setup_core_dumps(instance: harness.Instance):
core_pattern = os.path.join(config.CORE_DUMP_DIR, config.CORE_DUMP_PATTERN)
LOG.info("Configuring core dumps. Pattern: %s", core_pattern)
instance.exec(["echo", core_pattern, ">", "/proc/sys/kernel/core_pattern"])
instance.exec(["echo", "1", ">", "/proc/sys/fs/suid_dumpable"])
instance.exec(["snap", "set", "system", "system.coredump.enable=true"])


def configure_dqlite_logging(instance: harness.Instance):
"""Configure k8s-dqlite logging (requires restart)."""
if config.DQLITE_TRACE_LEVEL:
Expand Down

0 comments on commit 9e917c8

Please sign in to comment.