You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2015/10/28 16:27:30 UTC
[13/14] 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/3fc742e2
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/3fc742e2
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/3fc742e2
Branch: refs/heads/YETUS-83
Commit: 3fc742e256a6e5e1cd6ef21e980bf3960c242bc8
Parents: 7e6c769
Author: Allen Wittenauer <aw...@apache.org>
Authored: Tue Oct 20 16:55:02 2015 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Wed Oct 28 08:23:29 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/3fc742e2/precommit/test-patch-docker/test-patch-docker.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/test-patch-docker.sh b/precommit/test-patch-docker/test-patch-docker.sh
index 8b19502..ca910ff 100755
--- a/precommit/test-patch-docker/test-patch-docker.sh
+++ b/precommit/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}')