Commit Graph

92 Commits

Author SHA1 Message Date
Clark Boylan 738a671459 Update Gerrit bot to python3.11 on bookworm
This drops python3.8 and python3.10 testing focusing only on python3.11.
At the same time we bump the container image to python3.11 and bookworm.

The eventual goal here is to have opendev services on bookworm and
python3.11 so that we can drop docker image builds for bullseye and
older python versions.

Change-Id: I37b2ed3fafb3599db95730f3a9bbb90da95ff0e4
2023-09-19 10:58:24 -07:00
Clark Boylan d4758daf51 Revert "Move gerritbot to quay.io"
This reverts commit f5878e3023.

OpenDev is moving back to docker.io to preserve speculative image
testing.

Change-Id: I349c0016bd57fd03d472703749b2f5bb467acab3
2023-05-24 13:36:23 -07:00
Clark Boylan f5878e3023 Move gerritbot to quay.io
This moves shifts the publication of our gerritbot images from docker
hub to quay.io. It also updates the source of the python base images to
quay.io as they will be moved by the time our depends-on merges.

Depends-On: https://review.opendev.org/c/opendev/system-config/+/881932
Change-Id: I1289923c5e91d9058d28e72ddca56f23490c07d3
2023-05-05 16:23:43 -07:00
Clark Boylan 00ec88ed8e Fix gerritbot CI
This is fallout from the v4 and default nodeset updates.

Change-Id: I11b1c979767aeda64c9436e407b4627cc0d0b16f
2023-05-05 15:33:35 -07:00
Clark Boylan ec934f441c Switch the docker image over to python 3.10
Python 3.10 has been quite a bit quicker than 3.8 with Zuul. With the
3.11 release coming up soon updating to 3.10 will allow us to drop the
3.8 docker images and take advantage of faster python.

We add python 3.10 unittesting to ensure we don't regress when making
changes.

Change-Id: I439027f6e2c6f2d01b4629351a4c72cc1892579a
2022-10-14 15:31:58 -07:00
Clark Boylan ee566eb499 Update the docker image to run as uid 11000
We're running as uid 11000 on eavesdrop. Update the docker image to do
this by default.

Change-Id: Ia2c26b6b5557593cad70b8868c74d353de585e12
2021-11-18 15:23:51 -08:00
Clark Boylan 4492ccf01c Update docker image to bullseye
This updates us to bullseye on our docker image.

Change-Id: Id7d4bcee76de84c55f15d2f9ee6970bc5f29bd0a
2021-11-18 15:23:04 -08:00
Zuul 3497425ff4 Merge "Add branch to all the remaining event messages" 2021-07-28 16:54:09 +00:00
Clark Boylan 6f78d6e52b Support normal auth in gerritbot
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
2021-05-29 10:08:56 -07:00
Clark Boylan 5f67ba2410 Update to python3.8
Our base CI image doesn't have python3.7 anymore so bump this up to
running on 3.8.

Change-Id: Ifa13fe62247bedd77771628aace15ad47e86e07c
2021-05-28 13:22:32 -07:00
Radosław Piliszek 75e2c2f03d Add branch to all the remaining event messages
Branch is always useful to know. ;-)

Change-Id: Icece8d06c771dbd55825655206f75810d9fa43e6
2021-04-28 18:39:09 +00:00
Jeremy Stanley 3cefaa8617 Don't reconnect on MessageTooLong exceptions
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
2021-03-19 22:12:29 +00:00
Jeremy Stanley 03c21d8369 Explicitly clear joined channels when reconnecting
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
2021-03-19 21:44:37 +00:00
Jeremy Stanley 225a6a3502 Revert "Skip notifications about WIP changes"
Needs more discussion.

This reverts commit 54e2f218d6.

Change-Id: I7fd6b8f78830cc87d14b67d957fa64cc0d453c0b
2021-01-19 19:26:45 +00:00
Zuul e3bcd8a4e9 Merge "Skip notifications about WIP changes" 2021-01-19 15:46:11 +00:00
Sorin Sbarnea 7d473e4d43 Use yaml.safe_load instead of load.
Fixes security issue and deprecation of simple use of yaml.load
without an explicit loader.

Change-Id: If47e3fd1cc09c7a1db1fad05a643aa3da04cf26c
2020-12-02 16:51:28 +00:00
Sorin Sbarnea 54e2f218d6 Skip notifications about WIP changes
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
2020-12-02 15:32:09 +00:00
Ian Wienand cfcc7d53b3 Build against gerritlib master branch
This adds gerritlib as a required project and installs it as a sibling
into the image.  This effectively means the images promoted are
gerritbot from master with gerritlib also from master.

Change-Id: I7e4040c82b1617b56af3e62de9e5637096892a40
2020-11-25 09:42:02 +11:00
Jeremy Stanley 04a8d696f1 Iterate over a copy of the channel keys
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
2020-08-12 16:50:33 +00:00
Clark Boylan df6af38172 Pin to irc==18.0.0
The current release of 19.0.0 has a bug where it tries to get the client
version string for cctp responses but the attribute was removed. This
attribute is present in 18.0.0 so use that instead.

Change-Id: I2ee81b464164ca41177aa35079b98017cd9f413f
2020-08-11 15:19:18 -07:00
Zuul 84db99ef6e Merge "Add option to disable daemonization" 2020-08-11 19:27:16 +00:00
Zuul 92c9614654 Merge "Update docker image jobs to advertise the image they build" 2020-08-10 18:21:20 +00:00
Clark Boylan 1da055f809 Add option to disable daemonization
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
2020-08-07 10:10:20 -07:00
Clark Boylan a934f90f74 Update docker image jobs to advertise the image they build
This should allow depends-on to work properly through the intermediate
registry.

Change-Id: I90275a671bd707ce494a6dd4310dc779869b4bc9
2020-08-06 15:28:13 -07:00
Javier Pena 079396a691 Switch to stestr, declare Python 3.7 compatibility
Since [1] the project supports Python 3.7. It is also a good idea
to move away from ostestr to stestr, as all OpenStack projects did
already.

[1] - https://review.opendev.org/715634

Change-Id: I68bb89e441cba373f3c781ec0f4418c3969c8f85
2020-05-25 11:21:52 +02:00
Monty Taylor 83f3097608 Build docker images
So that we can deploy gerritbot in the new world of ansible+docker,
we need container images. Build and publish some.

Change-Id: I3b8a9f7d28af0f9098cfb73051976d7666a46a3c
2020-03-28 12:09:15 -05:00
Monty Taylor 29ff7b3bec Update for python3
We're gonna build an image in the next patch, so let's fix things
up to be python3 ready.

Change-Id: Ia0e1ecf75e6593a7e7be9dc962a1e2f3dc23fe27
2020-03-28 11:46:39 -05:00
Steve Baker e3879412b7 Fix event comment-added
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
2019-12-10 10:49:01 +13:00
OpenDev Sysadmins c34fb29841 OpenDev Migration Patch
This commit was bulk generated and pushed by the OpenDev sysadmins
as a part of the Git hosting and code review systems migration
detailed in these mailing list posts:

http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003603.html
http://lists.openstack.org/pipermail/openstack-discuss/2019-April/004920.html

Attempts have been made to correct repository namespaces and
hostnames based on simple pattern matching, but it's possible some
were updated incorrectly or missed entirely. Please reach out to us
via the contact information listed at https://opendev.org/ with any
questions you may have.
2019-04-19 19:26:00 +00:00
Ian Wienand 41d73a4470 Replace openstack.org git:// URLs with https://
This is a mechanically generated change to replace openstack.org
git:// URLs with https:// equivalents.

This is in aid of a planned future move of the git hosting
infrastructure to a self-hosted instance of gitea (https://gitea.io),
which does not support the git wire protocol at this stage.

This update should result in no functional change.

For more information see the thread at

 http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003825.html

Change-Id: I50e662774e52e6f1c82f7129d7e9eb0ab7cf2af6
2019-03-24 20:33:40 +00:00
Clark Boylan fefaae1109 Don't autojoin channels
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
2018-10-15 15:38:16 -07:00
Jeremy Stanley 57a669d35d Identify with SASL
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
2018-10-05 17:13:59 +00:00
Zuul f32d742eff Merge "Add _get_username method to discover username" 2018-02-21 17:25:20 +00:00
Eric Fried 981dfa50fa Support regexes in channel config yaml
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
2018-02-17 11:35:39 -08:00
Eric Fried fc4041f6a3 Test Gerrit message filtering
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
2018-02-17 11:35:31 -08:00
John L. Villalovos 01e1a0f979 Add more unit tests including testing of Gerrit() class
* 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
2018-02-17 11:28:38 -08:00
John L. Villalovos 4658934d22 Add unit test framework and one unit test
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
2018-02-05 12:59:39 -08:00
Sorin Sbarnea 7050c81714 Removed unreasonable banning of newer pbr versions
Change-Id: I849de65d3d91447b9298be0b904dc0b5b419bbff
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2017-03-30 18:52:10 +01:00
Tristan Cacqueray 2240fc3450 Add _get_username method to discover username
This change mitigate this exception:
  File "gerritbot/bot.py", line 154, in change_created
    data['patchSet']['uploader']['name'],
KeyError: 'name'

Change-Id: Ia1f394d6ff0e158df16461cf3150761f6ec12f29
2017-03-15 02:09:49 +00:00
John L. Villalovos 033a83b870 For patch submitted/merged, announce the branch
When announcing that a patch has been submitted or merged, also announce
the branch that the patch is against.

Change-Id: I5b325951bdc1b0fca37d8579a14747a4da3b558e
2017-01-09 21:50:20 -08:00
James E. Blair 91d908b807 Treat channels as an LRU list
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
2016-11-02 12:03:42 -07:00
Matthew Treinish 7c6e57983d
Add gerrit stream over MQTT support to gerritbot
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
2016-08-11 17:32:07 -04:00
Joshua Hesketh d48b1bc417 Fix reconnection method
The reconnect method is on the connection object, not the bot or
client objects.

See http://paste.openstack.org/show/481770/

Change-Id: I14856c0c451e51973e9b062cb9b4f35362cb3766
2015-12-14 18:17:49 +11:00
Monty Taylor f907ae7054 Add a log entry to the debug log on config error
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
2015-09-20 19:33:09 -04:00
Jeremy Stanley 957981e7d8 Replace ci.o.o links with docs.o.o/infra
The http://ci.openstack.org/ documentation site has been deprecated,
replaced by redirects to corresponding paths within
http://docs.openstack.org/infra/ where other Project Infrastructure
documentation already resides.

Change-Id: Icb976e2ec63dd8bcbb5890353ff980a4013d9a8a
2015-05-14 21:38:16 +00:00
Monty Taylor 506aea9010 Replace six.iteritems with iter()
We don't need six for this.

Change-Id: I19673bf47ef74b5e67c4197d31600c73c025ab4c
2015-02-27 22:14:23 -05:00
Monty Taylor 4851742244 Update to modern pbr
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
2015-02-27 22:14:00 -05:00
Michael Krotscheck 976ce5abff Switched documentation to point to storyboard.
We've migrated this project to storyboard, I'm updating the documentation links.

Change-Id: I7f67c870bf1eef5b3ea29eb6880564f7aeb32e2e
2014-11-11 15:01:38 -08:00
Jenkins 9258586a86 Merge "Adding a configuration option for gerritbots PID file path." 2014-08-11 14:12:15 +00:00
Christian Berendt 8c38ecdb3f Cleaning up index.rst file
Removed notes about the generation of the file.

Change-Id: Ifefbb9ce4b76e22dd6ddb33658b4aa8469beff13
2014-07-21 08:29:05 +02:00