-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathdev-menu.sh
More file actions
executable file
·91 lines (79 loc) · 2.96 KB
/
Copy pathdev-menu.sh
File metadata and controls
executable file
·91 lines (79 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
#
# dev-menu.sh — entry point for dev-cluster work. Picks the network and
# version, then runs the upgrade in runbook order: nodes, verify, contract.
#
# Usage: ./scripts/ops/dev-cluster/dev-menu.sh [testnet|mainnet] [VERSION]
# Prompts for the Nomad IP, credentials, and node metrics addresses; exporting
# NOMAD_ADDR_DEV_*, NOMAD_HTTP_AUTH_DEV_*, or MPC_NODE_ADDRS_DEV_* for the
# network skips the matching prompt.
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../common.sh
source "${SCRIPT_DIR}/../common.sh"
# shellcheck source=dev-common.sh
source "${SCRIPT_DIR}/dev-common.sh"
# Sets NETWORK: a valid CLI argument passes, an invalid one dies (so scripted
# use fails loudly), no argument prompts until valid.
resolve_network() {
NETWORK="${1:-}"
[[ -z "$NETWORK" ]] || case "$NETWORK" in
testnet|mainnet) return 0 ;;
*) die "Unknown network '${NETWORK}' (expected testnet|mainnet)." ;;
esac
while true; do
read -rp "Network (testnet|mainnet) [testnet]: " NETWORK
NETWORK="${NETWORK:-testnet}"
case "$NETWORK" in
testnet|mainnet) return 0 ;;
*) echo "Unknown network '${NETWORK}'." ;;
esac
done
}
# Sets VERSION from the CLI argument or a prompt, then validates it.
resolve_version() {
VERSION="${1:-}"
[[ -n "$VERSION" ]] || read -rp "Version (e.g. 3.14.0): " VERSION
check_version "$VERSION"
}
resolve_network "${1:-}"
resolve_version "${2:-}"
resolve_dev_cluster "$NETWORK"
prompt_nomad_ip "$NETWORK"
[[ -n "${NOMAD_HTTP_AUTH+set}" ]] || prompt_http_auth
prompt_node_addrs
cat <<EOF
Upgrading the ${NETWORK} dev cluster to ${VERSION}
contract: ${CONTRACT}
Nomad: ${NOMAD_ADDR}
Nomad auth: $(nomad_auth_state)
node metrics: ${MPC_NODE_ADDRS:-(none — verification will be skipped)}
EOF
confirm "Proceed?" || { echo "Aborted."; exit 0; }
step "### Step 1 — nodes"
run_cmd "${SCRIPT_DIR}/migrate-dev-nodes.sh" "$VERSION" \
|| die "Node upgrade did not complete — stopping before the contract step."
step "### Verify"
if [[ -n "${MPC_NODE_ADDRS:-}" ]]; then
run_step verify_nodes "$VERSION" || true
else
echo "No node addresses given — skipping the build-info check."
fi
run_step test_sign "$NETWORK" || true
step "### Step 2 — contract"
echo "Only for releases that change crates/contract (diff it between the two tags)."
CONTRACT_RESULT="skipped — nodes only"
if confirm "Upgrade the contract too?"; then
if run_cmd "${SCRIPT_DIR}/upgrade-dev-contract.sh" "$VERSION" "$NETWORK"; then
CONTRACT_RESULT="upgraded"
else
CONTRACT_RESULT="FAILED — see the output above"
fi
fi
echo
if [[ "$CONTRACT_RESULT" == FAILED* ]]; then
warn "Nodes done; contract step ${CONTRACT_RESULT}. Do not upgrade the mainnet dev cluster yet."
else
ok "Done (contract: ${CONTRACT_RESULT}). Testnet first — upgrade the mainnet dev cluster only once this one is healthy."
fi