Skip to content

Commit 7e229db

Browse files
authored
fix: add migration script for flat-path firecracker binaries to amd64/ (#14)
* fix: add migration script for flat-path firecracker binaries to amd64/ Before ARM64 support was added, firecracker binaries were uploaded to GCS at the flat path firecrackers/{version}/firecracker. The orchestrator's arch-aware path resolution expects firecrackers/{version}/amd64/firecracker, so old builds are not found via the arch-based lookup. Add migrate-gcs-arch.sh to dry-run/copy (and optionally delete) existing flat-path GCS objects into the amd64/ subdirectory. * move migrate-gcs-arch.sh to scripts/ * simplify migration script: remove --delete-old * fix: don't hardcode firecrackers/ prefix, accept full GCS path * skip versions that already have amd64/firecracker
1 parent 70472f7 commit 7e229db

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

scripts/migrate-gcs-arch.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# Copies flat-path firecracker binaries into amd64/ subdirectories in GCS.
3+
#
4+
# Before ARM64 support was added, builds were uploaded as:
5+
# {version_name}/firecracker
6+
#
7+
# The arch-aware layout expects:
8+
# {version_name}/amd64/firecracker
9+
#
10+
# This script finds flat-path binaries and copies them into the amd64/ subdir
11+
# so the orchestrator's arch-based path resolution can find them.
12+
#
13+
# Usage:
14+
# ./scripts/migrate-gcs-arch.sh <bucket-or-path> # dry-run: show what would be copied
15+
# ./scripts/migrate-gcs-arch.sh <bucket-or-path> --apply # copy flat -> amd64/
16+
#
17+
# Examples:
18+
# ./scripts/migrate-gcs-arch.sh gs://e2b-staging-fc-versions
19+
# ./scripts/migrate-gcs-arch.sh gs://e2b-prod-public-builds/firecrackers --apply
20+
21+
set -euo pipefail
22+
23+
GCS_PATH="${1:?Usage: $0 <bucket-or-path> [--apply]}"
24+
shift
25+
26+
APPLY=false
27+
for arg in "$@"; do
28+
case "$arg" in
29+
--apply) APPLY=true ;;
30+
*) echo "Unknown flag: $arg"; exit 1 ;;
31+
esac
32+
done
33+
34+
# Normalize: strip trailing slash
35+
GCS_PATH="${GCS_PATH%/}"
36+
37+
echo "Scanning ${GCS_PATH} for flat-path firecracker binaries..."
38+
echo ""
39+
40+
# Match only flat-path binaries: {version}/firecracker
41+
# The single * does NOT match path separators, so this excludes
42+
# {version}/{arch}/firecracker.
43+
objects=$(gsutil ls "${GCS_PATH}/*/firecracker" 2>/dev/null || true)
44+
45+
if [[ -z "$objects" ]]; then
46+
echo "No flat-path firecracker binaries found in ${GCS_PATH}"
47+
exit 0
48+
fi
49+
50+
copied=0
51+
skipped=0
52+
while IFS= read -r src; do
53+
[[ -z "$src" ]] && continue
54+
55+
# Insert /amd64 before the filename:
56+
# .../v1.10.1/firecracker -> .../v1.10.1/amd64/firecracker
57+
dst="${src%/firecracker}/amd64/firecracker"
58+
59+
# Skip if destination already exists
60+
if gsutil -q stat "$dst" 2>/dev/null; then
61+
echo " SKIP $dst (already exists)"
62+
((skipped++)) || true
63+
continue
64+
fi
65+
66+
if [[ "$APPLY" == true ]]; then
67+
echo " COPY $src"
68+
echo " -> $dst"
69+
gsutil cp "$src" "$dst"
70+
else
71+
echo " [dry-run] $src"
72+
echo " -> $dst"
73+
fi
74+
((copied++)) || true
75+
done <<< "$objects"
76+
77+
echo ""
78+
echo "Total: $copied to copy, $skipped skipped (already exist)"
79+
if [[ "$APPLY" != true && "$copied" -gt 0 ]]; then
80+
echo ""
81+
echo "This was a dry run. Add --apply to actually copy."
82+
fi

0 commit comments

Comments
 (0)