diff options
author | Zhijiang Hu <hu.zhijiang@zte.com.cn> | 2017-02-07 07:53:08 -0500 |
---|---|---|
committer | Zhijiang Hu <hu.zhijiang@zte.com.cn> | 2017-02-07 08:18:56 -0500 |
commit | eadbe3d058d7241b130f8e8114989f38b4c0fa32 (patch) | |
tree | 00378484b5d233ae0beb18ab35ff0d88b82021b6 | |
parent | 35d0a0c0274dd7a298d691f0afcd8e745ef9f641 (diff) |
Resolve build silent failure
1) Add "-f" to docker rmi command, otherwise we encountered "Error
response from daemon: conflict: unable to remove repository ..."
2) Remove "2>&1" to get error message printed out if present.
3) Add cleanup_container, otherwise we got "Error response from
daemon: Conflict. The name "/daisy" is already in use by container"
Change-Id: Ic5cecb34699c6fbe0d3af45be38633d35bdfc89f
Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
-rwxr-xr-x | ci/build_rpm/build_rpms.sh | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh index c98747b6..811eb13a 100755 --- a/ci/build_rpm/build_rpms.sh +++ b/ci/build_rpm/build_rpms.sh @@ -25,11 +25,34 @@ function build_rpm_pkg { $OPNFV_ARTIFACT_VERSION } +function cleanup_container { + echo "Cleaning daisy container" + containers_to_kill=$(sudo docker ps --filter "name=daisy" \ + --format "{{.Names}}" -a) + + if [[ ! -z "$containers_to_kill" ]]; then + volumes_to_remove=$(sudo docker inspect -f \ + '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' \ + ${containers_to_kill} | egrep -v '(^\s*$)' | sort | uniq) + + echo "Stopping containers... $containers_to_kill" + (sudo docker stop -t 2 ${containers_to_kill} 2>&1) > /dev/null + echo "Removing containers... $containers_to_kill" + (sudo docker rm -v -f ${containers_to_kill} 2>&1) > /dev/null + + if [[ ! -z "$containers_to_kill" ]]; then + echo "Removing volumes... $volumes_to_remove" + (sudo docker volume rm ${volumes_to_remove} 2>&1) || true > /dev/null + fi + fi +} + function cleanup_docker_image { if [ ! -z "$(sudo docker images -q opnfv/daisy)" ]; then - sudo docker rmi opnfv/daisy >/dev/null 2>&1 + sudo docker rmi -f opnfv/daisy fi } +cleanup_container cleanup_docker_image build_rpm_pkg |