From 4ca08a12a48854ebdaa3cceea71281137a02cba5 Mon Sep 17 00:00:00 2001 From: yuyr Date: Mon, 29 Jun 2026 16:53:10 +0800 Subject: [PATCH] fix periodic snapshot upgrade edge cases --- deploy/arm64-installer/upgrade.sh | 40 ++++++++++++++++++++++++++++++- scripts/soak/run_soak.sh | 9 ++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/deploy/arm64-installer/upgrade.sh b/deploy/arm64-installer/upgrade.sh index dee59f9..eb5e35b 100755 --- a/deploy/arm64-installer/upgrade.sh +++ b/deploy/arm64-installer/upgrade.sh @@ -5,10 +5,16 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/scripts/common.sh" REUSE_ENV_FROM="" +UPDATE_PACKAGE_IMAGE=1 usage() { cat <<'USAGE' -Usage: ./upgrade.sh [--reuse-env-from /path/to/.env] +Usage: ./upgrade.sh [--reuse-env-from /path/to/.env] [--keep-reused-image] + +By default, --reuse-env-from preserves user/runtime settings but refreshes image +tags from this package's .env.example so the upgraded service actually runs the +new packaged runtime and monitor images. Use --keep-reused-image only when you +intentionally want to keep the previous image tags. USAGE } @@ -18,6 +24,10 @@ while [[ $# -gt 0 ]]; do REUSE_ENV_FROM="$2" shift 2 ;; + --keep-reused-image) + UPDATE_PACKAGE_IMAGE=0 + shift + ;; -h|--help) usage exit 0 @@ -38,6 +48,34 @@ if [[ -n "$REUSE_ENV_FROM" ]]; then fi fi +refresh_env_key_from_example() { + local key="$1" + local value + [[ -f "$ENV_EXAMPLE" ]] || die "missing $ENV_EXAMPLE" + value="$(awk -F= -v key="$key" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$ENV_EXAMPLE")" + [[ -n "$value" ]] || return 0 + if grep -q "^${key}=" "$ENV_FILE"; then + tmp_env="$(mktemp)" + awk -v key="$key" -v value="$value" ' + BEGIN { done=0 } + $0 ~ "^" key "=" { print key "=" value; done=1; next } + { print } + END { if (!done) print key "=" value } + ' "$ENV_FILE" > "$tmp_env" + mv "$tmp_env" "$ENV_FILE" + else + printf '%s=%s\n' "$key" "$value" >> "$ENV_FILE" + fi + log "refreshed $key from packaged .env.example" +} + +if [[ "$UPDATE_PACKAGE_IMAGE" == "1" ]]; then + load_env + refresh_env_key_from_example "RPKI_IMAGE" + refresh_env_key_from_example "PROMETHEUS_IMAGE" + refresh_env_key_from_example "GRAFANA_IMAGE" +fi + load_env create_data_dirs install_docker_if_missing diff --git a/scripts/soak/run_soak.sh b/scripts/soak/run_soak.sh index 2ec5388..dff549f 100755 --- a/scripts/soak/run_soak.sh +++ b/scripts/soak/run_soak.sh @@ -497,7 +497,14 @@ import sys runs_root = pathlib.Path(sys.argv[1]) delta_count = 0 run_dirs = sorted( - [path for path in runs_root.glob("run_[0-9][0-9][0-9][0-9]") if path.is_dir()], + [ + path + for path in runs_root.glob("run_*") + if path.is_dir() + and path.name.startswith("run_") + and path.name[4:].isdigit() + ], + key=lambda path: int(path.name[4:]), reverse=True, ) for run_dir in run_dirs: