Skip to content

Commit 9d64778

Browse files
author
Qasim Sarfraz
committed
Retry token
1 parent 2970d90 commit 9d64778

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

files/renew_token.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/bin/sh
22

3-
set -e
3+
set -xe
44

55
# update the auth token
66
CONFIG=/usr/local/openresty/nginx/conf/nginx.conf
77
AUTH=$(grep X-Forwarded-User $CONFIG | awk '{print $4}'| uniq|tr -d "\n\r")
8-
TOKEN=$(aws ecr get-login --no-include-email | awk '{print $6}')
8+
9+
# retry till new get new token
10+
while true; do
11+
TOKEN=$(aws ecr get-login --no-include-email | awk '{print $6}')
12+
[ ! -z "${TOKEN}" ] && break
13+
echo "Warn: Unable to get new token, wait and retry!"
14+
sleep 30
15+
done
16+
17+
918
AUTH_N=$(echo AWS:${TOKEN} | base64 |tr -d "[:space:]")
1019

1120
sed -i "s|${AUTH%??}|${AUTH_N}|g" $CONFIG

files/root

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Refresh the AWS ECR token periodically.
22
# min hour day month weekday command
3-
0 * * * * /renew_token.sh
3+
0 */6 * * * /renew_token.sh

0 commit comments

Comments
 (0)