Skip to content

Commit

Permalink
APPS-2624 Put awscliv2 ecr get-login-password into retry loop (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-i-v-a authored Oct 4, 2024
1 parent 501106f commit 6aaf086
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## in develop

* Added [DIY Docker image instructions](./scripts/docker_image/). This replaces the Docker image published to Docker Hub, which is deprecated and will be removed after November 1, 2024.
* Added exponential backoff and retry, including attempt to get password from AWS, in ECR docker script template

## 2.11.7 2024-09-12

Expand Down
25 changes: 15 additions & 10 deletions compiler/src/main/resources/templates/ecr_docker_preamble.ssp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@
# disable echo to avoid logging password
set +x

# get the password from the aws client
password=${bashDollar}(awscliv2 ecr get-login-password --region ${bashDollar}{AWS_REGION})

# Log into docker. Retry several times.
i=0
while [[ ${bashDollar}i -le 5 ]]; do
# don't exit if docker command fails - retry instead
set +e
# TODO: use credential helper instead https://docs.docker.com/engine/reference/commandline/login/
echo ${bashDollar}{password} | docker login ${bashDollar}{DOCKER_REGISTRY} --username AWS --password-stdin
rc=${bashDollar}?
set -e
if [[ ${bashDollar}rc == 0 ]]; then
break

# get the password from the aws client
password=${bashDollar}(awscliv2 ecr get-login-password --region ${bashDollar}{AWS_REGION})
if [[ ${bashDollar}? -ne 0 ]]; then
echo "Could not get password from AWS"
else
# TODO: use credential helper instead https://docs.docker.com/engine/reference/commandline/login/
echo ${bashDollar}{password} | docker login ${bashDollar}{DOCKER_REGISTRY} --username AWS --password-stdin
rc=${bashDollar}?
if [[ ${bashDollar}rc == 0 ]]; then
break
fi
fi

set -e
sleep ${bashDollar}((2**i))
i=${bashDollar}((i + 1))
sleep 3
echo "retry docker login (${bashDollar}i)"
done

Expand Down

0 comments on commit 6aaf086

Please sign in to comment.