wikibugs

From MediaWiki.org
Jump to navigation Jump to search

wikibugs is an IRC bot that idles in the #wikimedia-dev development channel (and others) on the freenode IRC network.

After restart, the bot joins only #wikimedia-cloud by default. Other channels are joined when the first relevant message to them is supposed to be sent.

Functions[edit]

The bot polls the phabricator API, listens to the Gerrit events feed, and posts changes to tasks and patches into various IRC channels.

  • wikibugs.py: Runs as wb2-phab and polls the API, and inserts all task events into a redis queue
  • grrrrit.py: Runs as wb2-grrrrit and listens to the Gerrit stream-events feed, and inserts all changes events into a redis queue
  • redis2irc.py: Runs as wb2-irc, reads from the redis-queue, and notifies various channels.
    • redis2stdout.py is useful when debugging if you don't want to have to connect to IRC all the time.

Source[edit]

The source for wikibugs can be found in Git:

https://gerrit.wikimedia.org/g/labs/tools/wikibugs2/

Including the channels list and gerrit-channels list.

Deploying changes[edit]

If your change just updates the channel list, the change should be deployed automatically.
Events that occur while restarting wb2-phab or wb2-grrrrit will not be reported.

Since Gerrit change 455347 deployment is performed using a 'manage.py' script in the tool directory.

The manage.py script provides the following commands:

  • manage.py deploy [job name] [job name]
    • This will pull changes, and will restart the jobs provided (see above for job names)
    • If no job names are provided, all jobs will be restarted
  • manage.py pull
    • pulls changes into the working directory
  • manage.py start_job [job name]
    • Starts (i.e., jsub) the provided job
  • manage.py start_jobs
    • This will start all jobs.
  • manage.py restart_job [job name]
    • Restarts (i.e., qmod -rj) the provided job

Muting wikibugs[edit]

There is currently no IRC-based method for this. Maintainers can kill the phabricator listener via:

user@tools-bastion-03:~$ become wikibugs
tools.wikibugs@tools-bastion-03:~$ qstat
job-ID  prior   name       user         state submit/start at     queue                          slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
4602105 0.39032 wb2-phab   tools.wikibu r     03/24/2016 04:29:15 continuous@tools-exec-1401.eqi     1
5736318 0.32072 lighttpd-w tools.wikibu r     04/28/2016 04:15:16 webgrid-lighttpd@tools-webgrid     1
6049120 0.30351 wb2-irc    tools.wikibu r     05/06/2016 19:56:31 continuous@tools-exec-1407.eqi     1

tools.wikibugs@tools-bastion-03:~$ qdel 4602105

The job can be restarted using fab start_jobs as described above. If you do not have access to fabric, run:

/usr/bin/jsub -N wb2-phab -l release=trusty -mem 1G -once -v PYTHONIOENCODING="utf8:backslashreplace" -continuous /data/project/wikibugs/py-wikibugs2/bin/python /data/project/wikibugs/wikibugs2/wikibugs.py --logfile /data/project/wikibugs/wikibugs.log
/usr/bin/jsub -N wb2-grrrrit -l release=trusty -mem 1G -once -v PYTHONIOENCODING="utf8:backslashreplace" -continuous /data/project/wikibugs/py-wikibugs2/bin/python /data/project/wikibugs/wikibugs2/grrrrit.py --logfile /data/project/wikibugs/grrrrit.log
/usr/bin/jsub -N wb2-irc -l release=trusty -mem 1G -once -v PYTHONIOENCODING="utf8:backslashreplace" -continuous /data/project/wikibugs/py-wikibugs2/bin/python /data/project/wikibugs/wikibugs2/redis2irc.py --logfile /data/project/wikibugs/redis2irc.log

Making wikibugs ignore certain users[edit]

In the case of a vandal attacking Phabricator, you likely want to quietly cause the bot to drop their messages (so Freenode stops killing the bot for flooding) without giving them the recognition of a commit.

In redis2irc.py, there is a function named handle_useful_info with an ignored tuple in it. Add the username to the tuple on labs, qdel wb2-irc, wait for it to disappear from qstat, then on your machine fab start_jobs. Then let it run for a while until the vandal's account has been disabled and all their messages have been popped from redis. Then reverse the change.

During this it will still be processing their phabricator edits behind the scenes so depending on volume it may be slow to post things to IRC.

Configuring channels[edit]

Update channels.yaml or gerrit-channels.yaml with the channel name and project name. Project names can be regular expressions and are case insensitive.

Note that before wikibugs can be added to a new channel, it must be whitelisted by freenode staff (gerrit:454263 has some more details). wikibugs maintainers will take care of this step when necessary.

Help[edit]

Find any of the following friendly people on IRC and they should be able to help you out:

  • legoktm
  • valhallasw

The list of people who have access to the bot can be found here.

See also[edit]