feat: formation join token (#141)

This commit is contained in:
Julian Sommer
2026-04-15 16:55:55 +10:00
committed by GitHub
parent c8429f98ae
commit bb9cd8ea23
10 changed files with 352 additions and 61 deletions
+22 -1
View File
@@ -39,7 +39,26 @@ echo "Starting init node (127.0.0.1) and joining nodes (127.0.0.2, 127.0.0.3)...
INIT_PID=$!
# Wait for formation server to start
sleep 2
echo "Waiting for formation server..."
for i in $(seq 1 30); do
if curl -sk "https://127.0.0.1:4432/formation/health" > /dev/null 2>&1; then
echo "Formation server ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "ERROR: Formation server failed to start"
kill $INIT_PID 2>/dev/null || true
exit 1
fi
sleep 1
done
# Read join token
JOIN_TOKEN=$(cat ~/node1/config/join-token)
if [ -z "$JOIN_TOKEN" ]; then
echo "ERROR: Join token file is empty"
exit 1
fi
# Join nodes concurrently
./bin/spx admin join \
@@ -47,6 +66,7 @@ sleep 2
--bind 127.0.0.2 \
--cluster-bind 127.0.0.2 \
--host 127.0.0.1:4432 \
--token "$JOIN_TOKEN" \
--data-dir ~/node2/ \
--config-dir ~/node2/config/ \
--region ap-southeast-2 \
@@ -58,6 +78,7 @@ JOIN2_PID=$!
--bind 127.0.0.3 \
--cluster-bind 127.0.0.3 \
--host 127.0.0.1:4432 \
--token "$JOIN_TOKEN" \
--data-dir ~/node3/ \
--config-dir ~/node3/config/ \
--region ap-southeast-2 \
+9
View File
@@ -121,6 +121,14 @@ while ! curl -sk --connect-timeout 3 "https://$NODE1_IP:4432/formation/health" >
done
echo " Formation server ready"
# Read join token from init node
JOIN_TOKEN=$(remote "$NODE1_IP" "cat ~/spinifex/config/join-token")
if [ -z "$JOIN_TOKEN" ]; then
echo "Error: Failed to read join token from $NODE1_IP"
exit 1
fi
echo " Join token loaded from node1"
# Nodes 2..N: join
if [ "$NODE_COUNT" -gt 1 ]; then
JOIN_PIDS=()
@@ -134,6 +142,7 @@ if [ "$NODE_COUNT" -gt 1 ]; then
--cluster-bind $ip \
--cluster-routes $NODE1_IP:4248 \
--host $NODE1_IP:4432 \
--token $JOIN_TOKEN \
--data-dir ~/spinifex/ \
--config-dir ~/spinifex/config/ \
--region $REGION \
+5 -1
View File
@@ -329,7 +329,11 @@ if has_service "predastore"; then
PREDASTORE_CMD="./bin/spx service predastore start"
start_service "predastore" "$PREDASTORE_CMD"
set_oom_score "predastore" "-500"
check_service "Predastore" "$SPINIFEX_PREDASTORE_HOST" "$SPINIFEX_PREDASTORE_PORT"
if is_multinode; then
echo " ⏭️ Skipping Predastore connectivity check (multi-node: needs quorum from peer nodes)"
else
check_service "Predastore" "$SPINIFEX_PREDASTORE_HOST" "$SPINIFEX_PREDASTORE_PORT"
fi
else
echo "2️⃣ Skipping Predastore (not a local service)"
fi