Исправить замечания ревью: защита rollout от остановленных реплик, чтение серий, время экспериментов по часам Docker, выход сервера при ошибке старта
This commit is contained in:
@@ -14,6 +14,13 @@
|
||||
# faults.json (when and what was stopped), compose.log (the balancer's
|
||||
# DOWN/UP lines and the replicas' shutdown/start lines), instances-*.txt.
|
||||
# Runs on the current stand (`make up`) and leaves every replica running.
|
||||
#
|
||||
# Every time used for the analysis comes from the Docker VM's clock: the log
|
||||
# timestamps, the container's stop and start times from `docker inspect`, and
|
||||
# the generator's own times. The host clock of Windows runs apart from it by
|
||||
# a fraction of a second, a large share of a 1.5 s detection window; host
|
||||
# times are kept for reference only. With `stop`, the moment SIGTERM arrived
|
||||
# is the replica's own "shutdown started" line in compose.log.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/../.."
|
||||
. scripts/bench/lib.sh
|
||||
@@ -37,7 +44,8 @@ alias=$(sh scripts/api-instances.sh | awk -v id="$(printf '%s' "$target" | cut -
|
||||
meta "$dir/meta.json" "experiment=failover" "kind=$kind" "replica=$n" "rate=$rate" "duration=$duration" \
|
||||
"fault_at_s=$fault_at" "restore_at_s=$restore_at"
|
||||
sh scripts/instances.sh >"$dir/instances-before.txt"
|
||||
since=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
# A margin for the host clock, which may run ahead of the VM's.
|
||||
since=$(date -u -d '-10 seconds' +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
BENCH_OUT=$(abspath "$dir") docker compose --profile bench run --rm loadgen timeline \
|
||||
-rate "$rate" -duration "$duration" >"$dir/loadgen.log" 2>&1 &
|
||||
@@ -45,17 +53,18 @@ generator=$!
|
||||
# The generator seeds two users first; its timeline starts after that. The
|
||||
# fault times below are absolute, as is started_at in timeline.json.
|
||||
sleep "$fault_at"
|
||||
fault=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)
|
||||
fault_host=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)
|
||||
docker "$kind" "$target" >/dev/null
|
||||
fault_done=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)
|
||||
exited=$(docker inspect --format '{{.State.FinishedAt}}' "$target")
|
||||
sleep $((restore_at - fault_at))
|
||||
restore=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)
|
||||
restore_host=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)
|
||||
docker compose start api >/dev/null 2>&1
|
||||
started=$(docker inspect --format '{{.State.StartedAt}}' "$target")
|
||||
wait "$generator" || echo "generator reported a failed history check, see $dir/loadgen.log"
|
||||
|
||||
printf '{\n "kind": "%s",\n "container": "%s",\n "x_instance_id": "%s",\n "fault_utc": "%s",\n "fault_command_returned_utc": "%s",\n "restore_utc": "%s"\n}\n' \
|
||||
"$kind" "$(printf '%s' "$target" | cut -c1-12)" "$alias" "$fault" "$fault_done" "$restore" >"$dir/faults.json"
|
||||
docker compose logs --no-color --since "$since" lb api >"$dir/compose.log" 2>&1
|
||||
printf '{\n "kind": "%s",\n "container": "%s",\n "x_instance_id": "%s",\n "process_exited_vm_utc": "%s",\n "restarted_vm_utc": "%s",\n "fault_command_host_utc": "%s",\n "restore_command_host_utc": "%s"\n}\n' \
|
||||
"$kind" "$(printf '%s' "$target" | cut -c1-12)" "$alias" "$exited" "$started" "$fault_host" "$restore_host" >"$dir/faults.json"
|
||||
docker compose logs --no-color --timestamps --since "$since" lb api >"$dir/compose.log" 2>&1
|
||||
sh scripts/instances.sh >"$dir/instances-after.txt"
|
||||
cat "$dir/loadgen.log" | tail -n 1
|
||||
echo "results in $dir"
|
||||
|
||||
Reference in New Issue
Block a user