BugBusting / GNATS Auto Assignment

The toolset

The tools are located on hub.freebsd.org in /g/hubgnats/gnats-aa. You can access them by su - gnats-aa on hub. Ask clusteradm@ to get access to it, since it has to do with magically Kerberos thingies.

The directory structure is:

[gnats-aa@hub ~]$ ls -l
total 36
drwx------  2 gnats-aa  gnats-aa    512 Sep  5  2008 Mail
drwxr-xr-x  9 gnats-aa  gnats-aa    512 Jun 21  2006 incoming-PRs
drwxr-xr-x  2 gnats-aa  gnats-aa    512 Aug 27 01:30 mail
drwxr-xr-x  6 gnats-aa  gnats-aa    512 Aug 27 00:09 modules
-r-xr-xr-x  1 gnats-aa  gnats-aa  28492 Sep  6  2008 portsnap

[gnats-aa@hub ~/incoming-PRs]$ ls -al
total 14
drwxr-xr-x   2 gnats-aa  gnats-aa   512 Apr 22  2008 bin
drwxr-xr-x   2 gnats-aa  gnats-aa   512 Jun 21  2006 data
drwxr-xr-x   2 gnats-aa  gnats-aa   512 Jun 21  2006 etc
drwxr-xr-x   3 gnats-aa  gnats-aa   512 Jun 21  2006 local
drwxr-xr-x   2 gnats-aa  gnats-aa   512 May 18  2009 log
drwxr-xr-x  69 gnats-aa  gnats-aa  1536 Aug 26 00:22 ports
drwxr-xr-x   3 gnats-aa  gnats-aa  1024 Aug 27 00:13 portsnap

Automatic portsnap update

Every four hours, portsnap updates the ports directory:

[gnats-aa@hub ~]$ crontab -l
0 */4 * * * /g/hubgnats/gnats-aa/incoming-PRs/bin/portsnap-update.sh

which does a run of portsnap with the "cron" and the "update" commands. The portsnap configuration is in the etc directory and has these configuration lines:

[gnats-aa@hub ~/incoming-PRs]$ grep hub etc/portsnap.conf
WORKDIR=/g/hubgnats/gnats-aa/incoming-PRs/portsnap
PORTSDIR=/g/hubgnats/gnats-aa/incoming-PRs/ports

Incoming email

It tracks the freebsd-ports-bugs mailinglist as the user gnats-aa@freebsd.org.

Incoming email for it comes in on hub and is via a .forward file forwarded to procmail:

[gnats-aa@hub ~]$ cat .forward
"|/usr/local/bin/procmail -t"

which checks if it is really related to freebsd-ports-bugs:

:0 ?
* ^List-Id: Ports bug reports .freebsd-ports-bugs.freebsd.org.$
{
        :0:gnats2.lock w
        |/g/hubgnats/gnats-aa/incoming-PRs/bin/scanmail.sh
        EXITCODE=$?
        :0:gnats1.lock c
        freebsd-pb
}

scanmail.sh is a lockf protection around scanmail3.pl.

How scanmail3.pl works

Scanmail3.pl works as follows:

  1. Parse the file lookups.txt, which is nothing more than a perl script, which contain the configuration magic. More later.
  2. Get the important data from the mail header (From:, Subject:) and the GNATS data (*-Changed-By, The following reply was to PR, Number, Category, Synopsis, Class).
  3. If *-Changed-By or "The following reply was to PR" are there, then this is not a new PR and we stop.
  4. From the Synopsis data we check if there is a string which looks like a category/portname (a la dns/dnstracer, www/apache22 etc)

    • If there is a string like category/portname, that is an "manual" override by us in case the scanmail.pl script can't properly decode it. More later.

  5. If the port is a new port, we stop.
  6. If the synopsis contains a string like bsd.*.mk (see lookups.txt), assign it to the right maintainer.
  7. If the category/portname string is not found, we stop. The logfile has shows a * as the first character in this case.
  8. With the category/portname we now have, we can check if ports/category/portname/ exists.
    • If it doesn't, go through a list of prefix-replacements (see lookups.txt).
    • If nothing can be found, then log it with a *.
  9. From the port itself, get the CATEGORIES and the MAINTAINER fields.
  10. If the Class is a maintainer-update, and the From: line is not the MAINTAINER, then fix it up.
    • This will fail when the submitter is the real maintainer but using a different email address. It happens.
  11. If the Class is a change-request and the From: line is the MAINTAINER, then fix it up.
    • Crappy authentication, we do our best.
  12. If the maintainer has a @FreeBSD.org email address, then make him the Responsible of the PR.
    • If s/he doesn't have ports committing privileges, then he just should put it back with "maintainer approved" status instead of complaining.
  13. Reassign the PR according to the preferences in lookups.txt
  14. Send email to maintainer about a new PR.
  15. Done!

How the reassigning works

See reassign() in scanmail3.pl (lame lame lame)

lookups.txt

The lookups.txt is a text file, with Perl code, which describes what has to happen with PRs of specific ports, categories and submitters.

prefix_replacements
To fix the portname from for example py26-jabber to py-jabber so that a port submitted as net-im/py26-jabber gets checked for in net-im/py-jabber.
overrules - emails
When the Responsible is X, then set it to Y.
overrules - ports
When the port is cat/portname, then the Responsible is Y.
mk_replacements
Who is in charge of a certain bsd.X.mk file.
reassign - maintainers

If the MAINTAINER is X@non-freebsd.org, then the responsible should be Y.

reassign - friends
If the MAINTAINER is X, then set the Responsible to Y.
reassign - submitters
If the submitter is X, then set the Responsible to Y.
reassign - grabbers - synopsis
If the Synopsis RE matches X, then set the Responsible to Y.
reassign - grabbers - category
If the category is X, then set the Responsible to Y.
reassign - grabbers - portname
If the portname RE matches X, then set the Responsible to Y.

Editing GNATS

The editing of GNATS happens by SSH-ing into freefall and issueing the change-pr command. The SSH username and key (without a passphrase, don't give it to anybody about it and keep ~/.ssh private!) are specified in the freefall() function.

Daily maintenance

90% of the incoming PRs come through fine, the last 10% might need a hand.

The issues are:

The easiest way to keep track of these ones is to run tail -f foo | grep ^* in a screen on hub and check it once per day.

BugBusting/Gnats-AA (last edited 2011-08-09 09:57:11 by ChrisRees)