wikibugs

From mediawiki.org

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

After restart, the bot joins only #wikimedia-cloud connect 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 wikibugs-phab and polls the API, and inserts all task events into a redis queue
grrrrit.py
Runs as grrrrit and listens to the Gerrit stream-events feed, and inserts all changes events into a redis queue
redis2irc.py
Runs as redis2irc, 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.

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. For the most part, this is self-serve and up to the people who operate and participate in each individual channel. Many people have +2 on the repository, if you are trusted, please ask and we can add you.

Note that before wikibugs can be added to a new channel, it must be autovoiced in that channel to avoid issues with the ozone anti-spam bot (T283983). Please do not merge changes which add wikibugs to a new channel until a wikibugs maintainer has checked this step.

IRC channel operators can do: /msg chanserv flags <#channel> wikibugs +Vv to set the correct flags.

Deploying changes[edit]

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

You need to ssh into login.toolforge.org and run the following commands:

$ become wikibugs # sudo -i become wikibugs if you're in sudoers but not a member of tools.wikibugs
$ kubectl get pods
NAME                             READY   STATUS    RESTARTS   AGE
wikibugs-5d8d594cbf-77vvc        1/1     Running   0          10h     # this is the webservice, not the irc bot!
redis2irc-75db4dcbd7-t98wq       1/1     Running   0          150m    # the wikibugs irc bot
grrrrit-654f9884bd-m9n6z         1/1     Running   0          150m    # the gerrit listener
wikibugs-phab-74d6bbf6bf-bhlp7   1/1     Running   0          150m    # the phabricator listener

$ kubectl delete pod grrrrit-654f9884bd-m9n6z        # this will restart grrrrit

To (re)start all jobs, run the following:

$ become wikibugs # sudo -i become wikibugs if you're in sudoers but not a member of tools.wikibugs
$ toolforge-jobs load libera/k8s-jobs.yaml

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:~$ toolforge-jobs delete wikibugs-phab

To restart an individual job, we currently have to manually start the job from the command line:

user@tools-bastion-03:~$ become wikibugs
tools.wikibugs@tools-bastion-03:~$ cat libera/k8s-jobs.yaml
...
- name: wikibugs-phab
  command: libera/wrapper.sh wikibugs
  image: tf-python39
  continuous: true
  emails: all
...

# this then becomes the following command:
tools.wikibugs@tools-bastion-03:~$ toolforge-jobs run wikibugs-phab --command "libera/wrapper.sh wikibugs" --image tf-python39 --continuous --emails all

Check wikibugs server log[edit]

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 Libera Chat 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 libera-irc, wait for it to disappear from qstat, restart the job as normal (see Restarting wikibugs above). 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.

Help[edit]

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

  • legoktm
  • valhallasw

List of people who have access to the bot.

History[edit]

The first wikibugs, started in August 2004, was a Perl script that parsed Bugzilla's email messages, wrote them to a log file, and relied on ircecho to post them. In April 2014, the bot was rewritten in Python ("pywikibugs"), still parsing email messages, but using a Redis queue to post on IRC. Later in November 2014, the bot was rewritten again ("wikibugs2"), this time handling bugs from Phabricator rather than Bugzilla, but reused many of the ideas from pywikibugs such as a Redis queue and asyncio. In 2021, the bot left Freenode and moved to Libera Chat.

See also[edit]