Commit Graph

189 Commits

Author SHA1 Message Date
Tony Breeds 287f8d5063 Set SO_REUSEADDR and SO_REUSEPORT to enable faster service restarts
In a fast restart of the service we don't have time for all the TCP
sessions to drain the sockets in TIME_WAIT.  So the service fails to
restart with a "bind address in use".   To avoid this we want to add
SO_REUSEADDR and SO_REUSEPORT.  To do so we have to disable
bind_and_activate so we can then set allow_reuse_address and
allow_reuse_address on the TCPServer before we bind.

For reference:
 * https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address
 * https://github.com/python/cpython/blob/3.11/Lib/socketserver.py#L445
 * https://github.com/python/cpython/blob/3.11/Lib/socketserver.py#L447

Change-Id: I2ecbedf43e9912d430197e4110e4d467a8b449a3
2023-10-04 17:23:05 +11:00
Tony Breeds d01468e188 Fix errors in iCal
There were several issues with generating the ptg.ics.

Errors causing python tracebacks:

1. teams = slots = {}
   This was a gotcha for me.  This essentially makes teams and slots
   aliases for the *same* empty dictionary.  Not as I thought creating
   creating 2 empty dictionaries.  Upon reflection it is obvious.

   This meant that I was treating a "slot code" [MonA1] as a track/team

2. datetime.timedelta()'s keyword is "minutes" not "mins"

Functional errors:

1. If a team/track sets a VC url, it goes into db["urls"].
   Look there first and if not there look for a URL from the slot/room
   location.

2. Use a reasonable isn't a team/track key in db["etherpads"].

Non-functional changes:

1. There were a couple of FIXMEs which were addressed.
   e["key"] = "value" is the same as e.add("key", "value")

2. An empty url (""), is fine to add into the location, just strange.

Change-Id: I458924bfc26c47f4e062cc16f48e2d72da361918
2023-10-04 10:41:00 +11:00
Tony Breeds 0954e95fdc [scripts] Add an example/helper script for adding realtime fields.
Change-Id: I2accbc0db25d2e2d0700aad27b4e31de7ba63628
2023-09-25 11:58:42 +10:00
Tony Breeds f3060c0806 [iCal] Add an iCal file route.
Add a handler that converts the existing slot data into an ICS file.
This .ics file can be global ".../ptg.ics" or per track ".../ironic.ics"

Right now each block deafults to 60 minutes if there isn't a 'duration'
field in the slot entry.

Change-Id: I7a67ba777c004e57206976aca377fe3f41956db0
2023-09-25 11:58:42 +10:00
Tony Breeds 05ccf45dca [docs] Small fix for running http.server
Change-Id: I88821858122c3f2370ad44a3d0b8eca1bdab14fc
2023-09-25 10:21:12 +10:00
Tony Breeds 73e7258e6d Add stestr to .gitignore
Change-Id: Ib6946b974ebdce7ada55ed39d750e54a9e1e83d6
2023-09-25 10:21:12 +10:00
Clark Boylan 513944afea Update ptgbot to python3.11 and Bookworm
We update python testing from python3.8 to python3.11 to match the
deployment setup in the Docker image. We then update the docker image
from python3.9 + bullseye to python3.11 + bookworm. This is future
proofing, but also OpenDev would like to clean up old docker container
image builds for bullseye and older python.

Change-Id: Ifbb7dcf2bf5f0b7ea4f53e26dd4bf4911c9b8d37
2023-09-19 11:13:56 -07:00
Clark Boylan 70838b9d93 Revert "Migrate ptgbot to quay.io"
This reverts commit 260f6f3624.
This is a partial revert as test fixups are not reverted.

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

Change-Id: I5a1404c27f09f2cf2c1d7dd9b74c300052658559
2023-05-24 13:41:35 -07:00
Clark Boylan 260f6f3624 Migrate ptgbot to quay.io
This migrates publication of ptgbot container images to quay.io. We also
update the source of the opendev python base images to quay.io.

Depends-On: https://review.opendev.org/c/opendev/system-config/+/881932
Change-Id: Ia23aa05e770d0f002ce74effdae08dacb6edc18a
2023-05-08 09:53:37 -07:00
Jeremy Stanley 7b6b8293a8 Clarify required parameter names in readme
Multiple people have been mistaking the ~add and ~del syntax to
include a keyword "TRACK" which results in creating an actual track
by that name. Add chevrons around required parameters in the syntax
documentation in order to make it clear those are parameter names
and not literal keywords.

Change-Id: I69d5b79d8d894f94919724c0f94225dbf959b20e
2022-09-16 11:46:02 +00:00
Kendall Nelson 8ddd44bb1c Update Bot to Show Room Descriptions
Also adds examples of text for the description field
to base.json

Change-Id: Iac2201b9220db2c9b4c07a72cae1437b3f97de3a
2022-05-12 06:44:05 -05:00
Clark Boylan b072d88c0a Update ptgbot's docker image to bullseye
Bullseye has been out for a bit now and buster has a shelf life. Update
to bullseye to keep up with debian's releases.

Change-Id: I5845a8cf5c7a0c6383e9c2863146df28c7e40a4f
2021-12-09 15:36:05 -08:00
Ian Wienand 0e2f3d0a9d ptgbot-web: add simple service to serve static pages
This serves the static pages from the container directly

Change-Id: I86f3f5002f88005760e00c5714b0891c1892a6f2
2021-10-05 14:38:56 +11:00
Zuul 82c0b9ab9d Merge "Adapt PTGBot to OFTC" 2021-07-08 09:31:53 +00:00
Kendall Nelson a370934315 Add Container Image Build
Change-Id: If146ddc6176485cab038e68fae5c7cdbd7202417
2021-07-06 22:14:13 +00:00
Thierry Carrez ab85e55d74 Adapt PTGBot to OFTC
PTGBot was relying on a number of Freenode things and requires a
few changes to run on OFTC:

- Manually identify to NickServ instead of using SASL
- No longer use identify-msg capability
- Messages received are no longer prefixed by '+'

Change-Id: Ib014f58475c1eee89d34e718ee5988800602586b
2021-05-31 15:38:52 +02:00
Thierry Carrez 6445b85ccd Add missing clear clean alias
Recent change to introduce a "clear" alias for the "clean" commands
missed one case (~clear TRACK).

Change-Id: I60334ce80fee07edca335c1a75a295d90d6c39c5
2021-04-22 14:21:01 +02:00
Tim Burke ce24fed50c Add "clear" as an alias for "clean"
Change-Id: I5a5e9107850c008047dd875fe3901f1dd0ec2ea2
2021-04-21 07:56:46 -07:00
Zuul 10e8860653 Merge "Use Opendev Etherpad site" 2021-04-16 16:54:49 +00:00
Kendall Nelson c081b3fdc2 Use Opendev Etherpad site
To make it friendlier to non-openstack projects, use the opendev
instance of etherpad instead of the openstack one.

Change-Id: I30385d0ca0145994d21832769510a3a9b627e40d
2021-04-16 13:25:02 +00:00
Thierry Carrez 5a791cde41 Fix airbag deployment on empty messages
PTGbot airbag deploys on empty messages (messages containing only
spaces, or /me actions). Fix this crash to avoid airbag deployment.

Change-Id: I4def945894419536fd3d340e3850007210adf17f
2021-04-16 11:23:32 +02:00
Thierry Carrez b728b153e4 Fix ~add ~del ~clean commands
The first parameter would be ignored when running ~add, ~del or
~clean commands. Fix the issue and add a test to make sure we
do not regress again.

Change-Id: If2c239e8d04ca2ea86283861617c89d77d3917ee
2021-04-16 11:09:24 +02:00
Thierry Carrez 011c7c7ed7 Bot is now openinfraptg on #openinfra-events
Channel for PTG discussion was moved to #openinfra-events, and
the bot was renames "openinfraptg" to match the extended scope
of the event.

Depends-On: https://review.opendev.org/c/opendev/system-config/+/774862

Change-Id: I5f1cc7867273c82a836ab238e5c2b2352bbf02ff
2021-02-10 14:56:51 +01:00
Thierry Carrez 7beb7de516 Refactor processing of track and admin commands
Separate the processing of track commands and admin commands
into separate files, and normalize handling of messages.

Adjust test cases so that they match the new normalized messages.

Change-Id: I26e3683bbf3b7daab68407cd9928ee3d7f5c50dc
2020-12-08 14:35:48 +01:00
Thierry Carrez 2f8c18d9c1 Refactor processing of user commands
User commands in PTGbot can be called from privmsg or pubmsg.
Create a usercommands.py file to separate their processing.

This introduces a new '+' prefix for user commands, while preserving
the old '#' calls (which should really only be used for track
commands) for people that got used to them.

Change-Id: Ifab12fa27c6147ba9e9ff51f2b7f9e30a8ed0076
2020-12-08 14:35:48 +01:00
Thierry Carrez f368b40e98 Add tests for user commands
Add tests for in/out/seen and subscribe/notify/unsubscribe features.

Change-Id: I15313f93e728a692820ac79644d70928d87b3f2a
2020-12-08 14:35:37 +01:00
Thierry Carrez 5f371d18d4 Add tests for PTGbot
Add tests for most commands in PTGbot, checking that they result in
the desired outcome.

With this patch all track commands are tested, as well as most admin
commands.

Change-Id: I0a9907da6946db224a9efd2c740f275dfad0f00e
2020-11-27 09:43:46 +01:00
Thierry Carrez 21fbc34f3e Add memory-only database mode
Add a DB creation mode that will not persist changes to disk,
to be used in unit testing.

Change-Id: I3eeac5ddc1a360c1a4ed9dc892720ae92da1de87
2020-11-25 16:03:10 +01:00
Thierry Carrez 6bf2598db6 Create functions for is_voiced and is_oper checks
In order to be able to easily mock voice and oper checks, create
specific functions that implement those checks.

Change-Id: I6250c0d181085ff39d6ff0dae95c700dbeb931a3
2020-11-25 16:01:28 +01:00
Thierry Carrez df17b77f7e Log exception when bot airbag is activated
To facilitate investigating airbag-prevented PTGbot crashes,
log the exception stacktrace.

Change-Id: I6600abc1f07f16b739c62aeb632bd5bfd9a5e3e9
2020-11-25 15:59:56 +01:00
Thierry Carrez 89abc3f7bc Add missing entries in base.json
The base.json file was missing some entries, preventing us from
using it as a valid base for tests.

Change-Id: Iee9d1ea8052d8faaf1a2056b9769ed2a816c92d7
2020-11-25 15:59:18 +01:00
Zuul 00e49593b9 Merge "Make URLs in MOTD messages clickable" 2020-11-20 14:10:03 +00:00
Thierry Carrez 415ae5a05e Make URLs in MOTD messages clickable
A long-wanted feature! Since the MOTD can only be controlled by an
admin, the risk of abuse is very limited.

Change-Id: Iff6263059d76c9b75ae26e029e3063992ab7cb76
2020-11-20 14:38:25 +01:00
Zuul 39985b866d Merge "PTGbot airbag to prevent unexpected crashes" 2020-11-19 16:09:57 +00:00
Thierry Carrez a0d3fbab41 Add new MOTD handling commands
Revamp the ~motd command so that it supports the following subcommands
on the newly-introduced array of MOTD messages:

~motd add... (equivalent to old ~motd): adds a message
~motd clean (equivalent to old ~cleanmotd
~motd del n (to suppress message #n)
~motd reorder x y z (to reorder/remove messages)

Change-Id: I2f98c724c716ca4fd2e8fef34d4ca5af457b39e8
2020-11-13 18:14:52 +01:00
Thierry Carrez 9e052b1625 Turn MOTD into a list of messages
The message of the day used to be a single message with an importance
level. It's actually useful to be able to have several distinct
messages and add/remove them separately.

In preparation for that change, turn the motd entry in the json DB into
an array of messages. Gracefully migrate previous format DB into the
new one. Commands stay unchanged for now and just manipulate the first
entry.

Change-Id: Id98281dba0c6b3cffe1a359d6e0c250b99084bb1
2020-11-13 17:39:19 +01:00
Thierry Carrez 2aa77f38a4 PTGbot airbag to prevent unexpected crashes
Catch all previously-uncaught exceptions from on_pubmsg() and
on_privmsg() calls, to prevent the bot from crashing when people
start getting creative in their commands.

This should of course never happen, but if it does, better continue
running than crash.

Change-Id: Ic5eeec23652170061cbd2ce3606a3aee22463529
2020-11-13 13:15:03 +01:00
Thierry Carrez d172bd0cef Fix potential crash in etherpad command code
The code handling the "etherpad" command had the same issue as the
code handling the "url" command: if "auto" was passed to reset an
etherpad to default BUT no etherpad was set, the bot would crash.
This fixes it by doing nothing in that corner case.

Change-Id: I7a63c0b5ce95cf795964e637313a7b19e238964d
2020-10-30 14:41:03 +01:00
Thierry Carrez 902bce5867 Fix bot crash when 'none' URL provided
If a "none" URL is passed for a track but that track did not
have a customized URL in the first place, the bot would crash.
This fixes it by not doing anything in that case.

Change-Id: I9ab45ad7d07700efe5af208eb4c5b1285fd9deeb
2020-10-30 14:35:25 +01:00
Thierry Carrez 9e1b414bec No longer display location
The location code was created to allow for emergency relocation of
meetings, however in a virtual setting that is tracked using the "url"
feature. When location and urls differ it can create a lot of confusion.

It's better to stop displaying location for virtual PTGs. As an
emergency fix, let's stop displaying the location.

Change-Id: Ibb9d96e1fa7f686e31cc8d9b51e3826af8c4b015
2020-10-28 15:31:48 +01:00
Thierry Carrez 7ae6c6cc55 Fix issue in case unknown location is provided
Using the "location" command to point to an unknown location
would cause the Javascript displaying the schedule to crash.

It's a bit useless to use that command in a virtual PTG with
meeting URLs, however the page should handle that case and fail
more gracefully.

Change-Id: I271e2ead0094d407274cbb22e499d7b2c49631b4
2020-10-27 16:24:14 +01:00
Thierry Carrez 8f00364211 Make it clearer how to join the meeting
When a meeting URL is provided, use the tooltip to explain that you
can click to join the meeting, rather than confusingly mention that
no one is checked in.

Change-Id: Id0dacd065ce28ed817fd142105cb728392d0efe4
2020-10-23 11:41:59 +02:00
Thierry Carrez fc5a649df2 Mark current time on the schedule
Add a grey background on cells matching the current time, to make
it clearer where we are in the day.

Change-Id: Id2d13ae59f63c7059bba8abdf762b25e6339720e
2020-09-14 14:27:59 +02:00
Thierry Carrez 673d5375cd Make clickable badges more button-like
Make it clearer that certain badges are meant to be clicked on.
Also replace the darkblue badge color that was too close to the
hover color.

Change-Id: I84617dbd442cfd557155400a65bd87679fe2825a
2020-09-14 13:50:02 +02:00
Thierry Carrez 1db00eafb8 Do not crash on privmsg with no content
There is a corner case (/dcc chat) where a privmsg can have no content.
Ignore such corner cases instead of crashing.

Change-Id: Ia07c76c4a2342bb4e7bc9c37a4944d4b9f18efd8
2020-06-02 15:38:07 +02:00
Sean McGinnis 4f32e1fbf7
Fix minor typo in subscribe command example
Change-Id: I2c16f475918ac786e41635b9524654f00685a5db
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-01 14:00:15 -05:00
Thierry Carrez be84818a14 Do not fail if track is not scheduled today
The new track badge logic (which builds in a link to the
videoconference room if one is specified) is failing in case
the track is not scheduled in any location today.

Fix it so that we do not display any link in this precise case.

Change-Id: Ib6d93336e7c5d7c3494d442f95295442a8169a4d
2020-05-29 13:54:43 +02:00
Zuul 220832e547 Merge "UTC times can be confusing, explain times better" 2020-05-11 16:47:58 +00:00
Zuul fa1ed9ca1f Merge "Support for room and track URLs" 2020-05-11 16:04:59 +00:00
Zuul 7f2264178a Merge "Add base.json as example base data" 2020-05-11 16:04:05 +00:00