fix: require backend JSON readiness before activating a release
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
f4dd351f87
commit
2992c9e8f2
|
|
@ -50,7 +50,8 @@ overwrite a published release. A file lock
|
||||||
serializes activation. An older build cannot replace a newer active build.
|
serializes activation. An older build cannot replace a newer active build.
|
||||||
The `current` symlink changes atomically. HTTPS checks use the real hostname
|
The `current` symlink changes atomically. HTTPS checks use the real hostname
|
||||||
resolved to loopback and verify the certificate, release marker, homepage,
|
resolved to loopback and verify the certificate, release marker, homepage,
|
||||||
`/workspace`, `/cart`, and `/api/v1/health/ready`. Failure restores the previous
|
`/workspace`, `/cart`, and `/api/v1/health/ready`. Readiness must return the backend's
|
||||||
|
`{"status":"ok"}` response. An HTML fallback fails verification. Failure restores the previous
|
||||||
current symlink, or removes the first activation if no release existed before it.
|
current symlink, or removes the first activation if no release existed before it.
|
||||||
The last successful release is also retained at `previous`. Its assets can serve
|
The last successful release is also retained at `previous`. Its assets can serve
|
||||||
requests from browser tabs opened before the update. Failed first deployments
|
requests from browser tabs opened before the update. Failed first deployments
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,11 @@ mv -Tf "$temporary" current
|
||||||
served=$(curl --fail --silent --show-error --max-time 20 \
|
served=$(curl --fail --silent --show-error --max-time 20 \
|
||||||
--resolve "$host:443:127.0.0.1" "https://$host/release.txt")
|
--resolve "$host:443:127.0.0.1" "https://$host/release.txt")
|
||||||
test "$served" = "$release_id"
|
test "$served" = "$release_id"
|
||||||
for path in / /workspace /cart /api/v1/health/ready; do
|
for path in / /workspace /cart; do
|
||||||
curl --fail --silent --show-error --output /dev/null --max-time 20 \
|
curl --fail --silent --show-error --output /dev/null --max-time 20 \
|
||||||
--resolve "$host:443:127.0.0.1" "https://$host$path"
|
--resolve "$host:443:127.0.0.1" "https://$host$path"
|
||||||
done
|
done
|
||||||
|
ready=$(curl --fail --silent --show-error --max-time 20 \
|
||||||
|
--resolve "$host:443:127.0.0.1" "https://$host/api/v1/health/ready")
|
||||||
|
test "$(printf '%s' "$ready" | tr -d '[:space:]')" = '{"status":"ok"}'
|
||||||
echo "Activated $release_id on $host"
|
echo "Activated $release_id on $host"
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,17 @@ case "$*" in
|
||||||
else
|
else
|
||||||
cat "$DEPLOY_TEST_ROOT/current/release.txt"
|
cat "$DEPLOY_TEST_ROOT/current/release.txt"
|
||||||
fi ;;
|
fi ;;
|
||||||
*health/ready*) test ! -f "$DEPLOY_TEST_ROOT/fail-health" ;;
|
*health/ready*)
|
||||||
|
test ! -f "$DEPLOY_TEST_ROOT/fail-health" || exit 1
|
||||||
|
if [ -f "$DEPLOY_TEST_ROOT/html-readiness" ]; then
|
||||||
|
echo '<html>Page not found</html>'
|
||||||
|
else
|
||||||
|
echo '{"status":"ok"}'
|
||||||
|
fi ;;
|
||||||
esac
|
esac
|
||||||
MOCK
|
MOCK
|
||||||
chmod +x "$fixture/bin/curl"
|
chmod +x "$fixture/bin/curl"
|
||||||
for release in 1-aaa 2-bbb 3-ccc; do
|
for release in 1-aaa 2-bbb 3-ccc 4-ddd; do
|
||||||
mkdir -p "$fixture/site/incoming/$release/dist"
|
mkdir -p "$fixture/site/incoming/$release/dist"
|
||||||
printf '%s\n' "$release" > "$fixture/site/incoming/$release/dist/release.txt"
|
printf '%s\n' "$release" > "$fixture/site/incoming/$release/dist/release.txt"
|
||||||
printf '<html>Test</html>\n' > "$fixture/site/incoming/$release/dist/index.html"
|
printf '<html>Test</html>\n' > "$fixture/site/incoming/$release/dist/index.html"
|
||||||
|
|
@ -62,4 +68,7 @@ test "$(cat "$fixture/site/current/index.html")" = legacy
|
||||||
rm "$fixture/site/fail-health"
|
rm "$fixture/site/fail-health"
|
||||||
deploy 3-ccc
|
deploy 3-ccc
|
||||||
test "$(cat "$fixture/site/previous/index.html")" = legacy
|
test "$(cat "$fixture/site/previous/index.html")" = legacy
|
||||||
|
touch "$fixture/site/html-readiness"
|
||||||
|
if deploy 4-ddd; then echo 'Expected rollback when readiness serves HTML' >&2; exit 1; fi
|
||||||
|
test "$(cat "$fixture/site/current/release.txt")" = 3-ccc
|
||||||
printf 'Deployment activation, rollback and stale-build checks passed.\n'
|
printf 'Deployment activation, rollback and stale-build checks passed.\n'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue