yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-94. docker cleanup invalid date
Date Thu, 29 Oct 2015 14:56:07 GMT
Repository: yetus
Updated Branches:
  refs/heads/master 09ae5616a -> d1a27cc41


YETUS-94. docker cleanup invalid date

Signed-off-by: Sean Busbey <busbey@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/d1a27cc4
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/d1a27cc4
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/d1a27cc4

Branch: refs/heads/master
Commit: d1a27cc41ed093240d790a6f37beb24a9a8e00da
Parents: 09ae561
Author: Allen Wittenauer <aw@apache.org>
Authored: Tue Oct 20 16:55:02 2015 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Thu Oct 29 07:55:47 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/d1a27cc4/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}')
 


Mime
View raw message