[Popcon-developers] Bug#462268: Bug#462268: Bug#462268: popcon: stay out of lenny for a while

Petter Reinholdtsen pere at hungry.com
Wed Mar 19 11:40:37 UTC 2008


[Bill Allombert]
> We move the popcon cronjob to cron.dayly, and pick a random weekday
> for each submitter. The dayly cronjob check if it is running on this
> weekday before reporting, else it abort immediatly.

Here is a draft patch to implement this.  It does not address the
renaming/moving of the cron job from cron.weekly to cron.daily.  This
need to be handled as well.  I hope splitting the submissions into 7
equal slots will reduce the load enough for all submissions to make it
thought.  If not, we might need to spread it out even further.

Index: cron.weekly
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/debian/cron.weekly,v
retrieving revision 1.25
diff -u -3 -p -r1.25 cron.weekly
--- cron.weekly	18 Mar 2008 08:38:32 -0000	1.25
+++ cron.weekly	19 Mar 2008 11:38:54 -0000
@@ -26,6 +26,11 @@ if [ -n "$HTTP_PROXY" ]; then
   export http_proxy="$HTTP_PROXY";
 fi
 
+# Only run on the given day, to spread the load on the server a bit
+if [ "$DAY" ] && [ "$DAY" != "$(date +%w)" ] ; then
+  exit 0
+fi
+
 # keep old logs
 cd /var/log
 umask 022
Index: postinst
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/debian/postinst,v
retrieving revision 1.19
diff -u -3 -p -r1.19 postinst
--- postinst	29 Oct 2006 08:58:26 -0000	1.19
+++ postinst	19 Mar 2008 11:38:54 -0000
@@ -34,8 +34,15 @@ generate_id() {
         fi
 }
 
+# Select a random day to submit on, to spread the load over time, unless it is already set.
+select_random_day() {
+       	RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
+       	DAY=$(($RANDOM % 7))
+}
+
 generate_conffile() {
         generate_id
+	select_random_day
 	cat <<-EOF >$conffile
 		# Config file for Debian's popularity-contest package.
 		#
@@ -50,6 +57,7 @@ generate_conffile() {
 		MY_HOSTID="$MY_HOSTID"
 		PARTICIPATE="$PARTICIPATE"
 		USEHTTP="yes"
+		DAY="$DAY"
 	EOF
 
 	# preseeding is only allowed on first time install
@@ -77,6 +85,13 @@ case "$1" in
             # of behaviour with stdin. version 1.17, 2004-04-12.
               *-)  MY_HOSTID="${MY_HOSTID%  -}";;
             esac;
+
+	    # If DAY is not set, add it.
+	    if [ -z "$DAY" ] ; then
+	        select_random_day
+	        echo "DAY=\"$DAY\"" >> $conffile
+	    fi
+
 	    # Replace only if the content changed, to avoid changing the
 	    # config file date when no change was done.
 

Happy hacking,
-- 
Petter Reinholdtsen





More information about the Popcon-developers mailing list