Skip to content

Commit 81ebba3

Browse files
authored
Wait for docker build (#6013)
This is a short-term mitigation for pytorch/pytorch#141885 in which any changes touching `.ci/docker` would cause all the builds to fail until docker build workflow finishes building the images. At the moment, we don't have a good way to tell the build workflow to wait for the new docker image, so my fix here attempts to inject a delay when the action is called by `_linux_build`. It will wait up to 90 minutes for the Docker build to finish ### Testing pytorch/pytorch#142177
1 parent 52f2af2 commit 81ebba3

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/actions/calculate-docker-image/action.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ runs:
8787
DOCKER_IMAGE: ${{ steps.calculate-image.outputs.docker-image }}
8888
DOCKER_TAG: ${{ steps.calculate-image.outputs.docker-tag }}
8989
DOCKER_REGISTRY: ${{ inputs.docker-registry }}
90+
DOCKER_PUSH: ${{ inputs.push }}
9091
run: |
9192
set +e
9293
set -x
@@ -101,10 +102,25 @@ runs:
101102
102103
retry login "${DOCKER_REGISTRY}"
103104
104-
# Check if image already exists, if it does then skip building it
105-
if docker manifest inspect "${DOCKER_IMAGE}"; then
106-
exit 0
107-
fi
105+
START_TIME=$(date +%s)
106+
# Wait up to 90 minutes
107+
while [[ $(( $(date +%s) - 5400 )) -lt $START_TIME ]]; do
108+
# Check if image already exists, if it does then skip building it
109+
if docker manifest inspect "${DOCKER_IMAGE}"; then
110+
exit 0
111+
fi
112+
113+
# NB: This flag is used by Docker build workflow to push the image to ECR, so we can
114+
# use this to differentiate between the Docker build and regular build jobs. For the
115+
# latter, it will wait for the Docker images to become available before continuing
116+
if [ "${DOCKER_PUSH:-false}" == "true" ]; then
117+
# It's a Docker build job, let's build the image
118+
break
119+
else
120+
# It's a regular build job, wait for the image to become available
121+
sleep 300
122+
fi
123+
done
108124
109125
# NB: This part requires a full checkout. Otherwise, the merge base will
110126
# be empty. The default action would be to continue rebuild the image

0 commit comments

Comments
 (0)