Skip to content

Commit 0b68189

Browse files
gkalpakkara
authored andcommitted
fix(docs-infra): better detect failed attempts to update the preview server Docker container (angular#37015)
In order to avoid unnecessary operations, the `update-preview-server.sh` script, that is used to update the PR preview server Docker container, will only try to update the Docker container if either any files in the `aio/aio-builds-setup/` directory have changed since the last update or if a previous update failed. A failed previous update is detected by checking whether the temporary `aio-builds:provisional` Docker image still exists. This temporary image is created during the update operation and is renamed to `aio-builds:latest` if the update goes well. Previously, the update script was not able to detect a previous failed attempt if the operation failed before creating the `aio-builds:provisional` Docker image, such as if the `create-image.sh` script failed. This could lead to a situation where the preview server Docker container would not be updated after a failed attempt. This commit improves the logic for detecting failed attempts to account for this type of failures. It does this by not removing an older `aio-builds:provisional` Docker image until a new one is successfully created. NOTE: While this is not full-proof, it is an improvement as it eliminates a certain kind of failures. PR Close angular#37015
1 parent b811212 commit 0b68189

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

aio/aio-builds-setup/scripts/update-preview-server.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ readonly HOST_LOCALCERTS_DIR=$4
1313
readonly HOST_LOGS_DIR=$5
1414

1515
# Constants
16-
readonly PROVISIONAL_IMAGE_NAME=aio-builds:provisional
16+
readonly PROVISIONAL_TAG=provisional
17+
readonly PROVISIONAL_IMAGE_NAME=aio-builds:$PROVISIONAL_TAG
1718
readonly LATEST_IMAGE_NAME=aio-builds:latest
1819
readonly CONTAINER_NAME=aio
1920

@@ -30,7 +31,7 @@ readonly CONTAINER_NAME=aio
3031
# Do not update the server unless files inside `aio-builds-setup/` have changed
3132
# or the last attempt failed (identified by the provisional image still being around).
3233
readonly relevantChangedFilesCount=$(git diff --name-only $lastDeployedCommit...HEAD | grep -P "^aio/aio-builds-setup/" | wc -l)
33-
readonly lastAttemptFailed=$(sudo docker rmi "$PROVISIONAL_IMAGE_NAME" >> /dev/fd/3 && echo "true" || echo "false")
34+
readonly lastAttemptFailed=$(sudo docker image ls | grep "$PROVISIONAL_TAG" >> /dev/fd/3 && echo "true" || echo "false")
3435
if [[ $relevantChangedFilesCount -eq 0 ]] && [[ "$lastAttemptFailed" != "true" ]]; then
3536
echo "Skipping update because no relevant files have been touched."
3637
exit 0

0 commit comments

Comments
 (0)