yardstick-cleanup.sh: try to fix docker rmi failure 49/41649/1
authorRoss Brattain <ross.b.brattain@intel.com>
Tue, 12 Sep 2017 01:44:45 +0000 (18:44 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Tue, 12 Sep 2017 01:48:23 +0000 (18:48 -0700)
commit17328e1f83dc28f96f1b858d6ee7a7412dfbb8e8
tree2e2fe44970dd0f2452189ed415c3f46d78952f54
parenta3ef9d8f755464ac8af4cc19efae970d69251010
yardstick-cleanup.sh: try to fix docker rmi failure

apex builds seem to be failing to remove the yardstick
containers

https://build.opnfv.org/ci/job/yardstick-apex-baremetal-daily-master/400/console

[yardstick-apex-baremetal-daily-master] $ /bin/bash /tmp/hudson8974425724638109512.sh
Cleaning up docker containers/images...
Docker images to remove:
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
opnfv/yardstick              latest              5b83d8e60fb7        6 days ago          1.84GB
Removing docker image opnfv/yardstick:latest...
Error response from daemon: No such image: opnfv/yardstick:latest
Build step 'Execute shell' marked build as failure

For some reason we can't remove the yardstick container.

Try instead to remove based on ID

Replace grep | awk with just awk.

Also fixed shellcheck warnings:

In jjb/yardstick/yardstick-cleanup.sh line 6:
if [[ -n ${dangling_images} ]]; then
         ^-- SC2128: Expanding an array without an index only gives the first element.

In jjb/yardstick/yardstick-cleanup.sh line 10:
        containers=$(docker ps -a | grep $image_id | awk '{print $1}')
                                         ^-- SC2086: Double quote to prevent globbing and word splitting.

In jjb/yardstick/yardstick-cleanup.sh line 12:
            docker rm -f $containers >${redirect}
                         ^-- SC2086: Double quote to prevent globbing and word splitting.

In jjb/yardstick/yardstick-cleanup.sh line 14:
        docker rmi $image_id >${redirect}
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In jjb/yardstick/yardstick-cleanup.sh line 20:
if [[ ! -z $(docker ps -a | grep opnfv/yardstick) ]]; then
        ^-- SC2143: Use ! grep -q instead of comparing output with [ -z .. ].

In jjb/yardstick/yardstick-cleanup.sh line 27:
if [[ ! -z $(docker images | grep opnfv/yardstick) ]]; then
        ^-- SC2143: Use ! grep -q instead of comparing output with [ -z .. ].

In jjb/yardstick/yardstick-cleanup.sh line 33:
        docker rmi opnfv/yardstick:$tag >$redirect
                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

Change-Id: I6545ac7f568161e5620e31d487faf70fa21da075
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
jjb/yardstick/yardstick-cleanup.sh