This is a partial revert of 57a669d35d
which added SASL auth support but in the process removed normal auth. In
order to support OFTC which doesn't currentl do SASL we add back in
normal auth support while keeping SASL for OFTC should they add the
functionality.
Change-Id: I191ced962e91226d196e6fae728484d8cd7233e2
If a user pushes a commit with an overly-long subject (most often
forgetting to separate it from the rest of the commit message with a
blank line), the resulting IRC message will be longer than the
protocol allows. In these cases, irc.client.MessageTooLong is
raised. This is an unfortunately all-too-common occurrence, so catch
it specifically in order to not enter the reconnect phase
needlessly. Log the failure to send, so that it can still be found
if someone is trying to identify the reason a change was not
announced.
Change-Id: I3cfaa3ea3b3f8f2de20bfe425c345385eb7cbba6
If we try to reconnect after an error sending a message to the IRC
server, clear the tracking of which channels are currently joined,
since none will be joined once reconnected. This fixes a
longstanding regression where the bot would appear to quit the
network and never return, when in actuality it just didn't know it
needed to rejoin channels once reconnected.
Change-Id: Ic865e307609285708c40e11a66b4b9643afc178e
WIP changes are likely to spam irc channels as they are not even
visible by default in dashboards. If we detect the WIP flag as present
and set to true, we just skip doing anything about that message.
Change-Id: Id4ee6c825e6d508c0c722d01ac8b1147b4025dbe
In Python 2, dict.keys() created a list copy of a dictionary's keys,
but in Python 3 it's an iterable tied to the original dict instead.
Modifying the data dict while iterating over its keys under Python 3
therefore causes items to get removed out from under the loop before
they're reached. Switch to using an explicit list copy instead for
iteration, and similarly save the result as an explicit list rather
than carrying over the iterable.
Change-Id: Iac96cdf3bab47071f197832172b94481e7bf00d5
We are double forking in the docker image and that seems to confuse
docker because the process it started has exited. Fix this by adding a
--no-daemon option to gerritbot then set that in the dockerfile. This
should run gerritbot without any additional forking.
Change-Id: I048115da5362a883360dcaf40860022ed5b63d47
This change fixes the comment-added message sending to filter by the
event type which gerrit is now sending (Verified and Code-Review)
Adding the following to project-config/gerritbot/channels.yaml will
restore the previous functionality of sending messages for Verified,
Code-Review +2 and -2:
events:
- comments-added
- x-vrif-minus-2
- x-vrif-plus-2
- x-crvw-minus-2
- x-crvw-plus-2
Additionally, specifying 'comments-added' will send a message for
*every* gerrit comment, so the only way to get messages for
x-vrif-plus-2 (for example) is to also receive a firehose of every
gerrit comment.
To make this more configurable, the event type x-all-comments has been
added, which is now required in combination with 'comments-added' to
send a message for every gerrit comment:
events:
- comments-added
- x-all-comments
Change-Id: I9971e045c3416b300d1fd4683a2c145afef3d44f
Don't pass the channels list to super in the irc bot class init method
because this appears to cause autojoining to happen which breaks because
we have too many channels. Instead let the event driven processing join
and part channels as needed to make the least recently used channel
rotation with channel limit work.
Change-Id: I447e75e84526d08fb9ec88eaae9a90f950dc5349
Identify through SASL using the convenient ib3 mixins, and
get rid of a bunch of special-case code in the process.
This helps when dealing with channels set to require identified
users, as otherwise channel joins will race NickServ's processing of
the identify message and some channels will end up not serviced by
the bot (an alternative would be to delay joining channels until the
identify success is confirmed, but the implementation for that looks
like it would be at least as complex).
Change-Id: I1a01eed8102b59818df247a93fbe4bf50148e76a
Co-Authored-By: Thierry Carrez <thierry@openstack.org>
Depends-On: https://review.openstack.org/608313
With this change, the channel config yaml file can now be configured to
support regular expressions.
Any value in any section may be prefixed with `^` to denote that it is
to be treated as a regular expression [1]. Start and end ^anchors$ are
implicit (so add `.*` if needed).
For example, given the following paragraph in the channel config yaml:
openstack-foo:
events:
- patchset-created
- change-merged
projects:
- openstack/foo
- ^openstack/foo-.*
- openstack/oslo.foo
branches:
- master
- ^stable/(newton|ocata|pike)
...messages will be posted to #openstack-foo for events coming in from
project openstack/foo, openstack/foo-one, openstack/foo-bar, etc.; on
branches master, stable/newton, stable/ocata, or stable/pike.
Behavior is unchanged for values not prefixed with `^`.
[1] This paradigm cribbed from gerrit's search functionality:
https://review.openstack.org/Documentation/user-search.html#path
Change-Id: I97cb8faa72600bd1bd9792bb6bb59a3b652ec389
Enhance the tests introduced in [1] to exercise the filtering logic in
the Gerrit class.
[1] https://review.openstack.org/#/c/545128/
Change-Id: Ib4ecd9e7ee233378f25d585f016ba1448b9e8797
* Add some additional unit tests, including the initial framework to
be able to test the Gerrit() class.
* Improve the readability of the code by using more descriptive
variable names.
* Migrate to using '.stestr.conf' instead of '.testr.conf'. This
removes warning message that was being displayed.
Change-Id: I596c4ccb9fe37d996de26089eefd8481a12ff13b
Add an initial unit test framework and one unit test. This way we can
ask people to add unit tests when they contribute code.
Change-Id: If52976e1992945a8e38af3cbad5b5f4389922d4c
This change mitigate this exception:
File "gerritbot/bot.py", line 154, in change_created
data['patchSet']['uploader']['name'],
KeyError: 'name'
Change-Id: Ia1f394d6ff0e158df16461cf3150761f6ec12f29
When announcing that a patch has been submitted or merged, also announce
the branch that the patch is against.
Change-Id: I5b325951bdc1b0fca37d8579a14747a4da3b558e
Freenode has a limit of 120 channels joined by a single connection.
Since some of the channels Gerritbot reports to are less active
than others, have it only join channels when it needs to send a
message. If it has joined the max number of channels, part from
the least recently used channel to make room to join a new one.
Change-Id: Ifafeed77e640bc7b5910251c619358a8a2bd78a6
With the start of the germqtt project and it being deployed on
firehose.openstack.org services listening to gerrit no longer need
to connect via ssh to get the event stream. This commit adds support
for using an mqtt event stream as the input into gerritbot.
Change-Id: I4130edac746ab7ae979cad5e3ccad3be0321c909
The reconnect method is on the connection object, not the bot or
client objects.
See http://paste.openstack.org/show/481770/
Change-Id: I14856c0c451e51973e9b062cb9b4f35362cb3766
Recently a config problem broke gerritbot's ability to start, but what's
worse, there was no logging about why. Log the exception when this
happens.
Change-Id: If7832cbe5cbf5f506d5dfbb849f05f2e7670a2df
d2to1 hasn't been a thing in a VERY long time. We have to update hacking
as well beause the hacking this depends on also depends on a very old
pbr.
Change-Id: I1bf97a5fe1c1ae10f951510c2b95d43b4e9b8b19
According to https://wiki.openstack.org/wiki/Python3 dict.iteritems()
should be replaced with six.iteritems(dict).
Added six >= 1.6.0 as new requirement.
Change-Id: Ie8a3eacc00dd9248ee80956b3e72f0e80655b1f1
Adds a new optional config parameter "force_ssl" that applies the SSL wrapper
regardless of the specified port. The previous logic only allowed for SSL
on port 6697. This change is intended to be backwards compatible with
existing configs.
Added *.egg ignore patterns to .gitignore
Change-Id: I6fe6d9ad2d8461d759a63123af79f229b8f8b6f2
This commit fixes the gerritbot __init__ methods to use a proper super
call instead of directly calling the parent class's __init__.
Change-Id: I72894a978b7bcef782236f5d43f601697a89c50d
If any error is encountered while sending to IRC, try to reconnect.
This is an attempt to deal with this exception:
2013-10-07 23:00:00,937 ERROR gerritbot: Exception encountered in event loop
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 225, in run
self._read(event)
File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 216, in _read
self.change_merged(channel, data)
File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 194, in change_merged
self.ircbot.send(channel, msg)
File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 98, in send
self.connection.privmsg(channel, msg)
File "/usr/local/lib/python2.7/dist-packages/irc/client.py", line 933, in privmsg
self.send_raw("PRIVMSG %s :%s" % (target, text))
File "/usr/local/lib/python2.7/dist-packages/irc/client.py", line 960, in send_raw
sender = self.ssl.write if self.ssl else self.socket.send
AttributeError: 'NoneType' object has no attribute 'send'
Change-Id: I8c845626260ec7b9ee7f9e409adba4796dd367ee
The previous messages were wordy, when gerrit is very active, all these
wordy messages can clutter up a room. This makes the messages more
terse.
Change-Id: I7c941a871e3f1a09dd47c72aa32f93effc04250a
* gerritbot/bot.py(GerritBot.on_welcome): Add a 0.5-second pause
between channel join commands to avoid being kicked for flooding.
Change-Id: I8edad4b389683e62b58f5b6e81e5f4cb1e0dad97
Gerritbot previously leaked GerritLib threads because it did not check
if the preexisting thread was dead before starting new threads. Fix
that by checking the thread's is_alive() method.
Change-Id: I7282debf5caeb73cbc46b240f10c62b75b683776
The bot previously assumed that all event stream JSON blobs would always
have the data that the bot is interested in. Handle KeyError exceptions
when that data is missing.
Change-Id: I6ad034c5197c6778c39c334e3d9246c3b1356a81
Logging was configured, but only gerritlib log info was captured. Add
logging to the things that the IRC bot is doing.
Change-Id: Id38e49d95c2903ae28cfb7f2dc88d4fc201d8927
Gerritlib is now available for Gerrit event stream consumption. Use
it. This should fix the bug where events are missed due to the
connection dying and the resulting wait for five seconds.
Change-Id: I63e7c3064a42379c985f1a0a723d08c15a1be003
Add a setup.py for the gerritbot project. This incorporates
openstack.common.setup/version as well for versioning. This change
also adds a tox.ini file and its lists of dependencies to gerritbot:
pyyaml, python-daemon and python-irclib.
Change-Id: Id9204a1ad452c8aa3c5ec5b697db4dd835e46405