mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-01 13:44:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d46cd7dd41 |
@@ -81,6 +81,27 @@ Ansible-shaped hook (replace `/path/to/ansible` and the inventory group; the `co
|
||||
|
||||
For the quick A/B rig use the `HOTPATH_AB_*` names.
|
||||
|
||||
### Managed cluster acceptance
|
||||
|
||||
For a dedicated Linux test cluster, add the following flags to the ABBA command with an existing deploy hook and a fresh output directory.
|
||||
|
||||
```bash
|
||||
--cluster-lock-file /path/to/lab/cluster.lock \
|
||||
--restore-hook ./restore-test-cluster.sh \
|
||||
--hook-timeout-secs 180 \
|
||||
--node-ssh-target node-a=bench-node-a \
|
||||
--node-queue-devices node-a=nvme1n1+nvme2n1 \
|
||||
--node-queue-timeout-secs 60 \
|
||||
--workload 'put-32kib|put|32KiB' \
|
||||
--drive-sync 'sync-on|true'
|
||||
```
|
||||
|
||||
Repeat the SSH target and device mapping for every node. Specify the Linux kernel device names of the benchmark volumes. With the queue check enabled, each PUT attempt waits for two consecutive rounds of parallel five-second sampling. Each node must have mean queue depth at most 0.25 and no listed device above 0.75. Queue depth uses the change in weighted I/O milliseconds divided by elapsed monotonic milliseconds. Each attempt records the collected samples in its cell's `node_telemetry/queue_*.tsv`. An unavailable node, invalid counter or timeout fails the attempt before Warp starts. The ABBA drift and regression budgets still apply. [Linux block device counters](https://docs.kernel.org/admin-guide/iostats.html)
|
||||
|
||||
Use the same persistent lock file for cooperating commands on the same controller. An occupied lock makes the runner exit before deployment. Keep the lock file in place so every command locks the same inode. The controller runs the restore hook once after any deployment attempt, including a failed deploy, interrupted workload or failed gate. The hook receives `HOTPATH_ABBA_DATASET_NAMESPACE` and `HOTPATH_ABBA_OUT_DIR`. It owns the site-specific cleanup and must reconcile partially completed remote deployment, restore services and verify readiness before returning. Use bounded, synchronous hooks on the controller. The runner stops the active controller process group before restoration, holds the lock through restoration and records `restore.log` and `restore.status`. Managed runs require `flock` and a `timeout` implementation supporting `--foreground` and `--kill-after`.
|
||||
|
||||
For diagnostic PUT runs using `--service-prometheus-query-url`, add `--require-rename-rank-metrics` after enabling PUT stage metrics and warming that deployment. The service snapshots must include `rustfs_s3_put_object_rename_disk_wait_completion_ms_count` for both `position="quorum_first"` and `position="quorum_tail"`. Each group must advance across the attempt without series resets or changes in membership. Use the existing query or service-name filter to scope snapshots to the benchmark service. These counters describe completion order. Per-request attribution also needs a join with the coordinator's ACK decision.
|
||||
|
||||
## Quick A/B (`run_hotpath_warp_ab.sh`)
|
||||
|
||||
```bash
|
||||
|
||||
@@ -22,6 +22,12 @@ BASELINE_REVISION="unknown"
|
||||
CANDIDATE_REVISION="unknown"
|
||||
ENDPOINT=""
|
||||
DEPLOY_HOOK=""
|
||||
CLUSTER_LOCK_FILE=""
|
||||
RESTORE_HOOK=""
|
||||
HOOK_TIMEOUT_SECS=180
|
||||
NODE_QUEUE_DEVICES=()
|
||||
NODE_QUEUE_TIMEOUT_SECS=60
|
||||
REQUIRE_RENAME_RANK_METRICS=false
|
||||
HEALTH_PATH="/health"
|
||||
ADDRESS="127.0.0.1:9000"
|
||||
DATA_ROOT="/tmp/rustfs-hotpath-abba"
|
||||
@@ -103,6 +109,17 @@ Production / cluster mode:
|
||||
The hook must deploy the selected binary, reset or
|
||||
provision HOTPATH_ABBA_BUCKET for the requested
|
||||
mode, then write a non-empty evidence file.
|
||||
--cluster-lock-file <path> Reserve this cluster on the controller using flock.
|
||||
--restore-hook <path> Executable run once after deployment starts, even on
|
||||
failure or interruption. Requires --cluster-lock-file.
|
||||
--hook-timeout-secs <n> Bound managed deploy and restore hooks (default 180).
|
||||
--node-queue-devices <node=dev+dev>
|
||||
Wait for two quiet 5s windows before each PUT attempt.
|
||||
--node-queue-timeout-secs <n>
|
||||
Bound the cluster queue wait (default 60).
|
||||
--require-rename-rank-metrics
|
||||
Require both rename completion ranks to advance in
|
||||
each PUT attempt's service metrics.
|
||||
--allow-unmanaged-external Preserve legacy external mode without a deploy
|
||||
hook. Its output is not formal ABBA evidence.
|
||||
--after-probe Enable per-round PUT HEAD/GET/hash verification.
|
||||
@@ -214,6 +231,12 @@ while [[ $# -gt 0 ]]; do
|
||||
--candidate-revision) CANDIDATE_REVISION="$2"; shift 2 ;;
|
||||
--endpoint) ENDPOINT="$2"; shift 2 ;;
|
||||
--deploy-hook) DEPLOY_HOOK="$2"; shift 2 ;;
|
||||
--cluster-lock-file) CLUSTER_LOCK_FILE="$2"; shift 2 ;;
|
||||
--restore-hook) RESTORE_HOOK="$2"; shift 2 ;;
|
||||
--hook-timeout-secs) HOOK_TIMEOUT_SECS="$2"; shift 2 ;;
|
||||
--node-queue-devices) NODE_QUEUE_DEVICES+=("$2"); shift 2 ;;
|
||||
--node-queue-timeout-secs) NODE_QUEUE_TIMEOUT_SECS="$2"; shift 2 ;;
|
||||
--require-rename-rank-metrics) REQUIRE_RENAME_RANK_METRICS=true; shift ;;
|
||||
--health-path) HEALTH_PATH="$2"; shift 2 ;;
|
||||
--address) ADDRESS="$2"; shift 2 ;;
|
||||
--data-root) DATA_ROOT="$2"; shift 2 ;;
|
||||
@@ -298,6 +321,38 @@ if [[ -n "$ENDPOINT" ]]; then
|
||||
[[ -n "$DEPLOY_HOOK" ]] || log "warning: unmanaged external mode does not establish binary or data isolation and is not formal ABBA evidence"
|
||||
fi
|
||||
|
||||
if (("${#NODE_QUEUE_DEVICES[@]}")); then
|
||||
[[ "$EXTERNAL" == true && -n "$DEPLOY_HOOK" ]] || die "node queue checks require a managed endpoint with --deploy-hook"
|
||||
queue_args=(--validate-only --timeout-secs "$NODE_QUEUE_TIMEOUT_SECS")
|
||||
for entry in "${NODE_QUEUE_DEVICES[@]}"; do queue_args+=(--devices "$entry"); done
|
||||
for entry in "${NODE_SSH_TARGETS[@]}"; do queue_args+=(--target "$entry"); done
|
||||
"$PROJECT_ROOT/scripts/wait_cluster_disk_queue.sh" "${queue_args[@]}"
|
||||
fi
|
||||
if [[ "$REQUIRE_RENAME_RANK_METRICS" == true ]]; then
|
||||
[[ -n "$SERVICE_PROMETHEUS_QUERY_URL" ]] || die "rename rank checks require --service-prometheus-query-url"
|
||||
fi
|
||||
if (("${#NODE_QUEUE_DEVICES[@]}")) || [[ "$REQUIRE_RENAME_RANK_METRICS" == true ]]; then
|
||||
for spec in "${WORKLOADS[@]}"; do
|
||||
IFS='|' read -r _ mode _ <<<"$spec"
|
||||
[[ "$mode" == put ]] || die "node queue and rename rank checks require a PUT-only workload matrix"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -n "$CLUSTER_LOCK_FILE" || -n "$RESTORE_HOOK" ]]; then
|
||||
[[ "$EXTERNAL" == true && -n "$DEPLOY_HOOK" && -n "$CLUSTER_LOCK_FILE" && -n "$RESTORE_HOOK" ]] ||
|
||||
die "managed cluster runs require --endpoint, --deploy-hook, --cluster-lock-file and --restore-hook"
|
||||
[[ "$RESTORE_HOOK" == */* && -f "$RESTORE_HOOK" && -x "$RESTORE_HOOK" ]] ||
|
||||
die "--restore-hook must be an executable file path"
|
||||
validate_positive_int "$HOOK_TIMEOUT_SECS" "--hook-timeout-secs"
|
||||
if [[ "$DRY_RUN" != true ]]; then
|
||||
command -v flock >/dev/null && command -v timeout >/dev/null || die "managed cluster runs require flock and timeout"
|
||||
exec 9>>"$CLUSTER_LOCK_FILE"
|
||||
flock -n 9 || die "cluster lock is busy: $CLUSTER_LOCK_FILE"
|
||||
mkdir -p -- "$(dirname -- "$OUT_DIR")"
|
||||
mkdir -- "$OUT_DIR" || die "managed cluster runs require a fresh --out-dir"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
SERVER_LOG_DIR="$OUT_DIR/server-logs"
|
||||
DEPLOY_EVIDENCE_DIR="$OUT_DIR/deploy-evidence"
|
||||
@@ -319,7 +374,66 @@ tear_down() {
|
||||
run kill "$SERVER_PID" 2>/dev/null || true
|
||||
SERVER_PID=""
|
||||
}
|
||||
trap tear_down EXIT INT TERM
|
||||
ACTIVE_PID=""
|
||||
RESTORE_NEEDED=false
|
||||
|
||||
stop_active() {
|
||||
[[ -n "$ACTIVE_PID" ]] || return 0
|
||||
local i
|
||||
kill -TERM -- "-$ACTIVE_PID" 2>/dev/null || kill -TERM "$ACTIVE_PID" 2>/dev/null || true
|
||||
for ((i=0; i<5; i++)); do
|
||||
kill -0 -- "-$ACTIVE_PID" 2>/dev/null || break
|
||||
sleep 1
|
||||
done
|
||||
kill -KILL -- "-$ACTIVE_PID" 2>/dev/null || true
|
||||
wait "$ACTIVE_PID" 2>/dev/null || true
|
||||
ACTIVE_PID=""
|
||||
}
|
||||
|
||||
run_managed() {
|
||||
if [[ -z "$CLUSTER_LOCK_FILE" || "$DRY_RUN" == true ]]; then
|
||||
run "$@"
|
||||
return $?
|
||||
fi
|
||||
local status=0
|
||||
# Give benchmark and hook descendants a process group we can stop before
|
||||
# restoring the cluster. Only the controller holds the lock descriptor.
|
||||
set -m
|
||||
"$@" 9>&- &
|
||||
ACTIVE_PID=$!
|
||||
set +m
|
||||
wait "$ACTIVE_PID" || status=$?
|
||||
if kill -0 -- "-$ACTIVE_PID" 2>/dev/null; then
|
||||
log "stopping remaining controller processes before restore"
|
||||
stop_active
|
||||
if ((status == 0)); then status=1; fi
|
||||
fi
|
||||
ACTIVE_PID=""
|
||||
return "$status"
|
||||
}
|
||||
|
||||
finish() {
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
trap '' INT TERM
|
||||
stop_active
|
||||
tear_down
|
||||
if [[ "$RESTORE_NEEDED" == true ]]; then
|
||||
log "restore hook: $DATASET_NAMESPACE"
|
||||
local restore_status=0
|
||||
HOTPATH_ABBA_DATASET_NAMESPACE="$DATASET_NAMESPACE" HOTPATH_ABBA_OUT_DIR="$OUT_DIR" \
|
||||
timeout --kill-after=5s "${HOOK_TIMEOUT_SECS}s" "$RESTORE_HOOK" 9>&- >"$OUT_DIR/restore.log" 2>&1 || restore_status=$?
|
||||
printf "exit_code=%s\n" "$restore_status" >"$OUT_DIR/restore.status"
|
||||
if ((restore_status != 0)); then
|
||||
log "restore hook failed; see $OUT_DIR/restore.log"
|
||||
if ((status == 0)); then status=1; fi
|
||||
fi
|
||||
fi
|
||||
exit "$status"
|
||||
}
|
||||
trap finish EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
dump_server_log() {
|
||||
[[ -n "$SERVER_LOG" && -f "$SERVER_LOG" ]] || return 0
|
||||
@@ -330,19 +444,24 @@ dump_server_log() {
|
||||
|
||||
wait_health() {
|
||||
[[ "$DRY_RUN" == "true" ]] && return 0
|
||||
local i
|
||||
for ((i = 0; i < HEALTH_TIMEOUT_SECS; i++)); do
|
||||
local i remaining curl_timeout health_url="$ADDRESS" deadline=$((SECONDS+HEALTH_TIMEOUT_SECS))
|
||||
case "$health_url" in http://*|https://*) ;; *) health_url="http://$health_url";; esac
|
||||
while ((SECONDS < deadline)); do
|
||||
i=$((HEALTH_TIMEOUT_SECS - (deadline - SECONDS)))
|
||||
if [[ "$EXTERNAL" != "true" && -n "$SERVER_PID" ]] && ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
||||
echo "error: rustfs server (pid $SERVER_PID) exited before becoming healthy after ${i}s" >&2
|
||||
dump_server_log
|
||||
return 1
|
||||
fi
|
||||
if curl -fsS "http://${ADDRESS}${HEALTH_PATH}" >/dev/null 2>&1; then
|
||||
remaining=$((deadline - SECONDS))
|
||||
((remaining > 0)) || break
|
||||
curl_timeout=$((remaining < 5 ? remaining : 5))
|
||||
if curl -fsS --max-time "$curl_timeout" "${health_url%/}${HEALTH_PATH}" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "error: endpoint http://${ADDRESS}${HEALTH_PATH} did not become healthy within ${HEALTH_TIMEOUT_SECS}s" >&2
|
||||
echo "error: endpoint ${health_url%/}${HEALTH_PATH} did not become healthy within ${HEALTH_TIMEOUT_SECS}s" >&2
|
||||
dump_server_log
|
||||
return 1
|
||||
}
|
||||
@@ -382,8 +501,13 @@ bring_up() {
|
||||
local binary_sha
|
||||
binary_sha="$(sha256_file "$bin")"
|
||||
[[ "$binary_sha" != "unknown" ]] || die "cannot attest external binary without a SHA-256 tool"
|
||||
local hook_cmd=(bash -c "$DEPLOY_HOOK")
|
||||
if [[ -n "$RESTORE_HOOK" && "$DRY_RUN" != true ]]; then
|
||||
RESTORE_NEEDED=true
|
||||
hook_cmd=(timeout --foreground --kill-after=5s "${HOOK_TIMEOUT_SECS}s" "${hook_cmd[@]}")
|
||||
fi
|
||||
HOTPATH_ABBA_LEG="$leg" HOTPATH_ABBA_PHASE="$phase" HOTPATH_ABBA_BINARY="$bin" HOTPATH_ABBA_BINARY_SHA256="$binary_sha" HOTPATH_ABBA_DRIVE_SYNC="$drive_sync" HOTPATH_ABBA_WORKLOAD="$workload" HOTPATH_ABBA_MODE="$mode" HOTPATH_ABBA_SIZE="$size" HOTPATH_ABBA_CELL_ID="$sync_label/$workload/$leg" HOTPATH_ABBA_DATASET_NAMESPACE="$DATASET_NAMESPACE" HOTPATH_ABBA_BUCKET="$bucket" HOTPATH_ABBA_DEPLOY_EVIDENCE_FILE="$evidence_file" \
|
||||
run bash -c "$DEPLOY_HOOK"
|
||||
run_managed "${hook_cmd[@]}"
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
[[ -s "$evidence_file" ]] || die "deploy hook did not write evidence for $sync_label/$workload/$leg: $evidence_file"
|
||||
[[ "$(awk -F= '$1=="leg" {print substr($0, length($1) + 2)}' "$evidence_file")" == "$leg" ]] || die "deploy evidence leg does not match $sync_label/$workload/$leg"
|
||||
@@ -465,6 +589,11 @@ measure() {
|
||||
args+=(--require-node-telemetry)
|
||||
fi
|
||||
args+=(--node-ssh-timeout-secs "$NODE_SSH_TIMEOUT_SECS")
|
||||
if (("${#NODE_QUEUE_DEVICES[@]}")); then
|
||||
args+=(--node-queue-timeout-secs "$NODE_QUEUE_TIMEOUT_SECS")
|
||||
for node_target in "${NODE_QUEUE_DEVICES[@]}"; do args+=(--node-queue-devices "$node_target"); done
|
||||
fi
|
||||
[[ "$REQUIRE_RENAME_RANK_METRICS" != true ]] || args+=(--require-rename-rank-metrics)
|
||||
if [[ -n "$SERVICE_PROMETHEUS_QUERY_URL" ]]; then
|
||||
args+=(--service-prometheus-query-url "$SERVICE_PROMETHEUS_QUERY_URL" --service-metrics-dir "$cell/service_metrics")
|
||||
[[ -n "$SERVICE_PROMETHEUS_QUERY" ]] && args+=(--service-prometheus-query "$SERVICE_PROMETHEUS_QUERY")
|
||||
@@ -478,9 +607,8 @@ measure() {
|
||||
args+=(--extra-args "--objects $((CONCURRENCY * DATASET_OBJECTS_PER_WORKER)) --noclear")
|
||||
fi
|
||||
[[ -n "$baseline_csv" ]] && args+=(--baseline-csv "$baseline_csv")
|
||||
# Command substitution may clear errexit; emit a cell path only after success.
|
||||
run "$ENHANCED_BENCH" "${args[@]}" >&2 || return $?
|
||||
echo "$cell"
|
||||
run_managed "$ENHANCED_BENCH" "${args[@]}" >&2 || return $?
|
||||
MEASURE_CELL="$cell"
|
||||
}
|
||||
|
||||
write_schedule_header() {
|
||||
@@ -571,6 +699,12 @@ external_isolation=$(isolation_mode)
|
||||
evidence_mode=$(evidence_mode)
|
||||
formal_evidence=$(formal_evidence)
|
||||
performance_conclusion=$(performance_conclusion)
|
||||
cluster_lock_enabled=$([[ -n "$CLUSTER_LOCK_FILE" ]] && echo true || echo false)
|
||||
restore_hook_enabled=$([[ -n "$RESTORE_HOOK" ]] && echo true || echo false)
|
||||
hook_timeout_secs=$HOOK_TIMEOUT_SECS
|
||||
node_queue_device_mappings=${#NODE_QUEUE_DEVICES[@]}
|
||||
node_queue_timeout_secs=$NODE_QUEUE_TIMEOUT_SECS
|
||||
require_rename_rank_metrics=$REQUIRE_RENAME_RANK_METRICS
|
||||
after_probe=$AFTER_PROBE
|
||||
node_docker_container_count=${#NODE_DOCKER_CONTAINERS[@]}
|
||||
node_ssh_target_count=${#NODE_SSH_TARGETS[@]}
|
||||
@@ -615,7 +749,8 @@ for ds_spec in "${DRIVE_SYNC_MATRIX[@]}"; do
|
||||
baseline_csv="$OUT_DIR/$workload/$sync_label/A1/median_summary.csv"
|
||||
fi
|
||||
|
||||
cell="$(measure "$leg" "$workload" "$mode" "$size" "$sync_label" "$bucket" "$baseline_csv")" || exit $?
|
||||
measure "$leg" "$workload" "$mode" "$size" "$sync_label" "$bucket" "$baseline_csv" || exit $?
|
||||
cell="$MEASURE_CELL"
|
||||
case "$leg" in
|
||||
B1|B2)
|
||||
CANDIDATE_COMPARE_CSVS+=("$cell/baseline_compare.csv")
|
||||
|
||||
@@ -68,6 +68,9 @@ NODE_SSH_IDENTITY_FILE=""
|
||||
NODE_SSH_TIMEOUT_SECS=30
|
||||
REQUIRE_NODE_TELEMETRY=false
|
||||
NODE_TELEMETRY_FAILED=false
|
||||
NODE_QUEUE_DEVICES=()
|
||||
NODE_QUEUE_TIMEOUT_SECS=60
|
||||
REQUIRE_RENAME_RANK_METRICS=false
|
||||
AFTER_PROBE=false
|
||||
AFTER_PROBE_DIR=""
|
||||
STORAGE_QUIESCENCE_CONTAINER=""
|
||||
@@ -155,6 +158,12 @@ Enhanced options:
|
||||
Optional SSH private key used for node telemetry
|
||||
--node-ssh-timeout-secs <n> Bound each remote telemetry command (default 30)
|
||||
--require-node-telemetry Mark a round failed when any node snapshot fails
|
||||
--node-queue-devices <node=dev+dev>
|
||||
Wait for low queue depth on these Linux devices
|
||||
across all SSH nodes before each Warp PUT attempt
|
||||
--node-queue-timeout-secs <n> Bound the cluster queue wait (default: 60)
|
||||
--require-rename-rank-metrics Require both rename completion ranks to advance
|
||||
in the before/after service metrics snapshots
|
||||
--storage-quiescence-container <container>
|
||||
Require a quiet storage/writeback window from this container
|
||||
--storage-quiescence-docker-context <context>
|
||||
@@ -283,6 +292,9 @@ parse_args() {
|
||||
--node-ssh-identity-file) NODE_SSH_IDENTITY_FILE="$2"; shift 2 ;;
|
||||
--node-ssh-timeout-secs) NODE_SSH_TIMEOUT_SECS="$2"; shift 2 ;;
|
||||
--require-node-telemetry) REQUIRE_NODE_TELEMETRY=true; shift ;;
|
||||
--node-queue-devices) NODE_QUEUE_DEVICES+=("$2"); shift 2 ;;
|
||||
--node-queue-timeout-secs) NODE_QUEUE_TIMEOUT_SECS="$2"; shift 2 ;;
|
||||
--require-rename-rank-metrics) REQUIRE_RENAME_RANK_METRICS=true; shift ;;
|
||||
--storage-quiescence-container) STORAGE_QUIESCENCE_CONTAINER="$2"; shift 2 ;;
|
||||
--storage-quiescence-docker-context) STORAGE_QUIESCENCE_DOCKER_CONTEXT="$2"; shift 2 ;;
|
||||
--storage-quiescence-consecutive) STORAGE_QUIESCENCE_CONSECUTIVE="$2"; shift 2 ;;
|
||||
@@ -501,6 +513,20 @@ validate_args() {
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if ((${#NODE_QUEUE_DEVICES[@]})); then
|
||||
if [[ "$TOOL" != warp || "$WARP_MODE" != put || -n "$STORAGE_QUIESCENCE_CONTAINER" ]]; then
|
||||
echo "ERROR: node queue checks require Warp PUT and cannot be combined with Docker quiescence" >&2
|
||||
exit 1
|
||||
fi
|
||||
cluster_queue --validate-only
|
||||
fi
|
||||
if [[ "$REQUIRE_RENAME_RANK_METRICS" == true ]] && {
|
||||
[[ "$TOOL" != warp || "$WARP_MODE" != put ]] ||
|
||||
[[ -z "$SERVICE_METRICS_URL" && -z "$SERVICE_PROMETHEUS_QUERY_URL" ]];
|
||||
}; then
|
||||
echo "ERROR: rename rank checks require Warp PUT and service metrics capture" >&2
|
||||
exit 1
|
||||
fi
|
||||
validate_manifest_value "$SERVER_IMAGE_REF" "--server-image-ref"
|
||||
validate_manifest_value "$SERVER_IMAGE_DIGEST" "--server-image-digest"
|
||||
validate_manifest_value "$SERVER_REVISION" "--server-revision"
|
||||
@@ -635,6 +661,9 @@ EOF
|
||||
echo "node_ssh_timeout_secs=${NODE_SSH_TIMEOUT_SECS}"
|
||||
echo "require_node_telemetry=${REQUIRE_NODE_TELEMETRY}"
|
||||
echo "after_probe=${AFTER_PROBE}"
|
||||
echo "node_queue_device_mappings=${#NODE_QUEUE_DEVICES[@]}"
|
||||
echo "node_queue_timeout_secs=$NODE_QUEUE_TIMEOUT_SECS"
|
||||
echo "require_rename_rank_metrics=$REQUIRE_RENAME_RANK_METRICS"
|
||||
echo "storage_quiescence_container=${STORAGE_QUIESCENCE_CONTAINER:-N/A}"
|
||||
echo "storage_quiescence_docker_context=${STORAGE_QUIESCENCE_DOCKER_CONTEXT:-N/A}"
|
||||
echo "storage_quiescence_consecutive=${STORAGE_QUIESCENCE_CONSECUTIVE}"
|
||||
@@ -643,6 +672,49 @@ EOF
|
||||
} >>"$manifest_file"
|
||||
}
|
||||
|
||||
cluster_queue() {
|
||||
local entry
|
||||
local args=(--timeout-secs "$NODE_QUEUE_TIMEOUT_SECS" --identity-file "$NODE_SSH_IDENTITY_FILE")
|
||||
for entry in "${NODE_SSH_TARGETS[@]}"; do args+=(--target "$entry"); done
|
||||
for entry in "${NODE_QUEUE_DEVICES[@]}"; do args+=(--devices "$entry"); done
|
||||
"$SCRIPT_DIR/wait_cluster_disk_queue.sh" "${args[@]}" "$@"
|
||||
}
|
||||
|
||||
check_rename_rank_metrics() {
|
||||
local size="$1" round="$2" attempt="$3" phase="$4" token
|
||||
[[ "$REQUIRE_RENAME_RANK_METRICS" == true && "$DRY_RUN" != true ]] || return 0
|
||||
token=$(metric_snapshot_token "$size" "$round" "$attempt")
|
||||
local snapshots=("$SERVICE_METRICS_DIR/${token}_before.prom")
|
||||
if [[ "$phase" == after ]]; then snapshots+=("$SERVICE_METRICS_DIR/${token}_after.prom"); fi
|
||||
if ! LC_ALL=C awk '
|
||||
/^rustfs_s3_put_object_rename_disk_wait_completion_ms_count\{/ {
|
||||
close_at=match($0,/\}[[:space:]]+/)
|
||||
if (!close_at) next
|
||||
series=substr($0,1,close_at)
|
||||
if (series ~ /[{,]position="quorum_first"[,}]/) rank="first"
|
||||
else if (series ~ /[{,]position="quorum_tail"[,}]/) rank="tail"
|
||||
else next
|
||||
split(substr($0,close_at+RLENGTH),fields,/[[:space:]]+/)
|
||||
if (fields[1] !~ /^[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?$/) { bad=1; next }
|
||||
if (FILENAME==ARGV[1]) {
|
||||
if (series in before) bad=1
|
||||
before[series]=fields[1]+0
|
||||
present[rank]=1
|
||||
} else {
|
||||
if (!(series in before) || seen[series]++ || fields[1]+0 < before[series]) bad=1
|
||||
else if (fields[1]+0 > before[series]) grew[rank]=1
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (ARGC>2) for (series in before) if (!seen[series]) bad=1
|
||||
exit (bad || !present["first"] || !present["tail"] || (ARGC>2 && (!grew["first"] || !grew["tail"])))
|
||||
}
|
||||
' "${snapshots[@]}"; then
|
||||
echo "ERROR: incomplete rename rank metrics for $size round=$round attempt=$attempt phase=$phase" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_storage_quiescence() {
|
||||
local size="$1" round="$2" attempt="$3" output_file
|
||||
if [[ -z "$STORAGE_QUIESCENCE_CONTAINER" ]]; then
|
||||
@@ -1254,7 +1326,7 @@ capture_round_node_telemetry() {
|
||||
echo "$size,$TOOL,$round,$attempt,$phase,$node,$host,not_run_dry_run,$snapshot_file" >>"$NODE_SSH_CSV"
|
||||
continue
|
||||
fi
|
||||
if timeout "$NODE_SSH_TIMEOUT_SECS" ssh "${ssh_args[@]}" "$host" 'set -u
|
||||
if timeout --foreground --kill-after=1s "$NODE_SSH_TIMEOUT_SECS" ssh "${ssh_args[@]}" "$host" 'set -u
|
||||
pid="$(pgrep -o -f /usr/local/bin/rustfs || true)"
|
||||
echo "captured_at_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "pid=${pid:-N/A}"
|
||||
@@ -1412,6 +1484,19 @@ run_one_attempt() {
|
||||
capture_round_node_telemetry "$size" "$round" "$attempt" before
|
||||
|
||||
if [[ "$TOOL" == "warp" ]]; then
|
||||
if ! check_rename_rank_metrics "$size" "$round" "$attempt" before || {
|
||||
[[ "$DRY_RUN" != true ]] && ((${#NODE_QUEUE_DEVICES[@]})) &&
|
||||
! cluster_queue >"$OUT_DIR/node_telemetry/queue_${size}_r${round}_a${attempt}.tsv";
|
||||
}; then
|
||||
finished_at_utc="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
: >"$log_file"
|
||||
echo "$size,$TOOL,$round,$attempt,$CONCURRENCY,failed,1,$started_at_utc,$finished_at_utc,N/A,N/A,N/A,N/A,N/A,$log_file,N/A,N/A,N/A,N/A" >> "$ROUND_CSV"
|
||||
echo "failed"
|
||||
return
|
||||
fi
|
||||
if [[ "$DRY_RUN" != true ]] && ((${#NODE_QUEUE_DEVICES[@]})); then
|
||||
started_at_utc="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
fi
|
||||
local warp_host bucket
|
||||
warp_host="$(normalize_warp_host "$ENDPOINT")"
|
||||
bucket="$(bucket_for_size "$size")"
|
||||
@@ -1431,6 +1516,7 @@ run_one_attempt() {
|
||||
if [[ "$AFTER_PROBE" == "true" && "$WARP_MODE" == "put" ]]; then
|
||||
cmd+=("--noclear")
|
||||
fi
|
||||
if [[ "$ENDPOINT" == https://* ]]; then cmd+=("--tls"); fi
|
||||
if [[ "$INSECURE" == "true" ]]; then
|
||||
cmd+=("--insecure")
|
||||
fi
|
||||
@@ -1494,6 +1580,10 @@ run_one_attempt() {
|
||||
status="failed"
|
||||
exit_code=1
|
||||
fi
|
||||
if [[ "$status" == ok ]] && ! check_rename_rank_metrics "$size" "$round" "$attempt" after; then
|
||||
status="failed"
|
||||
exit_code=1
|
||||
fi
|
||||
if ! capture_after_probe "$size" "$round" "$attempt"; then
|
||||
status="failed"
|
||||
exit_code=1
|
||||
|
||||
@@ -322,7 +322,7 @@ for bad_field in leg phase bucket binary_sha256 dataset_reset; do
|
||||
rg -qx 'performance_conclusion=not_claimed_gate_and_artifacts_required' "$bad_out_dir/manifest.env"
|
||||
done
|
||||
|
||||
# Exercise the actual command-substitution path with a failing load driver.
|
||||
# Exercise failure propagation with a failing load driver.
|
||||
FAILURE_REPO="$TMP_DIR/failed-driver-repo"
|
||||
mkdir -p "$FAILURE_REPO/scripts" "$FAILURE_REPO/bin"
|
||||
git init -q "$FAILURE_REPO"
|
||||
@@ -336,7 +336,14 @@ while [[ $# -gt 0 ]]; do
|
||||
fi
|
||||
shift
|
||||
done
|
||||
exit 42
|
||||
if [[ "${DRIVER_HANG:-false}" == true ]]; then
|
||||
sleep 60 &
|
||||
child=$!
|
||||
trap 'wait "$child" 2>/dev/null || true; exit 143' TERM
|
||||
printf '%s\n' "$child" > "$DRIVER_PID_FILE"
|
||||
wait "$child"
|
||||
fi
|
||||
exit "${DRIVER_STATUS:-42}"
|
||||
DRIVER
|
||||
cat >"$FAILURE_REPO/scripts/hotpath_warp_ab_gate.sh" <<'GATE'
|
||||
#!/usr/bin/env bash
|
||||
@@ -369,6 +376,8 @@ cat >"$FAILURE_REPO/deploy.sh" <<'DEPLOY'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
echo "deploy:$HOTPATH_ABBA_LEG" >>"$FAILURE_TRACE"
|
||||
if [[ "${DEPLOY_HANG:-false}" == true ]]; then exec sleep 60; fi
|
||||
if [[ "${DEPLOY_STATUS:-0}" != 0 ]]; then exit "$DEPLOY_STATUS"; fi
|
||||
cat >"$HOTPATH_ABBA_DEPLOY_EVIDENCE_FILE" <<EOF
|
||||
leg=$HOTPATH_ABBA_LEG
|
||||
phase=$HOTPATH_ABBA_PHASE
|
||||
@@ -433,4 +442,98 @@ for failure_mode in external local; do
|
||||
[[ ! -e "$FAILURE_OUT_DIR/baseline_drift_gate.md" ]]
|
||||
done
|
||||
|
||||
# Managed lifecycle checks use actual locks and process groups on Linux.
|
||||
if command -v flock >/dev/null 2>&1; then
|
||||
export MANAGED_LOCK="$TMP_DIR/cluster.lock"
|
||||
cat > "$FAILURE_REPO/restore.sh" <<'RESTORE'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
test -d "$HOTPATH_ABBA_OUT_DIR"
|
||||
test -n "$HOTPATH_ABBA_DATASET_NAMESPACE"
|
||||
if flock -n "$MANAGED_LOCK" true; then
|
||||
echo "expected the controller to still own the lock during restore" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "${DRIVER_PID_FILE:-}" && -f "$DRIVER_PID_FILE" ]]; then
|
||||
read -r pid < "$DRIVER_PID_FILE"
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
echo "the measured workload survived interruption" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo restore >> "$FAILURE_TRACE"
|
||||
exit "${RESTORE_STATUS:-0}"
|
||||
RESTORE
|
||||
chmod +x "$FAILURE_REPO/restore.sh"
|
||||
run_managed_fixture() (
|
||||
local scenario="$1"
|
||||
shift
|
||||
cd "$FAILURE_REPO"
|
||||
export PATH="$FAILURE_REPO/bin:$PATH" FAILURE_TRACE="$TMP_DIR/managed-$scenario.trace"
|
||||
if [[ -n "${RUNNER_PID_FILE:-}" ]]; then printf "%s\n" "$BASHPID" > "$RUNNER_PID_FILE"; fi
|
||||
exec "$RUNNER" --baseline-bin "$FAILURE_REPO/bin/rustfs" --candidate-bin "$FAILURE_REPO/bin/rustfs" \
|
||||
--baseline-revision baseline-test --candidate-revision candidate-test --warp-bin /usr/bin/true \
|
||||
--endpoint 'https://localhost:9000' --deploy-hook "$FAILURE_REPO/deploy.sh" \
|
||||
--cluster-lock-file "$MANAGED_LOCK" --restore-hook "$FAILURE_REPO/restore.sh" \
|
||||
--workload 'put-32kib|put|32KiB' --drive-sync 'sync-on|true' \
|
||||
--out-dir "$TMP_DIR/managed-$scenario" "$@"
|
||||
)
|
||||
|
||||
(
|
||||
exec 8>>"$MANAGED_LOCK"
|
||||
flock -n 8
|
||||
if run_managed_fixture busy >"$TMP_DIR/managed-busy.log" 2>&1; then
|
||||
echo "expected an occupied cluster lock to fail" >&2
|
||||
exit 1
|
||||
fi
|
||||
test ! -e "$TMP_DIR/managed-busy.trace"
|
||||
)
|
||||
for scenario in driver-error deploy-error success restore-error; do
|
||||
expected=0
|
||||
driver=0
|
||||
deploy=0
|
||||
restore=0
|
||||
case "$scenario" in
|
||||
driver-error) driver=42; expected=42 ;;
|
||||
deploy-error) deploy=43; expected=43 ;;
|
||||
restore-error) restore=1; expected=1 ;;
|
||||
esac
|
||||
status=0
|
||||
DRIVER_STATUS="$driver" DEPLOY_STATUS="$deploy" RESTORE_STATUS="$restore" \
|
||||
run_managed_fixture "$scenario" >"$TMP_DIR/managed-$scenario.log" 2>&1 || status=$?
|
||||
[[ "$status" == "$expected" ]]
|
||||
[[ "$(grep -cx restore "$TMP_DIR/managed-$scenario.trace")" == 1 ]]
|
||||
[[ "$(tail -1 "$TMP_DIR/managed-$scenario.trace")" == restore ]]
|
||||
grep -qx "exit_code=$restore" "$TMP_DIR/managed-$scenario/restore.status"
|
||||
if [[ "$scenario" == deploy-error ]]; then
|
||||
[[ "$(cat "$TMP_DIR/managed-$scenario.trace")" == $'deploy:A1\nrestore' ]]
|
||||
fi
|
||||
flock -n "$MANAGED_LOCK" true
|
||||
done
|
||||
|
||||
status=0
|
||||
DEPLOY_HANG=true run_managed_fixture hook-timeout --hook-timeout-secs 1 >"$TMP_DIR/managed-timeout.log" 2>&1 || status=$?
|
||||
[[ "$status" == 124 ]]
|
||||
[[ "$(cat "$TMP_DIR/managed-hook-timeout.trace")" == $'deploy:A1\nrestore' ]]
|
||||
flock -n "$MANAGED_LOCK" true
|
||||
|
||||
export DRIVER_PID_FILE="$TMP_DIR/managed-driver.pid" RUNNER_PID_FILE="$TMP_DIR/managed-runner.pid"
|
||||
DRIVER_HANG=true run_managed_fixture interrupt >"$TMP_DIR/managed-interrupt.log" 2>&1 &
|
||||
runner_pid=$!
|
||||
for ((i=0; i<500; i++)); do
|
||||
[[ -s "$DRIVER_PID_FILE" ]] && break
|
||||
kill -0 "$runner_pid" 2>/dev/null || break
|
||||
sleep 0.01
|
||||
done
|
||||
test -s "$DRIVER_PID_FILE"
|
||||
read -r controller_pid < "$RUNNER_PID_FILE"
|
||||
kill -TERM "$controller_pid"
|
||||
status=0
|
||||
wait "$runner_pid" || status=$?
|
||||
[[ "$status" == 143 ]]
|
||||
[[ "$(cat "$TMP_DIR/managed-interrupt.trace")" == $'deploy:A1\nmeasure:A1\nrestore' ]]
|
||||
! grep -q 'restore hook failed' "$TMP_DIR/managed-interrupt.log"
|
||||
flock -n "$MANAGED_LOCK" true
|
||||
fi
|
||||
|
||||
echo "hotpath warp ABBA tests passed"
|
||||
|
||||
@@ -271,4 +271,102 @@ done
|
||||
--compare-csv "${TMP_DIR}/fake-warp-zero-candidate/baseline_compare.csv" \
|
||||
--require-tail-error >/dev/null
|
||||
|
||||
GUARD_BIN="$TMP_DIR/guard-bin"
|
||||
mkdir "$GUARD_BIN"
|
||||
cat > "$GUARD_BIN/ssh" <<'SSH'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
command="${*: -1}"
|
||||
if [[ "$command" != devices=* ]]; then
|
||||
printf 'telemetry fixture\n'
|
||||
exit 0
|
||||
fi
|
||||
host="${@: -2:1}"
|
||||
marker="$GUARD_DIR/$host"
|
||||
case "${QUEUE_FIXTURE:-quiet}" in
|
||||
missing) exit 2 ;;
|
||||
hung) exec sleep 60 ;;
|
||||
reset)
|
||||
n=0
|
||||
[[ ! -f "$marker" ]] || read -r n < "$marker"
|
||||
n=$((n+1))
|
||||
printf '%s\n' "$n" > "$marker"
|
||||
if [[ "$host" == host-b && "$n" == 2 ]]; then
|
||||
echo '0.050000 0.800000'
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo '0.050000 0.070000'
|
||||
SSH
|
||||
cat > "$GUARD_BIN/curl" <<'CURL'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
first=10
|
||||
tail=3
|
||||
if [[ -e "$GUARD_DIR/warp-called" ]]; then
|
||||
first=12; tail=4
|
||||
case "${RANK_FIXTURE:-valid}" in
|
||||
reset) tail=2 ;;
|
||||
stale) tail=3 ;;
|
||||
esac
|
||||
fi
|
||||
metric=rustfs_s3_put_object_rename_disk_wait_completion_ms_count
|
||||
printf '%s{position="quorum_first"} %s\n' "$metric" "$first"
|
||||
if [[ "${RANK_FIXTURE:-valid}" != missing ]]; then
|
||||
printf '%s{position="quorum_tail"} %s\n' "$metric" "$tail"
|
||||
fi
|
||||
CURL
|
||||
cat > "$GUARD_BIN/warp" <<'WARP'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
[[ " $* " == *" --tls "* ]]
|
||||
touch "$GUARD_DIR/warp-called"
|
||||
exec "$GUARD_FAKE_WARP" "$@"
|
||||
WARP
|
||||
chmod +x "$GUARD_BIN/"*
|
||||
export GUARD_DIR="$TMP_DIR" GUARD_FAKE_WARP="$FAKE_WARP"
|
||||
guard_args=(--tool warp --warp-mode put --warp-bin "$GUARD_BIN/warp"
|
||||
--endpoint https://localhost:9000 --access-key test --secret-key fixture --sizes 32KiB
|
||||
--rounds 1 --retry-per-round 1 --retry-sleep-secs 1 --cooldown-secs 0 --duration 1s
|
||||
--node-ssh-target a=host-a --node-ssh-target b=host-b
|
||||
--node-queue-devices a=nvme0n1+nvme1n1 --node-queue-devices b=nvme0n1+nvme1n1
|
||||
--service-metrics-url http://localhost:9001/metrics --service-metrics-dir "$TMP_DIR/guard-metrics"
|
||||
--require-rename-rank-metrics)
|
||||
if ! PATH="$GUARD_BIN:$PATH" QUEUE_FIXTURE=reset "$RUNNER" "${guard_args[@]}" --out-dir "$TMP_DIR/guard-pass" >"$TMP_DIR/guard-pass.log" 2>&1; then
|
||||
cat "$TMP_DIR/guard-pass.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
test -f "$GUARD_DIR/warp-called"
|
||||
awk -F '\t' 'NR>1{last=$1; n++} END{exit !(last==4 && n==8)}' "$TMP_DIR/guard-pass/node_telemetry/queue_32KiB_r1_a1.tsv"
|
||||
rg -q ',ok,0,' "$TMP_DIR/guard-pass/round_results.csv"
|
||||
|
||||
for fixture in missing-rank reset-rank stale-rank missing-node; do
|
||||
rm -f "$GUARD_DIR/warp-called"
|
||||
if [[ "$fixture" == missing-node ]]; then
|
||||
rank=valid
|
||||
queue=missing
|
||||
else
|
||||
rank="${fixture%-rank}"
|
||||
queue=quiet
|
||||
fi
|
||||
if PATH="$GUARD_BIN:$PATH" RANK_FIXTURE="$rank" QUEUE_FIXTURE="$queue" "$RUNNER" \
|
||||
"${guard_args[@]}" --out-dir "$TMP_DIR/$fixture" >"$TMP_DIR/$fixture.log" 2>&1; then
|
||||
echo "expected $fixture to fail the round" >&2
|
||||
exit 1
|
||||
fi
|
||||
rg -q ',failed,1,' "$TMP_DIR/$fixture/round_results.csv"
|
||||
case "$fixture" in
|
||||
missing-rank|missing-node) test ! -e "$GUARD_DIR/warp-called" ;;
|
||||
*) test -f "$GUARD_DIR/warp-called" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if PATH="$GUARD_BIN:$PATH" QUEUE_FIXTURE=hung "$SCRIPT_DIR/wait_cluster_disk_queue.sh" \
|
||||
--target a=host-a --devices a=nvme0n1 --timeout-secs 11 >"$TMP_DIR/queue-timeout.log" 2>&1; then
|
||||
echo "expected an unresponsive SSH sample to time out" >&2
|
||||
exit 1
|
||||
fi
|
||||
rg -q 'failed or timed out' "$TMP_DIR/queue-timeout.log"
|
||||
|
||||
echo "object batch benchmark enhanced tests passed"
|
||||
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wait for two consecutive low-queue samples across the SSH inventory.
|
||||
set -euo pipefail
|
||||
export LC_ALL=C
|
||||
|
||||
targets=()
|
||||
mappings=()
|
||||
identity=""
|
||||
budget=60
|
||||
validate_only=false
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--validate-only) validate_only=true; shift; continue ;;
|
||||
--target|--devices|--identity-file|--timeout-secs)
|
||||
[[ $# -ge 2 ]] || { echo "missing value for $1" >&2; exit 2; }
|
||||
case "$1" in
|
||||
--target) targets+=("$2") ;;
|
||||
--devices) mappings+=("$2") ;;
|
||||
--identity-file) identity="$2" ;;
|
||||
--timeout-secs) budget="$2" ;;
|
||||
esac
|
||||
shift 2 ;;
|
||||
*) echo "unknown disk queue option: $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
if ! [[ "$budget" =~ ^[1-9][0-9]{0,5}$ ]] || ((budget < 11)); then
|
||||
echo "disk queue timeout must be at least 11 seconds" >&2
|
||||
exit 2
|
||||
fi
|
||||
(("${#targets[@]}" > 0 && "${#targets[@]}" == "${#mappings[@]}")) || { echo "disk queue check requires one device mapping per SSH target" >&2; exit 2; }
|
||||
|
||||
nodes=""
|
||||
hosts=""
|
||||
device_lists=()
|
||||
for target in "${targets[@]}"; do
|
||||
[[ "$target" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*=[A-Za-z0-9][A-Za-z0-9@._:%+-]*$ ]] || { echo "invalid disk queue SSH target" >&2; exit 2; }
|
||||
node="${target%%=*}"
|
||||
host="${target#*=}"
|
||||
[[ "$nodes" != *" $node "* ]] || { echo "duplicate disk queue node: $node" >&2; exit 2; }
|
||||
[[ "$hosts" != *" $host "* ]] || { echo "duplicate disk queue SSH host: $host" >&2; exit 2; }
|
||||
hosts="$hosts $host "
|
||||
nodes="$nodes $node "
|
||||
matches=0
|
||||
for mapping in "${mappings[@]}"; do
|
||||
[[ "${mapping%%=*}" == "$node" ]] || continue
|
||||
[[ "$mapping" =~ ^[^=]+=([A-Za-z0-9][A-Za-z0-9._-]*)(\+[A-Za-z0-9][A-Za-z0-9._-]*)*$ ]] || { echo "invalid device list for $node" >&2; exit 2; }
|
||||
devices="${mapping#*=}"
|
||||
if ! awk -v devices="$devices" 'BEGIN { n=split(devices,d,"+"); for(i=1;i<=n;i++) if(seen[d[i]]++) exit 1 }'; then
|
||||
echo "duplicate disk queue device for $node" >&2; exit 2
|
||||
fi
|
||||
device_lists+=("${devices//+/ }")
|
||||
matches=$((matches+1))
|
||||
done
|
||||
[[ "$matches" == 1 ]] || { echo "expected one device mapping for $node" >&2; exit 2; }
|
||||
done
|
||||
[[ "$validate_only" == false ]] || exit 0
|
||||
|
||||
ssh_args=(-o BatchMode=yes -o ConnectTimeout=5)
|
||||
if [[ -n "$identity" ]]; then ssh_args+=(-i "$identity"); fi
|
||||
artifacts=$(mktemp -d)
|
||||
pids=()
|
||||
cleanup() {
|
||||
local pid
|
||||
if ((${#pids[@]})); then
|
||||
kill -TERM "${pids[@]}" 2>/dev/null || true
|
||||
for pid in "${pids[@]}"; do wait "$pid" 2>/dev/null || true; done
|
||||
fi
|
||||
rm -rf -- "$artifacts"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
# Only validated device names are placed in the SSH command. The sampler uses
|
||||
# monotonic uptime and the weighted I/O milliseconds from /proc/diskstats.
|
||||
sample=$(cat <<'REMOTE'
|
||||
set -eu
|
||||
export LC_ALL=C
|
||||
snapshot() {
|
||||
awk -v devices="$devices" '
|
||||
BEGIN { n=split(devices,d," "); for(i=1;i<=n;i++) want[d[i]]=1 }
|
||||
FNR==NR { t=$1; next }
|
||||
$3 in want {
|
||||
if (NF<14 || $14 !~ /^[0-9]+$/) exit 2
|
||||
print $3,t,$14
|
||||
got++
|
||||
}
|
||||
END { if (got!=n) exit 2 }
|
||||
' /proc/uptime /proc/diskstats
|
||||
}
|
||||
before=$(snapshot)
|
||||
sleep 5
|
||||
after=$(snapshot)
|
||||
printf '%s\n--\n%s\n' "$before" "$after" | awk '
|
||||
$0=="--" { second=1; next }
|
||||
!second { if ($1 in t) bad=1; t[$1]=$2; w[$1]=$3; count++; next }
|
||||
{ if (!($1 in t) || seen[$1]++ || $2<=t[$1] || $3<w[$1]) { bad=1; next }
|
||||
q=($3-w[$1])/(1000*($2-t[$1])); sum+=q; if(q>peak)peak=q; got++ }
|
||||
END { if (bad||!count||got!=count) exit 2; printf "%.6f %.6f\n",sum/count,peak }
|
||||
'
|
||||
REMOTE
|
||||
)
|
||||
|
||||
end=$((SECONDS+budget))
|
||||
streak=0
|
||||
sample_number=0
|
||||
printf 'sample\tnode\tmean_queue\tpeak_queue\n'
|
||||
while ((end-SECONDS >= 5)); do
|
||||
sample_number=$((sample_number+1))
|
||||
remaining=$((end-SECONDS))
|
||||
for i in "${!targets[@]}"; do
|
||||
timeout --foreground --kill-after=1s "${remaining}s" ssh "${ssh_args[@]}" -- "${targets[i]#*=}" \
|
||||
"devices='${device_lists[i]}'; $sample" >"$artifacts/$i" &
|
||||
pids+=("$!")
|
||||
done
|
||||
valid=true
|
||||
for pid in "${pids[@]}"; do
|
||||
if ! wait "$pid"; then valid=false; fi
|
||||
done
|
||||
pids=()
|
||||
if [[ "$valid" != true ]]; then
|
||||
echo "disk queue sample failed or timed out" >&2
|
||||
exit 1
|
||||
fi
|
||||
quiet=true
|
||||
for i in "${!targets[@]}"; do
|
||||
result=$(cat "$artifacts/$i")
|
||||
if [[ ! "$result" =~ ^([0-9]+\.[0-9]+)\ ([0-9]+\.[0-9]+)$ ]]; then
|
||||
echo "invalid disk queue sample from ${targets[i]%%=*}" >&2; exit 1
|
||||
fi
|
||||
mean="${BASH_REMATCH[1]}"
|
||||
peak="${BASH_REMATCH[2]}"
|
||||
printf '%s\t%s\t%s\t%s\n' "$sample_number" "${targets[i]%%=*}" "$mean" "$peak"
|
||||
if ! awk -v mean="$mean" -v peak="$peak" 'BEGIN {exit !(mean<=0.25 && peak<=0.75)}'; then quiet=false; fi
|
||||
done
|
||||
if [[ "$quiet" == true ]]; then
|
||||
streak=$((streak+1))
|
||||
if ((streak == 2 && SECONDS <= end)); then exit 0; fi
|
||||
else
|
||||
streak=0
|
||||
fi
|
||||
done
|
||||
echo "disk queues did not settle within ${budget}s" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user