[Popcon-developers] Bug#610876: popularity-contest: Popularity contest will not be run in certain machines due to the DAY variable
Bill Allombert
Bill.Allombert at math.u-bordeaux1.fr
Mon Mar 7 11:33:16 UTC 2011
On Sun, Mar 06, 2011 at 10:54:54AM -0800, Vagrant Cascadian wrote:
> tags 610876 patch
> thanks
>
> On Sun, Jan 23, 2011 at 05:35:08PM +0100, Alberto Aparici wrote:
> > Popularity-contest is intended to be run approximately once a week. Its
> ...snip...
> > But even this has a problem: some computers may not run 7 days
> > a week. A computer that only runs, for example, on weekends, and ends
> > up with DAY="3" will never run the popularity contest, not even with
> > anacron, because anacron will execute the popularity-contest script
> > but it will exit without running the contest, as it's not Wednesday :-(
>
> here's a patch that checks the last time /var/log/popularity-contest was
> updated, and exits if it was updated more recently than a week ago:
>
> diff -U 5 debian/cron.daily.orig debian/cron.daily
> --- debian/cron.daily.orig 2011-03-06 08:26:52.000000000 -0800
> +++ debian/cron.daily 2011-03-06 08:57:43.000000000 -0800
> @@ -29,15 +29,25 @@
> # Only run on the given day, to spread the load on the server a bit
> if [ "$DAY" ] && [ "$DAY" != "$(date +%w)" ] ; then
> exit 0
> fi
>
> +POPCON=/var/log/popularity-contest
> +if [ -z "$DAY" ] && [ -f "$POPCON" ] ; then
> + now=$(date +%s)
> + lastrun=$(date -r $POPCON +%s)
> + # one week, in seconds
> + week=604800
> + if [ "$(( $now - $lastrun ))" -le "$week" ]; then
> + exit 0
> + fi
> +fi
> +
> # keep old logs
> cd /var/log
> umask 022
> savelog -c 7 popularity-contest >/dev/null
> -POPCON=/var/log/popularity-contest
>
> run_popcon()
> {
> su -s /bin/sh -c "/usr/sbin/popularity-contest" nobody
> }
>
Is your patch valid with /bin/sh being dash ?
> it relies on the un-setting DAY in /etc/popularity-contest.conf, though maybe
> it would make sense to make it the default (by not setting DAY= in postinst)?
> that would make the first time cron.daily runs the effective day of week to run
> popularity-contest, rather than randomly selecting a day, while working
> reasonably sanely on machines that aren't always on.
Hello Vagrant,
This is an interesting suggestion. Maybe we would change the script to:
1) always try to report on DAY.
2) always try to report if /var/log/popularity-contest is more that 7 days old.
Using the first time cron.daily runs as the reporting day unsufficiently
random, especially with clusters.
A secondary issue is network access. If the script only report through HTTP, it
also needs network access to work, so if network is down we could retry the next day.
Cheers,
--
Bill. <ballombe at debian.org>
Imagine a large red swirl here.
More information about the Popcon-developers
mailing list