Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Delete quick start docker images when error happens (#4248)
Browse files Browse the repository at this point in the history
  • Loading branch information
hzy46 authored Mar 6, 2020
1 parent 985cd4e commit a84fbe9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions contrib/kubespray/script/service-boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ OPENPAI_IMAGE_TAG=`cat ${CLUSTER_CONFIG} | grep docker-image-tag | tr -d "[:spac
echo "Branch Name ${OPENPAI_BRANCH_NAME}"
echo "OpenPAI Image Tag ${OPENPAI_IMAGE_TAG}"

function cleanup(){
sudo docker stop dev-box-quick-start &> /dev/null
sudo docker rm dev-box-quick-start &> /dev/null
}

sudo docker run -itd \
-e COLUMNS=$COLUMNS -e LINES=$LINES -e TERM=$TERM \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand All @@ -30,7 +35,7 @@ sudo docker run -itd \
--name=dev-box-quick-start \
openpai/dev-box:${OPENPAI_IMAGE_TAG}

sudo docker exec -it dev-box-quick-start kubectl get node
sudo docker exec -it dev-box-quick-start kubectl get node || { cleanup; exit 1; }

# Work in dev-box
sudo docker exec -i dev-box-quick-start /bin/bash << EOF_DEV_BOX
Expand Down Expand Up @@ -68,5 +73,9 @@ echo -e "pai\n" | python paictl.py config push -p /cluster-configuration -m serv
echo -e "pai\n" | python paictl.py service start
EOF_DEV_BOX

sudo docker stop dev-box-quick-start
sudo docker rm dev-box-quick-start
if [ $? -eq 0 ]; then
cleanup
exit 1
else
cleanup
fi

0 comments on commit a84fbe9

Please sign in to comment.