ReleaseEngineering/Applications/SlaveAPI

From MozillaWiki
Jump to: navigation, search
Warning: This RelEng page is obsolete!
RelEng doesn't use BuildBot anymore.

What is it?

SlaveAPI is a service that is intended to be a single point of entry for all actions related to slaves. Clients interact with it through a simple REST API and it communicates with many other systems on the backend to fulfill the requests (eg, bugzilla, slavealloc, inventory) made.

Its source code lives on github.

Where is it?

SlaveAPI has both a dev and production instance. Each lives on its own machine within the RelEng network. Unless you're in the process of landing a patch to SlaveAPI, you should be using the production instance.

These machines are managed by PuppetAgain.

Requirements/dependencies

SlaveAPI depends on many Python packages to function correctly. Installing it through its setup.py will take care of pulling in everything you need.

Deployment

Changes to SlaveAPI's config or credentials file should be done through Puppet. Both instances will pick up the changes and automatically reload the server.

Changes to SlaveAPI's code are a little trickier. SlaveAPI itself is deployed through pip by Puppet, so the first step is to upload a new version of SlaveAPI to PuppetAgain and update the version in the Puppet manifests. Once those are done the machine will automatically install the new version. However, the SlaveAPI service must be restarted to pick up the changes. You can do this by logging onto the machine and running the following:

sudo su - cltbld
cd /builds/slaveapi/dev (or prod)
source bin/activate
slaveapi-server.py stop slaveapi.ini && slaveapi-server.py start slaveapi.ini

The manual restart will be done automatically once bug 924616 is fixed.

The full process looks like this:

# bump the package version like in https://github.com/mozilla/build-slaveapi/commit/60d25601e0783bbfb9d5959c4092693fdb026321
# note: package is versioned according to http://semver.org/
$ vim slaveapi/__init__.py
# get review, commit, push, then
$ python setup.py sdist
$ ls dist
slaveapi-1.0.19.tar.gz
$ scp slaveapi-1.0.19.tar.gz root@releng-puppet2.srv.releng.scl3.mozilla.com:
$ ssh root@releng-puppet2.srv.releng.scl3.mozilla.com
$ mv -i slaveapi-1.0.19.tar.gz /data/python/packages/
$ puppetmaster-fixperms
# you should see the new package at http://puppetagain.pub.build.mozilla.org/data/python/packages/ 
# update slaveapi version in [puppet]/modules/slaveapi/manifests/instance.pp
$ vim modules/slaveapi/manifests/instance.pp
# get review, commit, push
# merge to puppet 'production' branch and push
# need to restart the production daemon
$ ssh <username>@slaveapi1.build.mozilla.org or <username>slaveapi-dev1.srv.releng.scl3.mozilla.com
$ sudo su - cltbld
$ cd /builds/slaveapi/prod or dev
# make sure the local package version has been upgraded by puppet before restarting the daemon
$ source bin/activate
$ pip freeze | grep slaveapi
slaveapi==1.0.19
$ slaveapi-server.py stop slaveapi.ini && slaveapi-server.py start slaveapi.ini

API Documentation

The details of the API are documented alongside the code, and an HTML version is available at mozilla-slaveapi.readthedocs.org.