@@ -11,6 +11,7 @@ VOLUMES_DIR=${DSTACK_E2E_VOLUMES_DIR:-$STATE_DIR/volumes}
1111ARTIFACT_DIR=${DSTACK_E2E_ARTIFACT_DIR:- $STATE_DIR / artifacts}
1212IMAGE_ROOT=${DSTACK_E2E_IMAGE_ROOT:-/ images}
1313IMAGE_NAME=${DSTACK_E2E_IMAGE_NAME:- dstack-0.6.0}
14+ OLD_IMAGE_NAME=${DSTACK_E2E_OLD_IMAGE_NAME:- dstack-0.5.11}
1415PLATFORM=${DSTACK_E2E_PLATFORM:- tdx}
1516
1617VMM_PORT=${DSTACK_E2E_VMM_PORT:- 29080}
@@ -65,13 +66,6 @@ if ! getent ahostsv4 "$KMS_RPC_DOMAIN" >/dev/null 2>&1; then
6566 exit 1
6667fi
6768
68- image_dir=" $IMAGE_ROOT /$IMAGE_NAME "
69- if [[ ! -d " $image_dir " ]]; then
70- echo " ERROR: image directory not found: $image_dir " >&2
71- echo " Set DSTACK_E2E_IMAGE_STORE to a host directory containing $IMAGE_NAME /" >&2
72- exit 1
73- fi
74-
7569digest_file=digest.txt
7670if [[ " $PLATFORM " == " amd-sev-snp" || " $PLATFORM " == " sev-snp" || " $PLATFORM " == " snp" ]]; then
7771 PLATFORM=amd-sev-snp
@@ -81,33 +75,49 @@ elif [[ "$PLATFORM" != tdx ]]; then
8175 exit 1
8276fi
8377
84- if [[ ! -s " $image_dir /$digest_file " ]]; then
85- echo " ERROR: missing $image_dir /$digest_file ; production-compatible E2E never permits an unpinned OS image" >&2
86- exit 1
87- fi
88- OS_IMAGE_HASH=$( tr -d ' [:space:]' < " $image_dir /$digest_file " )
89- if [[ ! " $OS_IMAGE_HASH " =~ ^[0-9a-f]{64}$ ]]; then
90- echo " ERROR: invalid OS image digest: $OS_IMAGE_HASH " >&2
91- exit 1
92- fi
78+ package_os_image () {
79+ local name=$1 image_dir=" $IMAGE_ROOT /$1 " image_hash
80+ if [[ ! -d " $image_dir " ]]; then
81+ echo " ERROR: image directory not found: $image_dir " >&2
82+ echo " Set DSTACK_E2E_IMAGE_STORE to a host directory containing $name /" >&2
83+ exit 1
84+ fi
85+ if [[ ! -s " $image_dir /$digest_file " ]]; then
86+ echo " ERROR: missing $image_dir /$digest_file ; production-compatible E2E never permits an unpinned OS image" >&2
87+ exit 1
88+ fi
89+ image_hash=$( tr -d ' [:space:]' < " $image_dir /$digest_file " )
90+ if [[ ! " $image_hash " =~ ^[0-9a-f]{64}$ ]]; then
91+ echo " ERROR: invalid OS image digest for $name : $image_hash " >&2
92+ exit 1
93+ fi
94+
95+ # Build the exact flat archive consumed by the KMS verifier. Verify the
96+ # source first and include only files named by sha256sum.txt.
97+ (
98+ cd " $image_dir "
99+ sha256sum -c sha256sum.txt >&2
100+ mapfile -t measured_files < <( awk ' {print $2}' sha256sum.txt)
101+ for file in " ${measured_files[@]} " ; do
102+ [[ " $file " != * /* && -f " $file " ]] || {
103+ echo " ERROR: unsafe or missing measured image file: $file " >&2
104+ exit 1
105+ }
106+ done
107+ tar -czf " $ARTIFACT_DIR /os/mr_${image_hash} .tar.gz.tmp" \
108+ sha256sum.txt " ${measured_files[@]} "
109+ )
110+ mv " $ARTIFACT_DIR /os/mr_${image_hash} .tar.gz.tmp" \
111+ " $ARTIFACT_DIR /os/mr_${image_hash} .tar.gz"
112+ printf ' %s' " $image_hash "
113+ }
93114
94- # Build the exact flat archive consumed by the KMS verifier. Verify the source
95- # first and include only the measured files named by sha256sum.txt.
96- (
97- cd " $image_dir "
98- sha256sum -c sha256sum.txt
99- mapfile -t measured_files < <( awk ' {print $2}' sha256sum.txt)
100- for file in " ${measured_files[@]} " ; do
101- [[ " $file " != * /* && -f " $file " ]] || {
102- echo " ERROR: unsafe or missing measured image file: $file " >&2
103- exit 1
104- }
105- done
106- tar -czf " $ARTIFACT_DIR /os/mr_${OS_IMAGE_HASH} .tar.gz.tmp" \
107- sha256sum.txt " ${measured_files[@]} "
108- )
109- mv " $ARTIFACT_DIR /os/mr_${OS_IMAGE_HASH} .tar.gz.tmp" \
110- " $ARTIFACT_DIR /os/mr_${OS_IMAGE_HASH} .tar.gz"
115+ OS_IMAGE_HASH=$( package_os_image " $IMAGE_NAME " )
116+ if [[ " $OLD_IMAGE_NAME " == " $IMAGE_NAME " ]]; then
117+ OLD_OS_IMAGE_HASH=$OS_IMAGE_HASH
118+ else
119+ OLD_OS_IMAGE_HASH=$( package_os_image " $OLD_IMAGE_NAME " )
120+ fi
111121
112122token_file=" $STATE_DIR /gateway-admin-token"
113123if [[ ! -s " $token_file " ]]; then
@@ -237,8 +247,10 @@ VM_DIR=$VM_DIR
237247ARTIFACT_DIR=$ARTIFACT_DIR
238248IMAGE_ROOT=$IMAGE_ROOT
239249IMAGE_NAME=$IMAGE_NAME
250+ OLD_IMAGE_NAME=$OLD_IMAGE_NAME
240251PLATFORM=$PLATFORM
241252OS_IMAGE_HASH=$OS_IMAGE_HASH
253+ OLD_OS_IMAGE_HASH=$OLD_OS_IMAGE_HASH
242254VMM_PORT=$VMM_PORT
243255AUTH_PORT=$AUTH_PORT
244256ARTIFACT_PORT=$ARTIFACT_PORT
@@ -271,5 +283,6 @@ echo " auth: http://10.0.2.2:${AUTH_PORT}"
271283echo " artifacts: http://10.0.2.2:${ARTIFACT_PORT} "
272284echo " old KMS: https://${KMS_RPC_DOMAIN} :${KMS_OLD_HOST_PORT} "
273285echo " latest KMS: https://${KMS_RPC_DOMAIN} :${KMS_LATEST_HOST_PORT} "
274- echo " image: ${IMAGE_NAME} (${OS_IMAGE_HASH} )"
286+ echo " current image: ${IMAGE_NAME} (${OS_IMAGE_HASH} )"
287+ echo " old image: ${OLD_IMAGE_NAME} (${OLD_OS_IMAGE_HASH} )"
275288echo " gateway app: ${GATEWAY_APP_ID} "
0 commit comments