Skip to content

Commit 9f1e08d

Browse files
authored
Enable specifying whether or not to pull the docker image from ECR (#6836)
We originally tried to simplify the number of parameters users had to pass in to linux_job_v2 by using the existence of the docker build script as a heuristic. That worked for a while, but that heuristic is now starting to break. If a repo has an unrelated docker build script located in `.ci/docker/build.sh`, we assume it wants to pull from our custom ECR path instead of docker hub. Our ideal end state would now look like: 1. Have an explicit parameter that needs to be set if a repo wants to use our ECR registries instead of assuming the desire based on the existence of a specific file. We default to docker hub 2. Migration to this end state would include fix all existing domain repos that have that docker build file defined to pass in that parameter. That migration requires many repos to be edited with a fix however, so for now we're having the following non-breaking change: 1. Have an explicit parameter on linux_job_v2 that needs to be set if a repo wants to use our ECR registries. *Set it to TRUE by default*, with the calculate-docker-image logic being "If param is set to True AND special docker file exists" then we use the ECR registry. If either is false, use docker hub 2. No migrations needed in the short term. We can later migrate domain repos to explicitly set this setting and then change the default to FALSE, but that's P2 Testing: Ran [this job](https://github.com/pytorch/pytorch/actions/runs/15884049575/job/44791525110) against it, and it only failed due to an error in the script inputted to the workflow, which is ignorable
1 parent 2af6c96 commit 9f1e08d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Calculate docker image
33
description: Determine docker image to pull, building a new one if necessary.
44

55
inputs:
6+
use-custom-docker-registry:
7+
description: "Use the custom ECR registry. Applies only if build.sh exists in docker-build-dir."
8+
default: true
9+
type: boolean
610
docker-image-name:
711
description: |
812
The name of a docker image, like `pytorch-linux-focal-linter`. A fullname
@@ -57,21 +61,22 @@ runs:
5761
DOCKER_BUILD_DIR: ${{ inputs.docker-build-dir }}
5862
DOCKER_BUILD_SCRIPT: ${{ inputs.docker-build-script }}
5963
DOCKER_REGISTRY: ${{ inputs.docker-registry }}
64+
USE_CUSTOM_DOCKER_REGISTRY: ${{ inputs.use-custom-docker-registry }}
6065
CUSTOM_TAG_PREFIX: ${{ inputs.custom-tag-prefix }}
6166
run: |
6267
set -ex
6368
6469
# If the docker build directory or the build script doesn't exist, the action will
6570
# gracefully return the docker image name as it is. Pulling docker image in Linux
6671
# job could then download the pre-built image as usual
67-
if [[ ! -d "${DOCKER_BUILD_DIR}" ]] || [[ ! -f "${DOCKER_BUILD_DIR}/${DOCKER_BUILD_SCRIPT}" ]]; then
72+
if [[ -d "${DOCKER_BUILD_DIR}" ]] && [[ -f "${DOCKER_BUILD_DIR}/${DOCKER_BUILD_SCRIPT}" ]] && [[ "${USE_CUSTOM_DOCKER_REGISTRY}" == "true" ]]; then
73+
echo "skip=false" >> "${GITHUB_OUTPUT}"
74+
else
6875
echo "skip=true" >> "${GITHUB_OUTPUT}"
6976
echo "docker-image=${DOCKER_IMAGE_NAME}" >> "${GITHUB_OUTPUT}"
7077
71-
echo "There is no Docker build script in ${REPO_NAME} repo, skipping..."
78+
echo "Not using custom ECR registry. Either it was not requested or there is no Docker build script in the ${REPO_NAME} repo..."
7279
exit 0
73-
else
74-
echo "skip=false" >> "${GITHUB_OUTPUT}"
7580
fi
7681
7782
if [[ "${DOCKER_IMAGE_NAME}" == *"${DOCKER_REGISTRY}/${REPO_NAME}"* ]]; then

.github/workflows/linux_job_v2.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ on:
5858
description: "Test infra reference to use"
5959
default: ""
6060
type: string
61+
use-custom-docker-registry:
62+
description: "Use the custom ECR registry. Applies only if build.sh exists in docker-build-dir."
63+
default: true
64+
type: boolean
6165
docker-image:
6266
description: Identifies the Docker image by name.
6367
default: "pytorch/almalinux-builder"
@@ -189,6 +193,7 @@ jobs:
189193
id: calculate-docker-image
190194
uses: ./test-infra/.github/actions/calculate-docker-image
191195
with:
196+
use-custom-docker-registry: ${{ inputs.use-custom-docker-registry }}
192197
docker-image-name: ${{ env.DOCKER_IMAGE }}
193198
docker-build-dir: ${{ inputs.docker-build-dir }}
194199
# This needs to be where the repository is checked out

0 commit comments

Comments
 (0)