From c0fe1e231354074b937368302607110df96d75ad Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 28 Nov 2016 19:50:42 -0500 Subject: [PATCH] dockcross: Ensure deletion error are ignored This commit follows up on 2e71db2 (dockcross: Ignore deletion error when running in unprivileged LXC container) by hiding the message only when (a) the command output matches the expected error message and (b) is executed on CircleCI. Doing so will avoid adding "noise" to log of service like CircleCI that are effectively running docker in unprivileged LXC container. See #50 --- imagefiles/dockcross | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/imagefiles/dockcross b/imagefiles/dockcross index b7823f7..1776c52 100755 --- a/imagefiles/dockcross +++ b/imagefiles/dockcross @@ -205,10 +205,17 @@ docker run $TTY_ARGS --name $CONTAINER_NAME \ $FINAL_IMAGE "$@" run_exit_code=$? -# Deleting the container while ignoring error is required because of -# https://circleci.com/docs/docker-btrfs-error/. -# See issue dockcross/dockcross#50 for more details. -docker rm -f $CONTAINER_NAME > /dev/null || true +# Attempt to delete container +rm_output=$(docker rm -f $CONTAINER_NAME 2>&1) +rm_exit_code=$? +if [[ $rm_exit_code != 0 ]]; then + if [[ "$CIRCLECI" == "true" ]] && [[ $rm_output == *"Driver btrfs failed to remove"* ]]; then + : # Ignore error because of https://circleci.com/docs/docker-btrfs-error/ + else + echo "$rm_output" + exit $rm_exit_code + fi +fi exit $run_exit_code