Retry docker login

The run_docker_login fails intermittently due to authentication
failure. Currently operation is aborted without touching flag file,
which result subsequent operations are not completed.

This change is to add reattempt when docker login fails.

Closes-Bug: 1931268
Change-Id: Id6961b1b68f2fce07a3a65917eeaeadcd742f4f1
Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
Bin Qian 2021-06-08 11:01:48 -04:00
parent 81051adf46
commit c9721f3df0
1 changed files with 14 additions and 10 deletions

View File

@ -58,13 +58,17 @@ do
sleep 1
done
res=$(docker login --password-stdin -u ${DOCKER_USERNAME} registry.local:9001 2>&1 <<< ${DOCKER_PASSWORD})
rc=$?
if [ ${rc} -eq 0 ]
then
LOG "docker login to registry.local completed successfully"
touch /var/run/docker_login_done
else
LOG "docker login error ${rc} ${res}"
fi
while true
do
res=$(docker login --password-stdin -u ${DOCKER_USERNAME} registry.local:9001 2>&1 <<< ${DOCKER_PASSWORD})
rc=$?
if [ ${rc} -eq 0 ]
then
LOG "docker login to registry.local completed successfully"
touch /var/run/docker_login_done
break
else
LOG "docker login error ${rc} ${res}"
sleep 3
fi
done