Skip to content

Fix permissive bot session handling

Jeremiah Bonney requested to merge jbonney/permissive-bots-fix into master

Before raising this MR, consider whether the following are required, and complete if so:

  • Unit tests
  • Metrics
  • Documentation update(s)

If not required, please explain in brief why not.

Description

This PR fixes how Permissive Bot Session handling is done when using DB backed Bots Interface in certain cases. Permissive Bot Session was a mode to make workers swinging from one BuildGrid machine to another not require workers to throw away all their work due to the new BuildGrid not knowing about them. When using a shared database this option isn't needed and shouldn't be used, but when using local sqlite databases or doing a rolling deployment this functionality is very nice to have.

There are two cases where this was broken:

  1. The bot connecting has a lease, in which case SQLAlchemy complains due to trying to treat a list[str] as a str, since the bots table only allows one lease.
  2. The bot name connecting has never been seen before by this specific BuildGrid, in which case the filter BotEntry.name == bot_session.name removes all potential rows to update and it ends up being a no-op

This PR fixes both issues and extends the permissive bot session tests to cover this scenario as it was previously missing.

Validation

Run the new tests in tests/integration/bots_service.py which test this behavior.

Merge request reports