NixOS / hydra

Hydra, the Nix-based continuous build system
http://nixos.org/hydra
GNU General Public License v3.0
1.2k stars 304 forks source link

Hydra integration with RabbitMQ Proposal #662

Open disassembler opened 5 years ago

disassembler commented 5 years ago

Hydra Integration with RabbitMQ Proposal

This proposal is something IOHK is looking at doing to improve hydra notifications. It solves a number of our problems even in phase 1 of the proposal. I'm opening this up for community feedback before we start work on the tasks listed below.

Details of implementation

Phases

  1. RabbitMQ added to pipeline for notifications
    • Convert hydra notify to a daemon that watches RabbitMQ for notifications
    • Change perl/C code to not run hydra-notify and send messages to RabbitMQ
    • implement notifications before/after eval and before/after builds matching regex
  2. Rewrite portions of hydra-notify in something other than perl
    • IOHK would rewrite GitHub and SMTP notifier code
  3. Change polling/webhook plugins to be producers to RabbitMQ and hydra to watch for eval and build requests
    • split perl script evaluator into 2 pieces.
    • One that receives events via polling repo status and publishes message to RabbitMQ
    • One that parses the output from RabbitMQ, runs evaluation and updates database
    • Possibly rewrite one or both pieces as independent non-perl plugins
edolstra commented 5 years ago

The downside is that it adds another moving part (RabbitMQ). We're already using PostgreSQL's LISTEN/NOTIFY for notifications in some places (e.g. for communication between the web interface and the evaluator, and between the evaluator and the queue runner), so maybe that could be used instead? So consumers like the GitHub notifier would do listen build_finished; to be woken up when something happens.

grahamc commented 5 years ago

I am +1 in limiting the dependencies and infrastructure required for hydra. If there were a way to optionally hook in rabbitmq, that could be interesting.

Rabbitmq has an advantage over postgres events for some usecases, like streaming build logs: rabbitmq can easily handle many thousands of messages per second, and has a STOMP plugin shipped with core to send those build log messages to a web browser.

edolstra commented 5 years ago

PR #668 changes hydra-notify to be based on PostgreSQL notifications. Other services could use these notifications directly, or maybe use a bridge like https://github.com/subzerocloud/pg-amqp-bridge.