Skip to content

Commit 6b6e1c2

Browse files
committed
[green] Harden cache retirement and smoke rollback
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent f826fc8 commit 6b6e1c2

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

tools/web/deploy/nginx/10-pyble-dev-https.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ map $status $pyble_firmware_cache_control {
1414
# social cards out of caches while retaining the normal no-cache/no-transform
1515
# policy for the shared website 404 page.
1616
map $request_uri $pyble_not_found_cache_control {
17-
~^/social/pyble-beta-og-1200x630\.(?:png|svg)(?:\?|$) "no-store";
17+
"/social/pyble-beta-og-1200x630.png" "no-store";
18+
"/social/pyble-beta-og-1200x630.svg" "no-store";
19+
~^/social/pyble-beta-og-1200x630\.png\? "no-store";
20+
~^/social/pyble-beta-og-1200x630\.svg\? "no-store";
1821
~^/firmware/ "no-store";
1922
default "no-cache, no-transform";
2023
}

tools/web/deploy/vps/deploy.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,16 @@ rollback_on_smoke_error() {
10481048
fi
10491049
exit "${smoke_status}"
10501050
}
1051+
reject_post_activation_smoke() {
1052+
local smoke_status=$1
1053+
if [[ ! "${smoke_status}" =~ ^[1-9][0-9]*$ ||
1054+
"${smoke_status}" -gt 255 ]]; then
1055+
printf 'Invalid post-activation smoke status: %s.\n' \
1056+
"${smoke_status}" >&2
1057+
return 70
1058+
fi
1059+
return "${smoke_status}"
1060+
}
10511061
trap rollback_on_smoke_error ERR
10521062

10531063
smoke_root=$(mktemp -d)
@@ -1122,13 +1132,13 @@ for firmware_release in out/firmware/v*; do
11221132
if [[ "${firmware_path}" == "${checksum_line}" ]]; then
11231133
printf 'Invalid firmware checksum entry: %s\n' \
11241134
"${checksum_line}" >&2
1125-
exit 67
1135+
reject_post_activation_smoke 67
11261136
fi
11271137
case "${firmware_path}" in
11281138
""|/*|*\\*|*..*)
11291139
printf 'Unsafe firmware checksum path: %s\n' \
11301140
"${firmware_path}" >&2
1131-
exit 67
1141+
reject_post_activation_smoke 67
11321142
;;
11331143
esac
11341144
mkdir -p -- "$(dirname -- "${public_release}/${firmware_path}")"
@@ -1154,7 +1164,7 @@ readonly not_found_status=$(
11541164
if [[ "${not_found_status}" != 404 ]]; then
11551165
printf 'Public 404 smoke failed: expected 404, received %s.\n' \
11561166
"${not_found_status}" >&2
1157-
exit 66
1167+
reject_post_activation_smoke 66
11581168
fi
11591169

11601170
retired_public_asset_paths=(
@@ -1180,7 +1190,7 @@ for retired_public_asset_path in "${retired_public_asset_paths[@]}"; do
11801190
"${retired_public_asset_method}" \
11811191
"${retired_public_asset_path}" \
11821192
"${retired_public_asset_status}" >&2
1183-
exit 66
1193+
reject_post_activation_smoke 66
11841194
fi
11851195
retired_public_asset_normalized_headers="${retired_public_asset_headers}.normalized"
11861196
tr -d '\r' < "${retired_public_asset_headers}" > \
@@ -1190,7 +1200,7 @@ for retired_public_asset_path in "${retired_public_asset_paths[@]}"; do
11901200
printf 'Retired public asset smoke failed for %s %s: Cache-Control is not no-store.\n' \
11911201
"${retired_public_asset_method}" \
11921202
"${retired_public_asset_path}" >&2
1193-
exit 66
1203+
reject_post_activation_smoke 66
11941204
fi
11951205
done
11961206
retired_public_asset_index=$((retired_public_asset_index + 1))
@@ -1227,7 +1237,7 @@ for firmware_not_found_path in "${firmware_not_found_paths[@]}"; do
12271237
"${firmware_not_found_method}" \
12281238
"${firmware_not_found_path}" \
12291239
"${firmware_not_found_status}" >&2
1230-
exit 66
1240+
reject_post_activation_smoke 66
12311241
fi
12321242
firmware_not_found_normalized_headers="${firmware_not_found_headers}.normalized"
12331243
tr -d '\r' < "${firmware_not_found_headers}" > \
@@ -1237,7 +1247,7 @@ for firmware_not_found_path in "${firmware_not_found_paths[@]}"; do
12371247
printf 'Firmware 404 smoke failed for %s %s: Cache-Control is not no-store.\n' \
12381248
"${firmware_not_found_method}" \
12391249
"${firmware_not_found_path}" >&2
1240-
exit 66
1250+
reject_post_activation_smoke 66
12411251
fi
12421252
done
12431253
firmware_not_found_index=$((firmware_not_found_index + 1))

0 commit comments

Comments
 (0)