Return-Path: X-Original-To: apmail-yetus-commits-archive@minotaur.apache.org Delivered-To: apmail-yetus-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17DF618712 for ; Wed, 21 Oct 2015 16:11:22 +0000 (UTC) Received: (qmail 3588 invoked by uid 500); 21 Oct 2015 16:11:12 -0000 Delivered-To: apmail-yetus-commits-archive@yetus.apache.org Received: (qmail 3548 invoked by uid 500); 21 Oct 2015 16:11:12 -0000 Mailing-List: contact commits-help@yetus.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@yetus.apache.org Delivered-To: mailing list commits@yetus.apache.org Received: (qmail 3532 invoked by uid 99); 21 Oct 2015 16:11:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2015 16:11:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 43522DFFAB; Wed, 21 Oct 2015 16:11:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aw@apache.org To: commits@yetus.apache.org Date: Wed, 21 Oct 2015 16:11:14 -0000 Message-Id: <02304f1531a24478860577ed407c86b9@git.apache.org> In-Reply-To: <074bb5ab7c4f41b48b9a120988b3abed@git.apache.org> References: <074bb5ab7c4f41b48b9a120988b3abed@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] yetus git commit: YETUS-94. docker cleanup invalid date YETUS-94. docker cleanup invalid date Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/e567c71a Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/e567c71a Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/e567c71a Branch: refs/heads/YETUS-83 Commit: e567c71a19cb325e40d23176e07f5d596a65e920 Parents: 5391279 Author: Allen Wittenauer Authored: Tue Oct 20 16:55:02 2015 -0700 Committer: Allen Wittenauer Committed: Wed Oct 21 09:11:13 2015 -0700 ---------------------------------------------------------------------- .../test-patch-docker/test-patch-docker.sh | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/e567c71a/dev-support/test-patch-docker/test-patch-docker.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch-docker/test-patch-docker.sh b/dev-support/test-patch-docker/test-patch-docker.sh index 8b19502..ca910ff 100755 --- a/dev-support/test-patch-docker/test-patch-docker.sh +++ b/dev-support/test-patch-docker/test-patch-docker.sh @@ -94,7 +94,7 @@ function stop_exited_containers # stop *all* containers that are in exit state for # more than > 8 hours - while read line; do + while read -r line; do id=$(echo "${line}" | cut -f1 -d' ') value=$(echo "${line}" | cut -f2 -d' ') size=$(echo "${line}" | cut -f3 -d' ') @@ -127,16 +127,22 @@ function stop_exited_containers ## @param args function rm_old_containers { - local line - local id - local value - local size + declare line + declare id + declare value + declare size + declare running - while read line; do + while read -r line; do id=$(echo "${line}" | cut -f1 -d, ) - state=$(echo "${line}" | cut -f2 -d, ) + running=$(echo "${line}" | cut -f2 -d, ) stoptime=$(echo "${line}" | cut -f3 -d, | cut -f1 -d. ) + if [[ ${running} = true ]]; then + yetus_debug "${id} is still running, skipping." + continue + fi + # believe it or not, date is not even close to standardized... if [[ $(uname -s) == Linux ]]; then @@ -148,13 +154,11 @@ function rm_old_containers stoptime=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${stoptime}" "+%s") fi - if [[ ${state} == false ]]; then - curtime=$(date "+%s") - ((difftime = curtime - stoptime)) - if [[ ${difftime} -gt 86400 ]]; then - echo "Removing docker ${id}" - dockercmd rm "${id}" - fi + curtime=$(date "+%s") + ((difftime = curtime - stoptime)) + if [[ ${difftime} -gt 86400 ]]; then + echo "Removing docker ${id}" + dockercmd rm "${id}" fi done < <( # see https://github.com/koalaman/shellcheck/issues/375 @@ -187,7 +191,7 @@ function remove_old_tagged_images local id local created - while read line; do + while read -r line; do id=$(echo "${line}" | awk '{print $1}') created=$(echo "${line}" | awk '{print $5}')