You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2026/09/28 13:27:11 UTC

(pulsar) 07/16: [improve][test] Read the usage of Docker's disk through Docker in configure-perf-test-environment.sh

This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch lh-perf-agents-guide-links
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit bcc14019b957c75d4af1978e447c8cae0a3def1e
Author: Lari Hotari <lh...@apache.org>
AuthorDate: Mon Sep 28 11:35:38 2026 +0300

    [improve][test] Read the usage of Docker's disk through Docker in configure-perf-test-environment.sh
    
    Always read how full Docker's disk is with df in a container, whose root file system is on the same disk as Docker's
    data and the bookies' ledgers, instead of from Docker's data directory on the host, which isn't there when Docker
    runs in a virtual machine. docker info only names the data directory in the output.
    
    Assisted-by: Claude Code (claude-opus-5-5)
---
 tests/performance/environment/README.md            | 14 ++++++------
 .../scripts/configure-perf-test-environment.sh     | 25 +++++++++-------------
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/tests/performance/environment/README.md b/tests/performance/environment/README.md
index e13974b11fb5..409b73b7e192 100644
--- a/tests/performance/environment/README.md
+++ b/tests/performance/environment/README.md
@@ -148,14 +148,14 @@ series of runs. It runs on Linux and on macOS:
 tests/performance/environment/scripts/configure-perf-test-environment.sh validate
 ```
 
-On every operating system, it checks that Docker is available and that the disk that holds Docker's data is less
-than 90 % full. When Docker's data directory isn't on the host, as with Docker in a virtual machine on macOS, it reads
-the disk's usage in a container of the `alpine` image, whose root file system is on the same disk as Docker's data;
-`DISK_CHECK_IMAGE` sets another image. On Linux, it also checks the host's configuration: that the host is on AC
-power, that the `performance-testing` profile is active with `thermald` (and `com.system76.PowerDaemon.service` on
+On every operating system, it checks that Docker is available and that the disk that holds Docker's data is less than
+90 % full. It reads the disk's usage through Docker, with `df` in a container of the `alpine` image, whose root file
+system is on the same disk as Docker's data, as the bookies' ledgers are, also when Docker runs in a virtual machine, as
+on macOS; `DISK_CHECK_IMAGE` sets another image. On Linux, it also checks the host's configuration: that the host is on
+AC power, that the `performance-testing` profile is active with `thermald` (and `com.system76.PowerDaemon.service` on
 Pop!_OS) stopped, and the settings the profile applies: turbo, the CPU frequency governor, swapping, perf events and
-Transparent Huge Pages. It runs every check, prints each one to stdout as `ok:`, `FAILED:` or `skipped:`, and the
-reason for each failed check, with what to do about it, to stderr.
+Transparent Huge Pages. It runs every check, prints each one to stdout as `ok:`, `FAILED:` or `skipped:`, and the reason
+for each failed check, with what to do about it, to stderr.
 
 Its exit code tells the kinds of checks that failed apart, and is their sum when several kinds failed, such as 10 when
 Docker's disk is too full and the host isn't configured:
diff --git a/tests/performance/environment/scripts/configure-perf-test-environment.sh b/tests/performance/environment/scripts/configure-perf-test-environment.sh
index 1feba61eaa1a..15a77303ebf1 100755
--- a/tests/performance/environment/scripts/configure-perf-test-environment.sh
+++ b/tests/performance/environment/scripts/configure-perf-test-environment.sh
@@ -56,8 +56,7 @@ DOCKER_LOG_OPTIONS='{"max-size": "100m", "max-file": "3"}'
 # BookKeeper's diskUsageWarnThreshold, bookies switch to read-only mode at 95 % by default. "start"
 # warns and "validate" fails when the disk that holds Docker's data is this full.
 DISK_USAGE_LIMIT_PERCENT=90
-# Where Docker's data directory isn't on the host, such as with Docker in a virtual machine on
-# macOS, the disk's usage is read in a container of this image
+# The image of the container in which the usage of Docker's disk is read
 DISK_CHECK_IMAGE="${DISK_CHECK_IMAGE:-alpine}"
 # The exit codes of "validate", added up when several kinds of checks failed; 1 is left for usage
 # and unexpected errors
@@ -454,20 +453,16 @@ check_ac_power() {
     fi
 }
 
-# Prints the directory of Docker's data and how full its disk is, in percent. When the directory
-# isn't on the host, as with Docker in a virtual machine, it reads the usage of a container's root
-# file system, which is on the same disk as Docker's data, as the bookies' ledgers are.
+# Prints how full the disk of Docker's data is, in percent, and Docker's data directory. The usage is
+# read through Docker rather than from the host, whose file system doesn't have Docker's data when
+# Docker runs in a virtual machine, as on macOS: a container's root file system is on the same disk
+# as Docker's data, as the bookies' ledgers are.
 docker_disk_usage() {
     local docker_root usage
     docker_root="$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || true)"
-    docker_root="${docker_root:-/var/lib/docker}"
-    if [[ -d "${docker_root}" ]]; then
-        usage="$(df -P "${docker_root}" | awk 'NR == 2 { sub("%", "", $5); print $5 }')"
-    else
-        usage="$(docker run --rm "${DISK_CHECK_IMAGE}" df -P / 2>/dev/null \
-            | awk 'NR == 2 { sub("%", "", $5); print $5 }')" || return 1
-        docker_root="${docker_root}, read in a container"
-    fi
+    docker_root="${docker_root:-Docker data directory}"
+    usage="$(docker run --rm "${DISK_CHECK_IMAGE}" df -P / 2>/dev/null \
+        | awk 'NR == 2 { sub("%", "", $5); print $5 }')" || return 1
     [[ "${usage}" =~ ^[0-9]+$ ]] || return 1
     echo "${usage} ${docker_root}"
 }
@@ -689,8 +684,8 @@ validate_disk_space() {
         return
     fi
     if ! read -r usage docker_root < <(docker_disk_usage); then
-        check_failed "Docker's disk usage can be read" "Docker's data directory isn't on the host, and a container\
- of the ${DISK_CHECK_IMAGE} image couldn't read its disk's usage."
+        check_failed "Docker's disk usage can be read" "A container of the ${DISK_CHECK_IMAGE} image couldn't read\
+ the usage of Docker's disk. Check that the image can be pulled, or set DISK_CHECK_IMAGE to an image that has df."
         return
     fi
     failure_exit_code=${EXIT_DOCKER_DISK}