Edgewall Software

Version 4 (modified by cmlenz, 19 years ago) (diff)

Added "Why BEEP" and "Error Handling" sections

Bitten Master/Slave? Protocol

To decouple the master and slave, an application protocol will be defined on top of the meta-protocol BEEP (Blocks Extensible Exchange Protocol, RFC 3080). BEEP was chosen because it provides peer-to-peer communication (so that both the client and the server can send requests to the other) and because of its relative simplicity compared to protocols such as XMPP.

Why BEEP?

I first looked Jabber/XMPP, but it seemed to be very complex (with dozens of related specifications), and there are no sufficiently mature implementations for Python. I could live with the complexity, but not if I have to implement the whole stack myself. I didn't look into other IM protocols because I wanted to build on something open/standardized. Note that even if I'd chosen XMPP/etc I would have to design a protocol on top of the provided infrastructure.

BEEP is simple and flexible, and explicitly designed as a foundation for custom application protocols. While the only Python implementation I found (BEEPy) uses Twisted and looks dead, BEEP is really simple enough to be implemented in a basic way in the scope of this project (i.e. minus

the authentication and security features, which could of course be added later).

Slave Registration

A new client connects to the build master and signals its' availability for executing builds by starting a channel for the Bitten profile.

First, the server needs to query some information about the client for orchestration:

  • Platform/architecture
  • Operating system
  • The product name and version number of each of the dependencies of the project to build (for example, the C compiler or the Python runtime).
  • Name and email address of the maintainer

After the Bitten channel has been started, the client would send a message like this to the server:

  MSG 1 0 . 0 78
  Content-Type: application/beep+xml
    
  <register name="levi" maintainer="Christopher Lenz &lt;cmlenz@gmx.de&gt;">
    <platform>Power Macintosh</platform>
    <os family="posix" version="8.1.0">Darwin</os>
  </register>
  END

The server acknowledges that it received the registration with a positive or negative reply.

Next, the server checks whether there are any pending builds for that client. For example, if it is the only client that supports GCC 4.0, and there has been no build of some revision with GCC 4 yet, it will initiate a build on that client. Anyway, the server remembers the client configuration for as long as the connection is open, and may choose to route build requests to that client when repository changes are detected, or a build is triggered otherwise.

Build Initiation

When the build server detects that builds are necessary for some revision of the project, it queries its database of available slaves and chooses a set of slaves with non-overlapping configurations. For example, if there are 10 clients available that could execute the build of a Java project on Windows 2000 with JDK 1.4, it will only select one of those to actually perform the build.

A build request

  MSG 1 1 . 0 78
  Content-Type: application/beep+xml
  
  <build config="trunk"/>
  END

A client can decline a build request (or even abort a build), in which case the build master selects the next available client with the same (or sufficiently similar) configuration.

If the client accepts a build request, the server will transmit a tarball of the code base that is to be built. The client does not need to know which exact revision (or branch) of the project it is building, nor does it need to perform a checkout itself.

  MSG 1 2 * 0 78
  Content-Type: application/tar
  Content-Encoding: gzip
  
  ...

Build Status Reporting

Before and after each step of the build recipe, the client informs the server about its status:

  • whether the build has been started, is currently running, or has finished
  • which step is currently being processed

After a build step has been completed, the client transmits the data generated (as identified by the <reports> in the recipe) to the server, along with the the output of the build and a success/failure flag.

Error Handling

A build slave can abort the build whenever it wants (announcing it and saying goodbye), or it can just disconnect (as would happen on a hard shutdown of the machine). Both can be easily detected by the build master, in which case it will choose the next client from its list that matches the given requirements.

Another case to deal with is timing out when the client started a build but fails to respond for an exceptionally long period of time. The server would then disconnect, and choose the next available slave, as above. The timeout would have to be configurable, as it may vary significantly between projects.

Attachments (1)

Download all attachments as: .zip