LAVA events

lun. 23 janvier 2017 by Rémi Duraffort

For some releases now, LAVA server is publishing events every time:

  • a Job status change (Submitted, Running, ...)
  • a Device status change (Idle, Reserved, ...)

The stream of events is public and anyone can subscribe and receive updates.

A dump of the streams for the production and the staging instances is available on ReactOWeb. For instance, here is a (partial) extract of the stream:

topic: org.linaro.validation.testjob, data: {"status": "Submitted", "priority": 50, "job": 1318796, "health_check": true, "device": "aa9-01", "description": "lab-health-aa9", "submit_time": "2017-01-19T13:31:17.995716+00:00", "submitter": "lava-health", "pipeline": false, "visibility": "Publicly visible"}
topic: org.linaro.validation.device, data: {"status": "Reserved", "pipeline": false, "job": "1318429.1", "health_status": "Pass", "device_type": "x15", "device": "x15-01"}
topic: org.linaro.validation.device, data: {"status": "Reserved", "pipeline": false, "job": "1318455.0", "health_status": "Pass", "device_type": "kvm", "device": "kvm21"}

Use cases

A typical use case of the stream of event would be to know when:

  • a job is finished without polling the database
  • jobs are running on a specific board
  • a given device is going offline/online/...

For instance a user might want to build a website that aggregate all the results of the jobs on a given device type. Thanks to the event stream, it's possible to build and update such website in real time and without any polling.

Listening to the stream

The stream of event is published by a ZMQ PUB socket. In order to connect you should use the ZMQ library or a program like ReactOBus.

In Python, printing all events from the production instance is as simple as:

import zmq

ctx = zmq.Context()
sub = ctx.socket(zmq.SUB)
sub.setsockopt(zmq.SUBSCRIBE, b"")

while True:
    msg = sub.recv_multipart()

For the official Linaro LAVA instances the streams are available at:

Each event is an array made of:

  1. topic
  2. uuid (as generated by uuid.uuid1() in Python)
  3. datetime when the message was generated (isoformat)
  4. username of the sending process or user
  5. data as JSON

LAVA configuration

If you want to use the stream of events for your own instance of LAVA, you should add to /etc/lava-server/settings.conf:

  • EVENT_NOTIFICATION: should be true to allow to generate events
  • EVENT_TOPIC: the base topic for each events

Read the documentation for more information.