Commit 6890cf2e authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cleaner: Remove watcher's instance status file after 21 days


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 0e5084ee
......@@ -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
}
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment