From a45d5a994d5e59dea94ae1a4fc4353e39a01dbdf Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:26:45 +0100 Subject: [PATCH] feat(juno): report the sync status through the healthcheck The healthcheck prints a status report that says whether the node is synced and what it is doing, declared in the manifest `nodes` field with the status-report probe. --- .github/workflows/node-status-test.yml | 28 + README.md | 4 + dappnode_package.json | 9 +- docker-compose.yml | 6 + juno/Dockerfile | 11 +- juno/entrypoint.sh | 69 ++- juno/node-status.sh | 261 ++++++++ .../mainnet/dappnode_package.json | 8 +- .../sepolia/dappnode_package.json | 8 +- test/node_status_test.sh | 558 ++++++++++++++++++ 10 files changed, 955 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/node-status-test.yml create mode 100755 juno/node-status.sh create mode 100755 test/node_status_test.sh diff --git a/.github/workflows/node-status-test.yml b/.github/workflows/node-status-test.yml new file mode 100644 index 0000000..ae645ef --- /dev/null +++ b/.github/workflows/node-status-test.yml @@ -0,0 +1,28 @@ +name: Node status test + +on: + pull_request: + +permissions: + contents: read + +jobs: + node-status: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/checkout@v4 + with: + repository: dappnode/staker-package-scripts + ref: v0.1.3 + path: staker-package-scripts + + - name: Test with dash + run: NODE_STATUS_TOOLS=staker-package-scripts/scripts/node_status_tools.sh dash test/node_status_test.sh + + - name: Test in Debian bookworm (the base of the Juno image, dash and mawk) + run: > + docker run --rm -v "$PWD:/work" -w /work debian:bookworm-slim sh -c + "apt-get update -qq && apt-get install -qq -y --no-install-recommends jq >/dev/null && + NODE_STATUS_TOOLS=/work/staker-package-scripts/scripts/node_status_tools.sh sh test/node_status_test.sh" diff --git a/README.md b/README.md index 9a48848..cc1c043 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,10 @@ The package uses Docker named volumes for data persistence: - **Data location**: `/var/lib/juno` (inside container) - **Persistence**: Data persists across container restarts and updates +## Node status report + +The package reports its sync status (snapshot download and extraction, database migration, blocks left to the chain head, whether Juno is synced, the block last verified on Ethereum) through its Docker healthcheck, which the Dappnode dashboard reads. Juno counts as synced only when it is at the chain head by its own account and its latest block is at most 5 minutes old. The script is [`juno/node-status.sh`](juno/node-status.sh), installed as `/usr/local/bin/node-status`; its tests are in [`test/node_status_test.sh`](test/node_status_test.sh) (`sh test/node_status_test.sh`, with `dappnode/staker-package-scripts` checked out next to this repository). + ## WebSocket Interface This package includes WebSocket support for real-time interactions with the Starknet network. The WebSocket server runs on port 6061 by default and supports: diff --git a/dappnode_package.json b/dappnode_package.json index 6ce020c..16c4b0c 100644 --- a/dappnode_package.json +++ b/dappnode_package.json @@ -39,5 +39,12 @@ "description": "WebSocket RPC endpoint for StarkNet", "port": 6061 } - ] + ], + "nodes": { + "juno": { + "role": "node", + "probe": { "kind": "status-report", "maxHeadAgeSeconds": 300 }, + "report": "healthcheck" + } + } } diff --git a/docker-compose.yml b/docker-compose.yml index e34a647..66620e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,12 @@ services: WS_PORT: 6061 volumes: - juno_data:/var/lib/juno + healthcheck: + test: ["CMD", "/usr/local/bin/node-status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 60s restart: unless-stopped volumes: juno_data: {} diff --git a/juno/Dockerfile b/juno/Dockerfile index a350a17..470b718 100644 --- a/juno/Dockerfile +++ b/juno/Dockerfile @@ -1,9 +1,11 @@ ARG UPSTREAM_VERSION FROM nethermind/juno:${UPSTREAM_VERSION} -# Install required tools (wget + zstd) in one layer before cleaning up +ARG NODE_STATUS_TOOLS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/v0.1.3/node_status_tools.sh + +# Install required tools (wget + zstd for the snapshot, curl + jq for the healthcheck) in one layer before cleaning up RUN apt-get update && \ - apt-get install -y --no-install-recommends wget zstd && \ + apt-get install -y --no-install-recommends wget zstd curl jq && \ rm -rf /var/lib/apt/lists/* # Create juno data directory @@ -13,4 +15,9 @@ RUN mkdir -p /var/lib/juno COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh +# Healthcheck that prints the node status report +ADD ${NODE_STATUS_TOOLS_URL} /etc/profile.d/node_status_tools.sh +COPY node-status.sh /usr/local/bin/node-status +RUN chmod 0644 /etc/profile.d/node_status_tools.sh && chmod 0755 /usr/local/bin/node-status + ENTRYPOINT ["/entrypoint.sh"] diff --git a/juno/entrypoint.sh b/juno/entrypoint.sh index 205e5a6..919ab21 100755 --- a/juno/entrypoint.sh +++ b/juno/entrypoint.sh @@ -17,14 +17,79 @@ echo "Extra options: $EXTRA_OPTS" # echo all envs printenv +# Read by the healthcheck (node-status) to report the snapshot download and extraction before Juno +# serves its RPC. Writing it never changes what the snapshot steps do or how they fail. +NODE_STATUS_DIR=/tmp/node-status +SNAPSHOT_MARKER="${NODE_STATUS_DIR}/snapshot" + +# A marker left by a container that was killed mid-download must not outlive that run +rm -f "${SNAPSHOT_MARKER}" "${SNAPSHOT_MARKER}.tmp" + +# Writes the snapshot marker atomically +# Arguments: PID of wget or tar, phase, size of the snapshot in bytes (may be empty) +write_snapshot_marker() { + { + mkdir -p "${NODE_STATUS_DIR}" && + printf 'pid=%s\nphase=%s\nfile=%s\nsize=%s\n' "$1" "$2" "${PWD%/}/${snapshot}" "$3" >"${SNAPSHOT_MARKER}.tmp" && + mv -f "${SNAPSHOT_MARKER}.tmp" "${SNAPSHOT_MARKER}" + } 2>/dev/null +} + +# Copies the output of wget (stdin) to stderr, where wget writes it, and records the snapshot size +# from its "Length: (...)" line +# Arguments: PID of wget +follow_snapshot_download() { + while IFS= read -r line || [ -n "$line" ]; do + printf '%s\n' "$line" >&2 + case $line in + "Length: "[0-9]*) + size=${line#Length: } + write_snapshot_marker "$1" "Downloading snapshot" "${size%% *}" || true + ;; + esac + done +} + +# Downloads the snapshot with wget in the background, so its PID can vouch for the marker. +# Returns the exit status of wget. +download_snapshot() { + fifo="${NODE_STATUS_DIR}/wget.fifo" + if ! { mkdir -p "${NODE_STATUS_DIR}" && rm -f "$fifo" && mkfifo "$fifo"; } 2>/dev/null; then + # shellcheck disable=SC2086 # unquoted as before + wget --progress=dot:giga -O $snapshot $SNAPSHOT_URL + return + fi + # shellcheck disable=SC2086 # unquoted as before + wget --progress=dot:giga -O $snapshot $SNAPSHOT_URL 2>"$fifo" & + wget_pid=$! + write_snapshot_marker "$wget_pid" "Downloading snapshot" "" || true + follow_snapshot_download "$wget_pid" <"$fifo" + wget_status=0 + wait "$wget_pid" || wget_status=$? + rm -f "$fifo" "${SNAPSHOT_MARKER}" + return "$wget_status" +} + +# Extracts the snapshot with tar in the background, so its PID can vouch for the marker. +# Returns the exit status of tar. +extract_snapshot() { + tar --checkpoint=65536 -xf $snapshot -C $JUNO_DIR & + tar_pid=$! + write_snapshot_marker "$tar_pid" "Extracting snapshot" "" || true + tar_status=0 + wait "$tar_pid" || tar_status=$? + rm -f "${SNAPSHOT_MARKER}" + return "$tar_status" +} + # if dir is empty and URL is configured, download the snapshot if [ "$(ls -A $JUNO_DIR)" ]; then echo "Skipping snapshot download." elif [ -n "$SNAPSHOT_URL" ]; then echo "Juno data directory is empty. Downloading snapshot." snapshot=mainnet.tar - wget --progress=dot:giga -O $snapshot $SNAPSHOT_URL - tar --checkpoint=65536 -xf $snapshot -C $JUNO_DIR + download_snapshot + extract_snapshot rm $snapshot fi diff --git a/juno/node-status.sh b/juno/node-status.sh new file mode 100755 index 0000000..d127fd8 --- /dev/null +++ b/juno/node-status.sh @@ -0,0 +1,261 @@ +#!/bin/sh + +# Node status report of the Juno package, run as the Docker healthcheck. +# Prints one JSON line (see node_status_tools.sh in dappnode/staker-package-scripts): +# whether Juno is synced, how far along it is and what it is doing, from its own +# JSON-RPC and metrics and from the snapshot marker the entrypoint leaves. +# Juno is not an Ethereum client, so this report carries the verdict (probe kind +# status-report): the dappmanager shows the state given here. +# +# Juno, as of v0.16: +# - starknet_syncing is false when Juno has no head, does not know the highest +# block yet, or its head is at or past the highest block it knows; an object +# with current_block_num and highest_block_num otherwise, even one block behind. +# - Juno learns the chain head from the feeder gateway once a minute and raises +# it to every block it stores, so a gateway it cannot reach leaves it "not +# syncing" on an old head: the latest block's timestamp must be checked too. +# - The JSON-RPC (the root path serves the newest RPC version) starts only after +# the database migrations; the metrics server starts before them. +# +# Environment: +# NODE_STATUS_TOOLS: Path of the shared helpers (default /etc/profile.d/node_status_tools.sh) +# NODE_STATUS_DIR: Directory of the snapshot marker (default /tmp/node-status) +# NODE_STATUS_PROC_NET: Socket tables to look for listening ports (default /proc/net/tcp /proc/net/tcp6) +# HTTP_PORT: JSON-RPC port, also read by the entrypoint (default 6060) +# ETH_L1_RPC_URL: Ethereum node of the L1 verification, read by the entrypoint; only +# whether it is set is used here +# NS_TIMEOUT: See node_status_tools.sh + +# At most three calls, each with its own timeout, and none after one fails, so +# the script ends well inside the healthcheck timeout even when Juno hangs +NS_TIMEOUT=${NS_TIMEOUT:-2} + +# shellcheck source=/dev/null +. "${NODE_STATUS_TOOLS:-/etc/profile.d/node_status_tools.sh}" || exit 1 + +NS_RPC_PORT=${HTTP_PORT:-6060} +# Fixed in the entrypoint (--metrics-port) +METRICS_PORT=9090 +METRICS_URL="http://127.0.0.1:${METRICS_PORT}/metrics" +SNAPSHOT_MARKER="${NODE_STATUS_DIR:-/tmp/node-status}/snapshot" +PROC_NET_TCP=${NODE_STATUS_PROC_NET:-"/proc/net/tcp /proc/net/tcp6"} + +# Oldest the latest block may be for Juno to count as synced. Must match +# probe.maxHeadAgeSeconds in dappnode_package.json. +MAX_HEAD_AGE_SECONDS=300 +# Blocks the head may trail the highest block Juno knows and still count as at +# the head: Juno's own default for /ready/sync (--readiness-block-tolerance) +HEAD_TOLERANCE_BLOCKS=6 + +is_uint() { + case $1 in + '' | *[!0-9]*) return 1 ;; + esac + return 0 +} + +# Percentage of $1 over $2, nothing unless both are known and $2 is positive +percent() { + is_uint "$1" && is_uint "$2" || return 0 + awk -v done="$1" -v total="$2" 'BEGIN { if (total > 0) printf "%.1f\n", done * 100 / total }' +} + +# 18647719 -> 18,647,719 +commas() { + awk -v n="$1" 'BEGIN { r = ""; while (length(n) > 3) { r = "," substr(n, length(n) - 2) r; n = substr(n, 1, length(n) - 3) } print n r }' +} + +# Succeeds when something listens on TCP port $1 (IPv4 or IPv6, any address) +listening() { + _port=$(printf ':%04X' "$1") + set -- + for _table in $PROC_NET_TCP; do + [ -r "$_table" ] && set -- "$@" "$_table" + done + [ $# -gt 0 ] || return 1 + # Columns: sl local_address rem_address st ...; st 0A is LISTEN + awk -v port="$_port" '$4 == "0A" && substr($2, length($2) - 4) == port { found = 1 } END { exit !found }' "$@" +} + +# Bytes of $2 read so far by process $1 or one of its children: tar hands a +# compressed archive to a zstd child, which then holds the file open +read_position() { + _parent=$1 + _file=$2 + _pids=$_parent + for _stat in /proc/[0-9]*/stat; do + _line="" + { read -r _line <"$_stat"; } 2>/dev/null || continue + # pid (comm) state ppid ...; comm may hold spaces and parentheses + # shellcheck disable=SC2086 # split into fields on purpose + set -- ${_line##*") "} + [ "${2:-}" = "$_parent" ] || continue + _pid=${_stat#/proc/} + _pids="$_pids ${_pid%/stat}" + done + _max="" + for _pid in $_pids; do + for _fd in "/proc/$_pid/fd/"*; do + [ "$(readlink "$_fd" 2>/dev/null)" = "$_file" ] || continue + _pos=$(sed -n 's/^pos:[[:space:]]*//p' "/proc/$_pid/fdinfo/${_fd##*/}" 2>/dev/null) + is_uint "$_pos" || continue + if [ -z "$_max" ] || [ "$_pos" -gt "$_max" ]; then + _max=$_pos + fi + done + done + [ -n "$_max" ] && printf '%s\n' "$_max" +} + +# Prints "|" of the snapshot download or extraction the +# entrypoint runs, nothing when there is none. The marker counts only while the +# process it names runs and works on the snapshot file, so a marker left by a +# killed run never makes a starting node look like it downloads. +snapshot_status() { + [ -f "$SNAPSHOT_MARKER" ] || return 0 + _mpid="" + _mphase="" + _mfile="" + _msize="" + while IFS='=' read -r _key _value; do + case $_key in + pid) _mpid=$_value ;; + phase) _mphase=$_value ;; + file) _mfile=$_value ;; + size) _msize=$_value ;; + esac + done <"$SNAPSHOT_MARKER" + is_uint "$_mpid" && [ -n "$_mphase" ] && [ -n "$_mfile" ] || return 0 + tr '\0' '\n' 2>/dev/null <"/proc/$_mpid/cmdline" | grep -qxF -e "$_mfile" -e "${_mfile##*/}" || return 0 + _progress="" + case $_mphase in + "Downloading snapshot") + _progress=$(percent "$(stat -c %s "$_mfile" 2>/dev/null)" "$_msize") + ;; + "Extracting snapshot") + is_uint "$_msize" || _msize=$(stat -c %s "$_mfile" 2>/dev/null) + _progress=$(percent "$(read_position "$_mpid" "$_mfile")" "$_msize") + ;; + esac + printf '%s|%s\n' "$_mphase" "$_progress" +} + +# The JSON-RPC does not answer: the entrypoint is still preparing the snapshot, +# Juno is migrating its database (metrics already served, RPC not listening +# yet), or Juno is opening it +report_starting() { + _snapshot=$(snapshot_status) + if [ -n "$_snapshot" ]; then + ns_emit starting phase="${_snapshot%%|*}" progress="${_snapshot#*|}" + elif listening "$METRICS_PORT" && ! listening "$NS_RPC_PORT"; then + ns_emit starting phase="Migrating database" + else + ns_emit starting + fi +} + +if ! syncing=$(ns_rpc starknet_syncing); then + report_starting + exit $? +fi + +# Latest block, then metrics; none after the first call that fails +height="" +head_time="" +metrics="" +if block=$(ns_rpc starknet_getBlockWithTxHashes '["latest"]'); then + height=$(ns_json_get "$block" .block_number) + head_time=$(ns_json_get "$block" .timestamp) + if ! is_uint "$height" || ! is_uint "$head_time"; then + height="" + head_time="" + fi + # Only these gauges are needed from the metrics page + metrics=$(ns_http_get "$METRICS_URL" | + grep -E '^(sync_best_known_block_number|l1_l2_finalised_height|l1_latest_height)[ {]') +fi + +current="" +highest="" +case $syncing in +"{"*) + current=$(ns_json_get "$syncing" .current_block_num) + highest=$(ns_json_get "$syncing" .highest_block_num) + ;; +esac +is_uint "$current" || current=$height +is_uint "$highest" || highest="" + +# 0 until Juno learns the chain head from the gateway or stores its first block +best_known=$(printf '%s\n' "$metrics" | ns_metric sync_best_known_block_number) || best_known="" +best_known=${best_known%.*} +is_uint "$best_known" || best_known="" +[ -z "$highest" ] && [ "${best_known:-0}" -gt 0 ] && highest=$best_known + +set -- + +# L1 verification: the L2 block last verified on Ethereum, and whether Juno +# reaches its Ethereum node. The gauges exist only with L1 verification on, and +# l1_latest_height reads 0 when Juno's own call to the Ethereum node fails. +if [ -z "${ETH_L1_RPC_URL:-}" ]; then + set -- "$@" "detail=Verified on Ethereum:Off (L1 verification disabled)" +else + verified=$(printf '%s\n' "$metrics" | ns_metric l1_l2_finalised_height) || verified="" + verified=${verified%.*} + # The L1 head is ahead of the local chain while Juno syncs; Juno caps it at + # its own head too (l1_accepted block tag) + if is_uint "$verified" && is_uint "$height" && [ "$verified" -gt "$height" ]; then + verified=$height + fi + if is_uint "$verified" && [ "$verified" -gt 0 ]; then + set -- "$@" "detail=Verified on Ethereum:Block $(commas "$verified")" + fi + l1_latest=$(printf '%s\n' "$metrics" | ns_metric l1_latest_height) || l1_latest="" + if [ "$l1_latest" = 0 ]; then + set -- "$@" "issue=Juno cannot reach its Ethereum node, so verification on Ethereum is paused" + fi +fi + +# No latest block: an empty database, or the call failed +if [ -z "$height" ]; then + ns_emit syncing target="$highest" "$@" + exit $? +fi + +behind="" +if [ -n "$highest" ]; then + behind=$((highest - current)) + [ "$behind" -lt 0 ] && behind=0 +fi + +age=$(($(date +%s) - head_time)) + +# At the head by Juno's own account: starknet_syncing says so, or trails by a +# few blocks (Juno reports even one block behind), and the metrics do not say +# that the chain head is still unknown +at_head=false +case $syncing in +false) + [ "$best_known" != 0 ] && at_head=true + ;; +"{"*) + [ -n "$behind" ] && [ "$behind" -le "$HEAD_TOLERANCE_BLOCKS" ] && at_head=true + ;; +esac + +if [ "$at_head" = true ] && [ "$age" -le "$MAX_HEAD_AGE_SECONDS" ]; then + ns_emit synced height="$height" headTime="$head_time" target="$highest" "$@" + exit $? +fi + +if [ "$at_head" = false ] && [ -z "$highest" ]; then + ns_emit syncing height="$height" headTime="$head_time" phase="Waiting for the chain head" "$@" +elif [ -n "$behind" ] && [ "$behind" -gt "$HEAD_TOLERANCE_BLOCKS" ]; then + ns_emit syncing height="$height" headTime="$head_time" phase="Downloading blocks" \ + position="$current" target="$highest" "$@" +else + # At the head by Juno's account, but the head is old: Juno sees no newer + # block, because the gateway does not answer or it has not polled it yet + ns_emit syncing height="$height" headTime="$head_time" phase="Catching up" "$@" +fi +exit $? diff --git a/package_variants/mainnet/dappnode_package.json b/package_variants/mainnet/dappnode_package.json index 083c968..d0ddc37 100644 --- a/package_variants/mainnet/dappnode_package.json +++ b/package_variants/mainnet/dappnode_package.json @@ -18,5 +18,11 @@ "description": "WebSocket RPC endpoint for StarkNet", "port": 6061 } - ] + ], + "nodes": { + "juno": { + "network": "starknet", + "requires": [{ "network": "mainnet", "role": "execution" }] + } + } } diff --git a/package_variants/sepolia/dappnode_package.json b/package_variants/sepolia/dappnode_package.json index d982058..adb0388 100644 --- a/package_variants/sepolia/dappnode_package.json +++ b/package_variants/sepolia/dappnode_package.json @@ -18,5 +18,11 @@ "description": "WebSocket RPC endpoint for StarkNet Sepolia", "port": 6061 } - ] + ], + "nodes": { + "juno": { + "network": "starknet-sepolia", + "requires": [{ "network": "sepolia", "role": "execution" }] + } + } } diff --git a/test/node_status_test.sh b/test/node_status_test.sh new file mode 100755 index 0000000..80b987d --- /dev/null +++ b/test/node_status_test.sh @@ -0,0 +1,558 @@ +#!/bin/sh +# shellcheck disable=SC1091 # sources files the test writes + +# Tests for juno/node-status.sh (the healthcheck status report) and for the snapshot marker +# written by juno/entrypoint.sh. +# Run from anywhere with any POSIX sh: sh test/node_status_test.sh +# Needs jq and the helper library of dappnode/staker-package-scripts, by default checked out next +# to this repository (override with NODE_STATUS_TOOLS=). +# The network is stubbed by a curl function; the snapshot download and extraction by fake wget +# and tar commands. Needs Linux /proc (the script reads the snapshot progress from it). + +cd "$(dirname "$0")/.." || exit 1 +NODE_STATUS_TOOLS=${NODE_STATUS_TOOLS:-../staker-package-scripts/scripts/node_status_tools.sh} +if [ ! -f "$NODE_STATUS_TOOLS" ]; then + echo "Helper library not found: $NODE_STATUS_TOOLS (set NODE_STATUS_TOOLS)" >&2 + exit 1 +fi +SCRIPT=$(pwd)/juno/node-status.sh +ENTRYPOINT=$(pwd)/juno/entrypoint.sh +NODE_STATUS_TOOLS=$(cd "$(dirname "$NODE_STATUS_TOOLS")" && pwd)/$(basename "$NODE_STATUS_TOOLS") + +PASS=0 +FAIL=0 +# Physical path: the script compares it with the targets of /proc//fd links +TMP=$(cd "$(mktemp -d)" && pwd -P) || exit 1 +NODE_STATUS_DIR="$TMP/status" +WORK="$TMP/work" +FAKE_DIR="$TMP/fake" +mkdir -p "$NODE_STATUS_DIR" "$WORK" "$FAKE_DIR" "$TMP/bin" "$TMP/data" +HELPER_PIDS="" +# shellcheck disable=SC2329 # called by the EXIT trap +cleanup() { + : >"$FAKE_DIR/wget.go" + : >"$FAKE_DIR/tar.go" + for pid in $HELPER_PIDS; do kill "$pid" 2>/dev/null; done + rm -rf "$TMP" +} +trap cleanup EXIT + +# check +check() { + if [ "$2" = "$3" ]; then + PASS=$((PASS + 1)) + else + FAIL=$((FAIL + 1)) + printf 'FAIL: %s\n expected: %s\n actual: %s\n' "$1" "$2" "$3" + fi +} + +# Stubbed node. STUB_RPC: up (default) or down (connection refused). STUB_SYNCING and STUB_BLOCK: +# JSON results of starknet_syncing and starknet_getBlockWithTxHashes; STUB_BLOCK=error makes the +# latter answer with a JSON-RPC error (Juno without blocks). STUB_METRICS: body of the metrics +# endpoint, which refuses connections when unset. Each call is logged to $TMP/calls as +# "[ ] max-time=". +# shellcheck disable=SC2329 # called by the library under test +curl() { + _url="" + _data="" + _max_time="" + while [ $# -gt 0 ]; do + case $1 in + --data) _data=$2 && shift ;; + --max-time) _max_time=$2 && shift ;; + http://*) _url=$1 ;; + esac + shift + done + _method="" + _params="" + if [ -n "$_data" ]; then + _method=$(printf '%s' "$_data" | jq -r .method) + _params=$(printf '%s' "$_data" | jq -c .params) + fi + echo "$_url${_method:+ $_method $_params} max-time=$_max_time" >>"$TMP/calls" + case $_url in + */metrics) + [ -n "${STUB_METRICS+set}" ] || return 7 + printf '%s' "$STUB_METRICS" + return 0 + ;; + esac + [ "${STUB_RPC:-up}" = up ] || return 7 + case $_method in + starknet_syncing) _result=$STUB_SYNCING ;; + starknet_getBlockWithTxHashes) + if [ "$STUB_BLOCK" = error ]; then + printf '{"jsonrpc":"2.0","id":1,"error":{"code":24,"message":"Block not found"}}' + return 0 + fi + _result=$STUB_BLOCK + ;; + *) _result=null ;; + esac + printf '{"jsonrpc":"2.0","id":1,"result":%s}' "$_result" +} + +# Runs the healthcheck script with the stubbed curl: sets OUT (stdout), RC, LINES and CALLS +run_status() { + : >"$TMP/calls" + # shellcheck disable=SC1090 + OUT=$(. "$SCRIPT" 2>"$TMP/stderr") + RC=$? + LINES=$(printf '%s\n' "$OUT" | grep -c .) + CALLS=$(cat "$TMP/calls") +} + +# Fails unless OUT is one JSON object that follows the status report contract +validate() { + _errors=$(printf '%s\n' "$OUT" | jq -r ' + def int: type == "number" and . == floor and . >= 0; + def short($n): type == "string" and length > 0 and length <= $n; + [ + (if .version != 1 then "version" else empty end), + (if (.state | IN("starting", "syncing", "synced", "error")) | not then "state" else empty end), + (keys - ["version", "state", "phase", "progress", "height", "headTime", "position", "target", + "unit", "peers", "awaitingTarget", "background", "issues", "details"] | .[] | "unknown key \(.)"), + (if has("phase") and (.phase | short(60) | not) then "phase" else empty end), + (if has("progress") and ((.progress | type) != "number" or .progress < 0 or .progress > 100 + or (.state != "synced" and .progress > 99.9)) then "progress" else empty end), + (["height", "headTime", "position", "target", "peers"][] as $k + | if has($k) and (.[$k] | int | not) then $k else empty end), + (if has("awaitingTarget") and .awaitingTarget != true then "awaitingTarget" else empty end), + (if has("background") and (.background | short(60) | not) then "background" else empty end), + (if has("issues") and ((.issues | type) != "array" or (.issues | length) > 5 + or any(.issues[]; short(120) | not)) then "issues" else empty end), + (if has("details") and ((.details | type) != "array" or (.details | length) > 8 + or any(.details[]; (.label | short(40) | not) or (.value | short(120) | not))) then "details" else empty end), + (if has("progress") and (has("position") or has("target")) then "progress with position" else empty end), + (if (tojson | utf8bytelength) > 2048 then "size" else empty end) + ] | join(", ")' 2>/dev/null) || _errors="not JSON" + check "$1: one line" 1 "$LINES" + check "$1: follows the contract" "" "$_errors" + check "$1: exit code" 0 "$RC" + check "$1: nothing on stderr" "" "$(cat "$TMP/stderr")" +} + +# field : value from OUT, compact +field() { + printf '%s\n' "$OUT" | jq -c "$1" 2>/dev/null +} + +# block : starknet_getBlockWithTxHashes result as Juno builds it +block() { + printf '{"status":"ACCEPTED_ON_L2","block_hash":"0xab","parent_hash":"0xaa","block_number":%s,"new_root":"0x1","timestamp":%s,"sequencer_address":"0x2","starknet_version":"0.14.1","transactions":["0x3","0x4"]}' "$1" "$2" +} + +# syncing : starknet_syncing object +syncing() { + printf '{"starting_block_hash":"0x1","starting_block_num":%s,"current_block_hash":"0x2","current_block_num":%s,"highest_block_hash":"0x3","highest_block_num":%s}' "$1" "$2" "$3" +} + +# metrics : Prometheus page, numbers as +# the Go client writes them; an empty argument leaves the gauge out +metrics() { + printf '# HELP sync_blockchain_height Current blockchain height (latest block number)\n# TYPE sync_blockchain_height gauge\nsync_blockchain_height 1.8647719e+07\n' + [ -n "$1" ] && printf '# TYPE sync_best_known_block_number gauge\nsync_best_known_block_number %s\n' "$1" + [ -n "$2" ] && printf 'l1_finalised_height 2.3891e+07\nl1_l2_finalised_height %s\n' "$2" + [ -n "$3" ] && printf 'l1_latest_height %s\n' "$3" + printf 'rpc_server_requests{method="starknet_syncing"} 12\n' +} + +# Socket tables: listen ... writes $TMP/tcp with those ports in LISTEN state, plus an +# established connection from port 6060 that must not count +listen() { + { + echo " sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode" + echo " 0: 0100007F:17AC 0100007F:A1B2 01 00000000:00000000 00:00000000 00000000 0 0 1 1 0000000000000000 20 4 30 10 -1" + for _p in "$@"; do + printf ' 1: 00000000:%04X 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 2 1 0000000000000000 100 0 0 10 0\n' "$_p" + done + } >"$TMP/tcp" +} +export NODE_STATUS_PROC_NET="$TMP/tcp $TMP/tcp6-absent" + +# write_marker : marker as the entrypoint writes it +write_marker() { + printf 'pid=%s\nphase=%s\nfile=%s\nsize=%s\n' "$1" "$2" "$3" "$4" >"$NODE_STATUS_DIR/snapshot" +} + +# wait_for : waits up to 10 s for a file to exist +wait_for() { + _tries=0 + while [ ! -e "$1" ] && [ "$_tries" -lt 100 ]; do + sleep 0.1 + _tries=$((_tries + 1)) + done + [ -e "$1" ] +} + +# Fake wget: prints its "Length:" line, writes 250 bytes, waits for $FAKE_DIR/wget.go, writes the +# rest and exits with $FAKE_WGET_STATUS. Arguments as the entrypoint passes them. +cat >"$TMP/bin/wget" <<'EOF' +#!/bin/sh +out="" +while [ $# -gt 0 ]; do + case $1 in -O) out=$2 && shift ;; esac + shift +done +echo "--2026-11-30 10:00:00-- http://snapshots.invalid/latest" >&2 +echo "Length: 1000 (1000) [application/zstd]" >&2 +head -c 250 /dev/zero >"$out" +: >"$FAKE_DIR/wget.ready" +while [ ! -e "$FAKE_DIR/wget.go" ]; do sleep 0.1; done +head -c 750 /dev/zero >>"$out" +echo "done" >&2 +exit "${FAKE_WGET_STATUS:-0}" +EOF +# Fake tar: reads 400 bytes of the archive (in a child that holds the file, like the zstd child of +# GNU tar, when $FAKE_TAR_CHILD is set), waits for $FAKE_DIR/tar.go and exits with $FAKE_TAR_STATUS +cat >"$TMP/bin/tar" <<'EOF' +#!/bin/sh +archive="" +while [ $# -gt 0 ]; do + case $1 in -xf) archive=$2 && shift ;; esac + shift +done +hold='exec 3<"$1"; dd bs=400 count=1 <&3 >/dev/null 2>&1; : >"$FAKE_DIR/tar.ready"; while [ ! -e "$FAKE_DIR/tar.go" ]; do sleep 0.1; done; :' +if [ -n "${FAKE_TAR_CHILD:-}" ]; then + sh -c "$hold" zstd "$archive" & + wait +else + exec 3<"$archive" + dd bs=400 count=1 <&3 >/dev/null 2>&1 + : >"$FAKE_DIR/tar.ready" + while [ ! -e "$FAKE_DIR/tar.go" ]; do sleep 0.1; done +fi +exit "${FAKE_TAR_STATUS:-0}" +EOF +chmod +x "$TMP/bin/wget" "$TMP/bin/tar" +export FAKE_DIR + +# Starts a process like a running wget of the snapshot (its command line names the file) and sets +# FAKE_PID +start_fake_process() { + sh -c 'sleep 60; :' wget -O "$1" >/dev/null 2>&1 & + FAKE_PID=$! + HELPER_PIDS="$HELPER_PIDS $FAKE_PID" +} + +NOW=$(date +%s) +H=18647719 +STUB_BLOCK=$(block "$H" "$((NOW - 10))") +STUB_SYNCING=false +# shellcheck disable=SC2034 # read by the script under test +ETH_L1_RPC_URL=ws://execution.mainnet.dncore.dappnode:8546 +SNAPSHOT="$WORK/mainnet.tar" +head -c 1000 /dev/zero >"$SNAPSHOT" + +echo "starting" +STUB_RPC=down +listen +run_status +validate "node down" +check "node down: report" '{"version":1,"state":"starting"}' "$OUT" +check "node down: only starknet_syncing called, root path" "http://127.0.0.1:6060 starknet_syncing [] max-time=2" "$CALLS" + +listen 9090 +run_status +validate "migrating" +check "migrating: metrics served, RPC not listening" '{"version":1,"state":"starting","phase":"Migrating database"}' "$OUT" +check "migrating: no further call" "1" "$(printf '%s\n' "$CALLS" | grep -c .)" + +listen 9090 6060 +run_status +check "RPC listening but not answering: plain starting" '{"version":1,"state":"starting"}' "$OUT" + +listen 6060 +run_status +check "metrics not listening: plain starting" '{"version":1,"state":"starting"}' "$OUT" + +# shellcheck disable=SC2034 # read by the script under test +HTTP_PORT=7070 +listen 9090 6060 +run_status +check "HTTP_PORT: RPC called on that port" "http://127.0.0.1:7070 starknet_syncing [] max-time=2" "$CALLS" +check "HTTP_PORT: that port not listening means migrating" '"Migrating database"' "$(field .phase)" +unset HTTP_PORT + +echo "snapshot marker" +listen +start_fake_process "$SNAPSHOT" +head -c 250 /dev/zero >"$SNAPSHOT" +write_marker "$FAKE_PID" "Downloading snapshot" "$SNAPSHOT" 1000 +run_status +validate "snapshot download" +check "snapshot download: report" '{"version":1,"state":"starting","phase":"Downloading snapshot","progress":25}' "$OUT" + +write_marker "$FAKE_PID" "Downloading snapshot" "$SNAPSHOT" "" +run_status +check "snapshot download without size: no progress" '{"version":1,"state":"starting","phase":"Downloading snapshot"}' "$OUT" + +head -c 1000 /dev/zero >"$SNAPSHOT" +write_marker "$FAKE_PID" "Downloading snapshot" "$SNAPSHOT" 1000 +run_status +check "snapshot download: progress never 100 while running" "99.9" "$(field .progress)" + +rm -f "$SNAPSHOT" +run_status +check "snapshot download before the file exists: no progress" '{"version":1,"state":"starting","phase":"Downloading snapshot"}' "$OUT" +head -c 1000 /dev/zero >"$SNAPSHOT" + +write_marker "$FAKE_PID" "Downloading snapshot" "$WORK/other.tar" 1000 +run_status +check "marker naming a process that does not work on the file is ignored" '{"version":1,"state":"starting"}' "$OUT" + +sh -c 'exit 0' & +DEAD_PID=$! +wait "$DEAD_PID" +write_marker "$DEAD_PID" "Downloading snapshot" "$SNAPSHOT" 1000 +run_status +validate "stale marker" +check "marker of a finished download is ignored" '{"version":1,"state":"starting"}' "$OUT" +listen 9090 +run_status +check "stale marker while Juno migrates: migration reported" '"Migrating database"' "$(field .phase)" +listen + +write_marker "" "Downloading snapshot" "$SNAPSHOT" 1000 +run_status +check "marker without pid is ignored" '{"version":1,"state":"starting"}' "$OUT" + +write_marker "$FAKE_PID" "" "$SNAPSHOT" 1000 +run_status +check "marker without phase is ignored" '{"version":1,"state":"starting"}' "$OUT" + +printf 'garbage\n' >"$NODE_STATUS_DIR/snapshot" +run_status +validate "garbage marker" +check "garbage marker: plain starting" '{"version":1,"state":"starting"}' "$OUT" + +for mode in "" child; do + rm -f "$FAKE_DIR/tar.ready" "$FAKE_DIR/tar.go" + FAKE_TAR_CHILD=$mode "$TMP/bin/tar" --checkpoint=65536 -xf "$SNAPSHOT" -C "$TMP/data" & + TAR_PID=$! + HELPER_PIDS="$HELPER_PIDS $TAR_PID" + wait_for "$FAKE_DIR/tar.ready" + write_marker "$TAR_PID" "Extracting snapshot" "$SNAPSHOT" "" + run_status + validate "extraction ${mode:-by tar}" + check "extraction ${mode:-by tar}: read position of the archive" \ + '{"version":1,"state":"starting","phase":"Extracting snapshot","progress":40}' "$OUT" + : >"$FAKE_DIR/tar.go" + wait "$TAR_PID" +done +run_status +check "extraction finished: marker ignored" '{"version":1,"state":"starting"}' "$OUT" + +echo "synced" +STUB_RPC=up +STUB_SYNCING=false +STUB_METRICS=$(metrics 1.8647719e+07 1.8640001e+07 2.3891234e+07) +write_marker "$FAKE_PID" "Downloading snapshot" "$SNAPSHOT" 1000 +run_status +validate "synced" +check "synced: report" "{\"version\":1,\"state\":\"synced\",\"height\":$H,\"headTime\":$((NOW - 10)),\"target\":$H,\"details\":[{\"label\":\"Verified on Ethereum\",\"value\":\"Block 18,640,001\"}]}" "$OUT" +check "synced: calls" "$(printf '%s\n%s\n%s' \ + "http://127.0.0.1:6060 starknet_syncing [] max-time=2" \ + "http://127.0.0.1:6060 starknet_getBlockWithTxHashes [\"latest\"] max-time=2" \ + "http://127.0.0.1:9090/metrics max-time=2")" "$CALLS" +check "synced: a marker is ignored once the RPC answers" "null" "$(field .phase)" +rm -f "$NODE_STATUS_DIR/snapshot" + +STUB_SYNCING=$(syncing 18600000 "$H" $((H + 6))) +STUB_METRICS=$(metrics $((H + 6)) "" "") +run_status +validate "synced within tolerance" +check "synced within tolerance: Juno reports 6 blocks behind" "\"synced\" $((H + 6))" "$(field .state) $(field .target)" + +STUB_SYNCING=false +STUB_BLOCK=$(block "$H" "$((NOW - 290))") +run_status +check "synced: latest block 290 s old" '"synced"' "$(field .state)" + +unset STUB_METRICS +STUB_BLOCK=$(block "$H" "$((NOW - 10))") +run_status +validate "synced without metrics" +check "synced without metrics: report" "{\"version\":1,\"state\":\"synced\",\"height\":$H,\"headTime\":$((NOW - 10))}" "$OUT" + +echo "freshness" +STUB_METRICS=$(metrics $H 1.8640001e+07 2.3891234e+07) +STUB_BLOCK=$(block "$H" "$((NOW - 310))") +run_status +validate "stale head" +check "stale head: not synced although Juno says it is not syncing" '"syncing" "Catching up"' "$(field .state) $(field .phase)" +check "stale head: head reported, no position or target" "$H $((NOW - 310)) null null" \ + "$(field .height) $(field .headTime) $(field .position) $(field .target)" + +STUB_SYNCING=$(syncing 18600000 "$H" $((H + 2))) +run_status +check "stale head within tolerance: catching up" '"syncing" "Catching up"' "$(field .state) $(field .phase)" + +echo "syncing" +STUB_SYNCING=$(syncing 0 120000 $H) +STUB_BLOCK=$(block 120000 1640000000) +STUB_METRICS=$(metrics $H 1.10000e+05 2.3891234e+07) +run_status +validate "downloading blocks" +check "downloading blocks: report" "{\"version\":1,\"state\":\"syncing\",\"phase\":\"Downloading blocks\",\"height\":120000,\"headTime\":1640000000,\"position\":120000,\"target\":$H,\"details\":[{\"label\":\"Verified on Ethereum\",\"value\":\"Block 110,000\"}]}" "$OUT" + +STUB_METRICS=$(metrics $H 1.8640001e+07 2.3891234e+07) +run_status +check "downloading blocks: L1-verified block capped at the head" '[{"label":"Verified on Ethereum","value":"Block 120,000"}]' "$(field .details)" + +STUB_SYNCING=$(syncing 18600000 "$H" $((H + 7))) +STUB_BLOCK=$(block "$H" "$((NOW - 10))") +run_status +validate "7 blocks behind" +check "7 blocks behind a recent head: downloading blocks" "\"syncing\" \"Downloading blocks\" $H $((H + 7))" \ + "$(field .state) $(field .phase) $(field .position) $(field .target)" + +STUB_SYNCING=false +STUB_METRICS=$(metrics 0 "" 2.3891234e+07) +run_status +validate "chain head unknown" +check "chain head unknown: waiting" '"syncing" "Waiting for the chain head" null' "$(field .state) $(field .phase) $(field .target)" + +STUB_METRICS=$(metrics "" "" "") +run_status +check "best known gauge absent: Juno's not syncing is trusted" '"synced"' "$(field .state)" + +STUB_BLOCK=error +STUB_SYNCING=false +STUB_METRICS=$(metrics 0 "" "") +run_status +validate "no blocks" +check "no blocks: syncing without head" '{"version":1,"state":"syncing"}' "$OUT" +check "no blocks: no metrics call after the failed call" "2" "$(printf '%s\n' "$CALLS" | grep -c .)" + +STUB_BLOCK=null +STUB_SYNCING=$(syncing 0 5 $H) +run_status +validate "latest block missing" +check "latest block missing: target from starknet_syncing" "{\"version\":1,\"state\":\"syncing\",\"target\":$H}" "$OUT" + +STUB_BLOCK='{"block_number":"x","timestamp":1}' +STUB_SYNCING=false +run_status +validate "malformed block" +check "malformed block: no head" '{"version":1,"state":"syncing"}' "$OUT" + +STUB_SYNCING='"unexpected"' +STUB_BLOCK=$(block "$H" "$((NOW - 10))") +STUB_METRICS=$(metrics $H "" "") +run_status +validate "unexpected starknet_syncing" +check "unexpected starknet_syncing: not at the head" "\"syncing\" \"Catching up\"" "$(field .state) $(field .phase)" + +echo "L1 verification" +STUB_SYNCING=false +STUB_METRICS=$(metrics $H 1.8640001e+07 0) +run_status +validate "L1 unreachable" +check "L1 unreachable: issue" '["Juno cannot reach its Ethereum node, so verification on Ethereum is paused"]' "$(field .issues)" +check "L1 unreachable: still synced" '"synced"' "$(field .state)" + +STUB_METRICS=$(metrics $H 0 2.3891234e+07) +run_status +check "nothing verified on L1 yet: no detail, no issue" "null null" "$(field .details) $(field .issues)" + +ETH_L1_RPC_URL="" +STUB_METRICS=$(metrics $H "" "") +run_status +validate "L1 verification disabled" +check "L1 verification disabled: detail" '[{"label":"Verified on Ethereum","value":"Off (L1 verification disabled)"}]' "$(field .details)" +check "L1 verification disabled: no issue" "null" "$(field .issues)" +# shellcheck disable=SC2034 # read by the script under test +ETH_L1_RPC_URL=ws://execution.mainnet.dncore.dappnode:8546 + +echo "entrypoint snapshot marker" +# The marker functions of the entrypoint, without running it +sed -n '/^write_snapshot_marker() {/,/^}/p; /^follow_snapshot_download() {/,/^}/p; /^download_snapshot() {/,/^}/p; /^extract_snapshot() {/,/^}/p' \ + "$ENTRYPOINT" >"$TMP/entrypoint_functions.sh" +check "entrypoint: four marker functions found" "4" "$(grep -c '^[a-z_]*() {$' "$TMP/entrypoint_functions.sh")" +cat >"$TMP/entrypoint_env.sh" <"$TMP/follow.err") +check "follow: marker with the size from wget's Length line" \ + "pid=4242 phase=Downloading snapshot file=$WORK/mainnet.tar size=109283994788" \ + "$(tr '\n' ' ' <"$NODE_STATUS_DIR/snapshot" | sed 's/ $//')" +check "follow: output passed through to stderr" "$(printf '%s\n%s' "Length: 109283994788 (102G) [application/zstd]" "Saving to: 'mainnet.tar'")" "$(cat "$TMP/follow.err")" +rm -f "$NODE_STATUS_DIR/snapshot" +printf 'Length: unspecified [application/zstd]\n' | + (cd "$WORK" && . "$TMP/entrypoint_env.sh" && follow_snapshot_download 4242 2>/dev/null) +check "follow: no size, no marker" "" "$(ls "$NODE_STATUS_DIR")" +(cd / && . "$TMP/entrypoint_env.sh" && write_snapshot_marker 1 "Downloading snapshot" "") +check "marker: file path in the root directory" "file=/mainnet.tar" "$(grep '^file=' "$NODE_STATUS_DIR/snapshot")" +rm -f "$NODE_STATUS_DIR/snapshot" + +# The download as the entrypoint runs it, with the healthcheck asked midway +rm -f "$SNAPSHOT" "$FAKE_DIR/wget.ready" "$FAKE_DIR/wget.go" +(cd "$WORK" && . "$TMP/entrypoint_env.sh" && download_snapshot 2>"$TMP/download.err" + echo $? >"$TMP/download.status") & +DOWNLOAD_PID=$! +HELPER_PIDS="$HELPER_PIDS $DOWNLOAD_PID" +wait_for "$FAKE_DIR/wget.ready" +_tries=0 +while ! grep -q '^size=1000$' "$NODE_STATUS_DIR/snapshot" 2>/dev/null && [ "$_tries" -lt 100 ]; do + sleep 0.1 + _tries=$((_tries + 1)) +done +STUB_RPC=down +listen +run_status +validate "download in the entrypoint" +check "download in the entrypoint: phase and progress" \ + '{"version":1,"state":"starting","phase":"Downloading snapshot","progress":25}' "$OUT" +: >"$FAKE_DIR/wget.go" +wait "$DOWNLOAD_PID" +check "download: exit status of wget" "0" "$(cat "$TMP/download.status")" +check "download: snapshot written" "1000" "$(wc -c <"$SNAPSHOT" | tr -d ' ')" +check "download: wget output passed through to stderr" "$(printf '%s\n%s\n%s' \ + "--2026-11-30 10:00:00-- http://snapshots.invalid/latest" "Length: 1000 (1000) [application/zstd]" "done")" \ + "$(cat "$TMP/download.err")" +check "download: marker and fifo removed at the end" "" "$(ls "$NODE_STATUS_DIR")" + +# A failing wget stops the entrypoint (set -e) with its exit status, as before +: >"$FAKE_DIR/wget.go" +OUT=$(cd "$WORK" && FAKE_WGET_STATUS=8 sh -ec ". '$TMP/entrypoint_env.sh'; download_snapshot 2>/dev/null; echo continued") +check "download failure: entrypoint exits with wget's status" "8 " "$? $OUT" +check "download failure: marker and fifo removed" "" "$(ls "$NODE_STATUS_DIR")" + +# Without a fifo (unwritable status directory) wget runs as before +OUT=$(cd "$WORK" && sh -ec ". '$TMP/entrypoint_env.sh'; NODE_STATUS_DIR=/dev/null/status; download_snapshot 2>/dev/null; echo continued") +check "download without fifo: still downloads" "0 continued 1000" "$? $OUT $(wc -c <"$SNAPSHOT" | tr -d ' ')" + +# The extraction as the entrypoint runs it +rm -f "$FAKE_DIR/tar.ready" "$FAKE_DIR/tar.go" +(cd "$WORK" && . "$TMP/entrypoint_env.sh" && FAKE_TAR_CHILD=1 extract_snapshot + echo $? >"$TMP/extract.status") & +EXTRACT_PID=$! +HELPER_PIDS="$HELPER_PIDS $EXTRACT_PID" +wait_for "$FAKE_DIR/tar.ready" +wait_for "$NODE_STATUS_DIR/snapshot" +run_status +validate "extraction in the entrypoint" +check "extraction in the entrypoint: phase and progress" \ + '{"version":1,"state":"starting","phase":"Extracting snapshot","progress":40}' "$OUT" +: >"$FAKE_DIR/tar.go" +wait "$EXTRACT_PID" +check "extraction: exit status of tar" "0" "$(cat "$TMP/extract.status")" +check "extraction: marker removed at the end" "" "$(ls "$NODE_STATUS_DIR")" + +OUT=$(cd "$WORK" && FAKE_TAR_STATUS=2 sh -ec ". '$TMP/entrypoint_env.sh'; extract_snapshot; echo continued") +check "extraction failure: entrypoint exits with tar's status" "2 " "$? $OUT" +check "extraction failure: marker removed" "" "$(ls "$NODE_STATUS_DIR")" + +echo "$PASS passed, $FAIL failed" +[ "$FAIL" -eq 0 ]