Skip to content

Commit c224604

Browse files
add image name and version validation for persistent volumes
1 parent 05dca8e commit c224604

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
sha: ${{ needs.setup.outputs.sha }}
9898
images: ${{ needs.setup.outputs.images }}
9999
archs: ${{ needs.setup.outputs.archs }}
100+
tag-prefix: ${{ needs.setup.outputs.tag-prefix }}
100101

101102
test:
102103
name: 3 test

.github/workflows/internal-build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ on:
4444
description: "A prefix added to all cache keys generated by this workflow"
4545
type: "string"
4646
default: "quickstart-"
47+
tag-prefix:
48+
description: "Tag prefix for image name (e.g. v876-b123.1-)"
49+
type: "string"
50+
default: ""
4751

4852
env:
4953
artifact_retention_days_for_image: 7
@@ -315,6 +319,7 @@ jobs:
315319
-t quickstart:${{ matrix.image.tag }}-${{ matrix.arch }}
316320
--label org.opencontainers.image.revision="${{ inputs.sha }}"
317321
--build-arg REVISION="${{ inputs.sha }}"
322+
--build-arg IMAGE_NAME="stellar/quickstart:${{ inputs.tag-prefix }}${{ matrix.image.tag }}"
318323
${{ steps.dep_args.outputs.args }}
319324
.
320325
- name: Save Quickstart Image

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ FROM ubuntu:24.04 AS quickstart
221221
ARG REVISION
222222
ENV REVISION=$REVISION
223223

224+
ARG IMAGE_NAME
225+
ENV IMAGE_NAME=$IMAGE_NAME
226+
224227
EXPOSE 5432
225228
EXPOSE 6060
226229
EXPOSE 6061

start

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ function validate_after_copy_defaults() {
9090
function start() {
9191
echo "Starting Stellar Quickstart"
9292

93+
validate_persistent_volume_version
94+
9395
echo "versions:"
9496
echo " quickstart: $REVISION"
9597
echo " xdr:"
@@ -327,6 +329,55 @@ function set_pg_password() {
327329

328330
}
329331

332+
function validate_persistent_volume_version() {
333+
local version_file="$STELLAR_HOME/.quickstart-version.json"
334+
if [ -f "$version_file" ]; then
335+
local init_revision=$(< "$version_file" jq -r '.revision')
336+
local init_image=$(< "$version_file" jq -r '.image')
337+
338+
# Check for mismatch: compare revisions, and images if both are set
339+
local mismatch=false
340+
if [ "$init_revision" != "$REVISION" ]; then
341+
mismatch=true
342+
elif [ -n "$init_image" ] && [ -n "$IMAGE_NAME" ] && [ "$init_image" != "$IMAGE_NAME" ]; then
343+
mismatch=true
344+
fi
345+
346+
if [ "$mismatch" = "true" ]; then
347+
local yellow=$(echo -e "\e[33m")
348+
local red=$(echo -e "\e[31m")
349+
local bold=$(echo -e "\e[1m")
350+
echo ""
351+
echo "${red}${bold}╔══════════════════════════════════════════════════════════════════╗${clear}"
352+
echo "${red}${bold}║ ⚠️ VERSION MISMATCH WARNING ║${clear}"
353+
echo "${red}${bold}╚══════════════════════════════════════════════════════════════════╝${clear}"
354+
echo ""
355+
echo "${yellow}The persistent volume was initialized with a different version.${clear}"
356+
echo ""
357+
if [ -n "$init_image" ]; then
358+
echo " Initialized with: ${bold}$init_revision ($init_image)${clear}"
359+
else
360+
echo " Initialized with: ${bold}$init_revision${clear}"
361+
fi
362+
if [ -n "$IMAGE_NAME" ]; then
363+
echo " Running with: ${bold}$REVISION ($IMAGE_NAME)${clear}"
364+
else
365+
echo " Running with: ${bold}$REVISION${clear}"
366+
fi
367+
echo ""
368+
echo "${yellow}Persistent volumes may contain incompatible data across versions.${clear}"
369+
echo ""
370+
if [ -n "$init_image" ]; then
371+
echo "To run with the original version:"
372+
echo " ${cyan}docker run ... $init_image${clear}"
373+
echo ""
374+
fi
375+
echo "To use the new version, remove the persistent volume and start fresh."
376+
echo ""
377+
fi
378+
fi
379+
}
380+
330381
function copy_defaults() {
331382
local CP="rsync -a"
332383

@@ -421,6 +472,18 @@ function copy_defaults() {
421472
$CP /opt/stellar-default/$NETWORK/galexie/ $GALEXIEHOME
422473
fi
423474
fi
475+
476+
# Save version info on first initialization
477+
local version_file="$STELLAR_HOME/.quickstart-version.json"
478+
if [ ! -f "$version_file" ]; then
479+
jq -n --arg revision "$REVISION" --arg image "$IMAGE_NAME" \
480+
'{revision: $revision, image: $image}' > "$version_file"
481+
if [ -n "$IMAGE_NAME" ]; then
482+
echo "version: saved $REVISION ($IMAGE_NAME)"
483+
else
484+
echo "version: saved $REVISION"
485+
fi
486+
fi
424487
}
425488

426489
function copy_pgpass() {
@@ -959,5 +1022,4 @@ function horizon_status() {
9591022
done
9601023
echo "horizon: ingestion caught up"
9611024
}
962-
9631025
main $@

0 commit comments

Comments
 (0)