[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.45-102-g4c48ac2
Andreas Beckmann
debian at abeckmann.de
Fri Aug 3 08:51:52 UTC 2012
The following commit has been merged in the develop branch:
commit 1b96fa0439e2cce7aa5b2dba75343cf774f6ba65
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Sun Jul 22 03:07:28 2012 +0200
reschedule_oldest_logs: cleanup obsolete rescheduling requests
delete the log from recycle/ if no other copy of the log is left
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/debian/changelog b/debian/changelog
index 2a337d9..8f37209 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -59,7 +59,7 @@ piuparts (0.46) UNRELEASED; urgency=low
- Adjust for new layout, cleanup, simplify.
* conf/piuparts.apache: Set DefaultType text/plain (for the logfiles).
* reschedule_oldest_logs: Hardlink old logfiles to recycle/ instead of
- deleting them.
+ deleting them. Cleanup obsolete rescheduling requests.
* New helper script: master-bin/reclassify_bugged.
* New custom script post_setup_forbid_home: replace /home with a file to
prevent creating home directories there. (Closes: #677332)
diff --git a/master-bin/reschedule_oldest_logs b/master-bin/reschedule_oldest_logs
index caffa95..1a34097 100755
--- a/master-bin/reschedule_oldest_logs
+++ b/master-bin/reschedule_oldest_logs
@@ -49,14 +49,26 @@ get_config_value FAIL_AGE global reschedule-fail-days 30
get_config_value FAIL_COUNT global reschedule-fail-count 25
TOTAL=0
+UNSCHEDULE=0
LOGS=`mktemp`
LOGS2=`mktemp`
+OBSOLETE=$(mktemp)
OLDPWD=$(pwd)
for SECTION in $SECTIONS ; do
test -d $MASTER/$SECTION || continue
- >$LOGS
cd $MASTER/$SECTION
- mkdir -p pass fail affected recycle
+ mkdir -p pass fail bugged affected recycle
+
+ # Clean up obsolete rescheduling requests
+ for log in $(find recycle/ -name '*.log' | cut -d"/" -f2) ; do
+ for dir in pass bugged affected fail ; do
+ test ! -e "$dir/$log" || continue 2
+ done
+ echo "recycle/$log"
+ done | sort > $OBSOLETE
+
+ # Reschedule old logs
+ >$LOGS
get_config_value RESCHEDULE $SECTION auto-reschedule yes
if [ "$RESCHEDULE" = "yes" ]; then
get_config_value _AGE $SECTION reschedule-old-days $AGE
@@ -71,20 +83,31 @@ for SECTION in $SECTIONS ; do
test -f recycle/$(basename "$log") || echo "$log"
done > $LOGS
fi
- if [ -s $LOGS ]; then
+
+ if [ -s $LOGS ] || [ -s $OBSOLETE ]; then
COUNT=$(wc -l $LOGS | awk '{ print $1 }')
TOTAL=$(($TOTAL + $COUNT))
- echo "$SECTION: $COUNT"
- ls -dtl $(cat $LOGS)
- ln -f $(cat $LOGS) recycle/
+ UCOUNT=$(wc -l $OBSOLETE | awk '{ print $1 }')
+ UNSCHEDULE=$(($UNSCHEDULE + $UCOUNT))
+ echo "$SECTION: $COUNT/$UCOUNT"
+ if [ -s $LOGS ]; then
+ ls -dtl $(cat $LOGS)
+ ln -f $(cat $LOGS) recycle/
+ fi
+ if [ -s $OBSOLETE ]; then
+ rm -fv $(cat $OBSOLETE)
+ fi
echo
echo "#########################################################"
echo
fi
cd $OLDPWD
done
-rm $LOGS $LOGS2
+rm $LOGS $LOGS2 $OBSOLETE
if [ "$TOTAL" -gt "0" ]; then
- echo "Rescheduled $TOTAL logs"
+ echo "Rescheduled $TOTAL logs."
+fi
+if [ "$UNSCHEDULE" -gt "0" ]; then
+ echo "Cancelled $UNSCHEDULE outdated rescheduling requests."
fi
--
piuparts git repository
More information about the Piuparts-commits
mailing list