Repository navigation
Install lldb in CI Docker images alongside gdb - #104815
Conversation
`clickhouse-test`'s `print_c_stacktraces` now drives `lldb` instead of `gdb` (ClickHouse#104771). To keep the helper from doing on-the-fly `apt-get install lldb` from inside an error path, install `lldb` at image build time. `lldb` is added to `clickhouse/fasttest` and `clickhouse/test-base` — the two base images on which every test image ultimately depends (`stateless-test`, `integration/runner`, `integration/base`, `performance-comparison` all inherit from `test-base`; `cctools` from `fasttest`). The LLVM apt repo is already configured for the matching `LLVM_VERSION` in both Dockerfiles, so the install is a single `apt-get install --yes lldb-${LLVM_VERSION}` plus a `/usr/bin/lldb` symlink and `chmod u+s` mirroring the existing `gdb` setup. `gdb` is kept as-is. It is still driven directly by the fuzzer (`ci/jobs/scripts/fuzzer/run-fuzzer.sh`), perf comparison (`ci/jobs/scripts/perf/compare.sh`), unit tests (`ci/jobs/unit_tests_job.py`), stress (`ci/jobs/scripts/stress/stress.py`), the upgrade runner (`tests/docker_scripts/upgrade_runner.sh`), and the integration test harness (`tests/integration/integration-tests-entrypoint.sh`, `tests/integration/helpers/cluster.py`, several tests under `tests/integration/`). Migrating those tools to `lldb` is out of scope for this PR. Follow-up: once this image lands, the `_ensure_lldb_installed` scaffolding in `tests/clickhouse-test` (added in ClickHouse#104771) can be deleted in a small cleanup PR.
|
Workflow [PR], commit [5923014] Summary: ✅
AI ReviewSummaryThis PR installs Final Verdict✅ No blocking or major issues found in the current diff. |
maxknv
left a comment
There was a problem hiding this comment.
why do we need to migrate? what is the size added to the image?
|
@maxknv It is recommended to use |
|
@maxknv Adding lldb to test-base costs ~120 MB per image (lldb-21 ~4 MB + liblldb-21 ~18 MB + libclang-cpp21 ~57 MB + python3-lldb-21 + a few smaller deps). But some images like fastest already contain libclang-cpp21 - thus we got only +50 MB for them. |
I think it's relatively easy. And we can avoid adding a new package to many Docker images (it's the base image you're updating), at least until it's confirmed that lldb works for us |
|
Dear @maxknv, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @maxknv, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
`_ensure_lldb_installed` split the install across two package managers: Homebrew on macOS and `apt-get` on Linux. The Linux branch can never work where it matters: the Fast test job runs in the unprivileged `clickhouse/fasttest` container (`docker run --user $(id -u):$(id -g)`, see `ci/praktika/runner.py`), so `apt-get install lldb` fails with a permission error and `c_stacktraces.log` is never written. Installing `lldb` on Linux belongs in the image, not at runtime -- see PR ClickHouse#104815 (`Install lldb in CI Docker images alongside gdb`). Drop the dead Linux branch and keep only the macOS Homebrew path (the Darwin runner is a bare host, not a container, so an on-the-fly install is the right tool there). On Linux the helper is now a no-op. Touching `tests/clickhouse-test` also changes the `Fast test (arm_darwin)` cache digest, so the job is a cache miss and actually re-runs on a real macOS host -- the previous run reused a cached result and reported `skipped`: https://github.com/ClickHouse/ClickHouse/actions/runs/30324617319 Related: ClickHouse#104815
`_ensure_lldb_installed` split the install across two package managers: Homebrew on macOS and `apt-get` on Linux. The Linux branch can never work where it matters: the Fast test job runs in the unprivileged `clickhouse/fasttest` container (`docker run --user $(id -u):$(id -g)`, see `ci/praktika/runner.py`), so `apt-get install lldb` fails with a permission error and `c_stacktraces.log` is never written. Installing `lldb` on Linux belongs in the image, not at runtime -- see PR ClickHouse#104815 (`Install lldb in CI Docker images alongside gdb`). Drop the dead Linux branch and keep only the macOS Homebrew path (the Darwin runner is a bare host, not a container, so an on-the-fly install is the right tool there). On Linux the helper is now a no-op. Related: ClickHouse#104815
Reviewer feedback on ci/docker/fasttest/Dockerfile and
ci/docker/test-base/Dockerfile asked to treat `lldb` as part of `llvm`
(same apt repo, same version) and drop the dedicated
`apt-get update`/install/cleanup block for it:
> This block should be with the block installing clang. It's the same repo, same version, etc
> Same here. Please treat lldb as part of llvm (because it is). No need to fetch the repo, install and track the version and clean up
Add `lldb-${LLVM_VERSION}` to the existing `clang`/`llvm` install list in
each image so it is fetched in the same layer that already configures the
LLVM apt repo, and keep only the `/usr/bin/lldb` symlink and suid steps in
the follow-up RUN.
clickhouse-test'sprint_c_stacktracesuseslldbto attach to a running (or hung) ClickHouse server and dump C++ backtraces intoc_stacktraces.logon a test timeout or the end-of-run hung check. For that to work,lldbhas to be present on the machine running the tests. How it gets there differs by platform.How
lldbis provisioned per platformlldbis baked intoclickhouse/fasttestandclickhouse/test-base. The LLVM apt repo is already configured for the matchingLLVM_VERSIONin both Dockerfiles, so this is a singleapt-get install --yes lldb-${LLVM_VERSION}, a/usr/bin/lldbsymlink, andchmod u+s, mirroring the existinggdbsetup. The suid bit is the point: the Fast test job runs its container unprivileged (docker run --user $(id -u):$(id -g)), so a runtimeapt-get install lldbcannot work there (no root), and attaching to the server withptraceneeds the elevated privilege that the setuidlldbprovides. Every test image ultimately depends on one of these two —stateless-test,integration/runner,integration/base, andperformance-comparisoninherit fromtest-base;cctoolsfromfasttest.lldbis provided at runtime by_ensure_lldb_installedintests/clickhouse-test, which runsbrew install llvmand prepends the keg-onlyopt/llvm/bintoPATH. That helper is macOS-only and stays.So
print_c_stacktracesgets its debugger from the image on Linux and from Homebrew on macOS, and producesc_stacktraces.logon both.gdbis intentionally left in place. It is still driven directly by the fuzzer (ci/jobs/scripts/fuzzer/run-fuzzer.sh), perf comparison (ci/jobs/scripts/perf/compare.sh), unit tests (ci/jobs/unit_tests_job.py), stress (ci/jobs/scripts/stress/stress.py), the upgrade runner (tests/docker_scripts/upgrade_runner.sh), and the integration test harness. Migrating those tolldbis out of scope.Related: #112058
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):