Draft: Set lease state to canceled if jobid found in cancel-cache
requested to merge fkolarek/rabbitmq/consume-cancel-action-msgs into sotk/rabbitmq/publish-botstatus
Before raising this MR, consider whether the following are required, and complete if so:
-
Unit tests -
Metrics -
Documentation update(s)
Description
In the bot service, create a RetryingPikaConsumer
and subscribe to the Cancellation
queue. When cancellation messages are received, cache the jobId/leaseIds in an LRU cache. When the bot receives update_bot_session
updates, iterate thru the leases in the request and set the lease state to LeaseState.CANCELLED
if we find any leaseIds in our cache.
TODO
- Rather than simply embed the leaseId/jobId as a string in the
Cancellation
queue entry, we will create .proto messages for them so that adding fields to these messages will be easier.
Changes proposed in this merge request:
-
buildgrid/server/rabbitmq/bots/instance.py
: Create aRetryingPikaConsumer
and subscribe to theCancellation
queue. -
buildgrid/server/rabbitmq/bots/instance.py
: In the callback function, add the jobId/leaseId to our LRU cache. -
buildgrid/server/rabbitmq/bots/instance.py
: Modify theupdate_bot_session
function to iterate thru the leases in the request and set the state toLeaseState.CANCELLED
if we find that leaseId in our cache.
Validation
Please note steps the reviewer should take to be able to test this MR; any necessary setup they might need, what results they should be looking for to verify.
Issues addressed
Closes / Resolves / Addresses (delete as appropriate) issue <e.g. repo-name#x>
Edited by Frank Kolarek