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

Delete quick start docker images when error happens #4248

Merged
merged 2 commits into from
Mar 6, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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