cleaner: Remove watcher's instance status file after 21 days
authorMichael Hanselmann <hansmi@google.com>
Thu, 4 Aug 2011 16:31:51 +0000 (18:31 +0200)
committerMichael Hanselmann <hansmi@google.com>
Fri, 5 Aug 2011 11:06:23 +0000 (13:06 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

daemons/ganeti-cleaner.in
test/ganeti-cleaner_unittest.bash

index ec5d8f7..0d93a6a 100644 (file)
@@ -55,7 +55,8 @@ cleanup_watcher() {
 
   # Remove old watcher files
   find $DATA_DIR -maxdepth 1 -type f -mtime +$REMOVE_AFTER \
-    -name 'watcher.*-*-*-*.data' -print0 | \
+    \( -name 'watcher.*-*-*-*.data' -or \
+       -name 'watcher.*-*-*-*.instance-status' \) -print0 | \
   xargs -r0 rm -vf
 }
 
index 367a27c..93bf5f4 100755 (executable)
@@ -56,10 +56,11 @@ count_jobs() {
 }
 
 count_watcher() {
-  local n=$1
+  local suffix="$1" n=$2
   local count=$(find $watcherdir -maxdepth 1 -type f \
-                  -name 'watcher.*.data' | wc -l)
-  [[ "$count" -eq "$n" ]] || err "Found $count watcher files instead of $n"
+                  -name "watcher.*-*-*-*.$suffix" | wc -l)
+  [[ "$count" -eq "$n" ]] || \
+    err "Found $count watcher files with suffix '$suffix' instead of $n"
 }
 
 count_and_check_certs() {
@@ -120,7 +121,8 @@ create_watcher_state() {
 
   i=0
   for uuid in ${uuids[@]}; do
-    touch -d "$(( 5 * i )) days ago" $watcherdir/watcher.$uuid.data
+    touch -d "$(( 5 * i )) days ago" \
+      $watcherdir/watcher.$uuid.{data,instance-status}
 
     let ++i
   done
@@ -197,8 +199,10 @@ count_jobs 31
 
 upto 'Watcher status files'
 create_watcher_state
-count_watcher 10
+count_watcher data 10
+count_watcher instance-status 10
 run_cleaner
-count_watcher 5
+count_watcher data 5
+count_watcher instance-status 5
 
 exit 0