loop waiting for containerd server to respond

Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
Mike Brown 2017-08-02 16:39:39 -05:00
parent a14153a218
commit 6a9152e83f

View File

@ -61,7 +61,16 @@ if [ ! -x "$(command -v containerd)" ]; then
fi fi
sudo pkill containerd sudo pkill containerd
sudo containerd -l debug &> ${REPORT_DIR}/containerd.log & sudo containerd -l debug &> ${REPORT_DIR}/containerd.log &
sleep 1 # sleep 1 seconds for containerd to be ready.
# Wait for containerd to be running by using the containerd client ctr to check the version
# of the containerd server. Wait an increasing amount of time after each of five attempts
MAX_ATTEMPTS=5
attempt_num=1
until sudo ctr version &> /dev/null || (( attempt_num == MAX_ATTEMPTS ))
do
echo "Attempt $attempt_num to connect to containerd failed! Trying again in $attempt_num seconds..."
sleep $(( attempt_num++ ))
done
# Start cri-containerd # Start cri-containerd
cd ${ROOT} cd ${ROOT}