Edgewall Software

Changes between Initial Version and Version 1 of Master Slave Protocol Http


Ignore:
Timestamp:
Jul 23, 2007, 10:36:21 PM (17 years ago)
Author:
cmlenz
Comment:

First draft of HTTP-based master/slave protocol

Legend:

Unmodified
Added
Removed
Modified
  • Master Slave Protocol Http

    v1 v1  
     1= Bitten Master/Slave Protocol, using HTTP =
     2[[PageOutline(2)]]
     3
     4This is a proposal for an HTTP-based protocol enabling communication between the build master and various build slaves. The protocol presented here is not final yet, nor is it implemented. Just throwing ideas out there, basically.
     5
     6== Comparison the Previous BEEP Protocol ==
     7
     8The BEEP-based protocol currently used by Bitten is described on MasterSlaveProtocol.
     9
     10The differences can be summarized as follows:
     11 * The build master would be a simple HTTP server, implemented as part of the Trac plugin. That means there would no longer be a separate daemon process needed for the master.
     12 * The build slaves are simply HTTP clients, probably using [http://bitworking.org/projects/httplib2/ httplib2] and falling back to the httplib or urllib modules in the standard library.
     13 * Both SSL and the various authentication methods of HTTP can be used to secure the communication.
     14 * Directionality of communication is always from the slave to the master. The master no longer initiates actions on the slave, rather the slave polls the master for pending actions when it is idle.
     15 * The build master would no longer be responsible for packaging tarballs and sending them to the slaves; instead, the slaves receive connection details for the repository, and perform a normal checkout. This is a [ticket:79 long standing ticket].
     16
     17== Build Creation ==
     18
     19A new client connects to the build master and asks the master whether there are any pending builds it could perform. The slave does this by `POST`ing its profile to the master, which contains information such as:
     20 * The platform/architecture of the slave machine,
     21 * the operating system,
     22 * 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), and
     23 * the name and email address of the maintainer of the machine.
     24
     25{{{
     26#!xml
     27POST /build/ HTTP/1.1
     28Host: example.org
     29Content-Type: application/xml; charset=utf-8
     30Content-Length: 666
     31
     32<slave name="lamech">
     33  <maintainer>Christopher Lenz &lt;cmlenz@gmx.de&gt;</maintainer>
     34  <platform>Power Macintosh</platform>
     35  <os family="posix" version="8.1.0">Darwin</os>
     36</slave>
     37}}}
     38
     39If the build master finds any pending builds that can be performed by the target platform matching the slave, it would send back a response similar to the following:
     40
     41{{{
     42#!xml
     43HTTP/1.1 201 Created
     44Location: http://example.org/builds/trunk/123/
     45}}}
     46
     47The response contains the URL to a build recipe as the value of the `Location` header. At this point, the master has allocated a pending build entity in its database that can also be viewed as HTML at the specified URL using any HTTP user agent.
     48
     49On the other hand, if the master has no work for the slave, it would return a `204 No Content` response:
     50
     51{{{
     52#!xml
     53HTTP/1.1 204 No Content
     54}}}
     55
     56== Build Initiation ==
     57
     58When the slave has received the URL to a build recipe, it can request the build recipe using a simple `GET` request:
     59
     60{{{
     61#!xml
     62GET /builds/trunk/123/ HTTP/1.1
     63Host: example.org
     64Accept: application/x-bitten+xml
     65}}}
     66
     67If the master still has that build in pending state in the database, it will respond with the recipe:
     68
     69{{{
     70#!xml
     71HTTP/1.1 200 OK
     72
     73<build xmlns:python="http://bitten.cmlenz.net/tools/python">
     74  <checkout type="svn" url="http://svn.example.org/repos/"
     75            revision="1234" />
     76  <step id="compile">
     77    <python:distutils command="build"/>
     78  </step>
     79  <step id="dist">
     80    <python:distutils command="sdist"/>
     81  </step>
     82  <upload>
     83    <file path="dist/foobar*.tar.gz"/>
     84    <file path="dist/foobar*.zip"/>
     85  </upload>
     86</build>
     87}}}
     88
     89The first element in a build recipe must be the `<checkout>` element containing the information necessary for the slave to perform a checkout from the version control repository.
     90
     91== Build Reporting ==
     92
     93As soon as the slave has received the recipe, it should perform the checkout and execute the steps outlined in the build.
     94
     95  ''Open issue: details of the checkout process should also be reported back the master''
     96
     97After every completed step, the slave should make a `PUT` requests the `steps` member of build collection:
     98
     99{{{
     100#!xml
     101PUT /builds/trunk/123/steps/test/ HTTP/1.1
     102Host: example.org
     103
     104<result status="success" started="2005-06-29T16:41:53" duration="7.61">
     105  ...
     106</result>
     107}}}
     108
     109The `started` attribute specifies the date and time at which processing of this step was started. The `duration` attribute contains the number of seconds that it took to complete the step (this may include fractions).
     110
     111The `<result>` element may contain one or more child elements:
     112 * `<error></error>` elements indicate errors in the execution of the step,
     113 * `<log></log>` elements contain the build log output, and
     114 * `<report></report>` elements contain generated [wiki:DataStorage report data].
     115
     116The build is assumed to be complete after the master has received a request for every step in the recipe.
     117
     118The server responds with a `201 Created` response.
     119
     120== Uploading of Build Artifacts ==
     121
     122If the recipe contains an `<upload>` element at the end of the recipe, the slave is expected to perform file uploads of any of the files specified. This is done using `PUT` requests the the `files` member of the build collection:
     123
     124{{{
     125#!xml
     126PUT /builds/trunk/123/files/foobar-r123.tar.gz HTTP/1.1
     127Host: example.org
     128Content-Type: application/tar
     129Content-Encoding: gzip
     130Content-Length: 666
     131
     132...
     133}}}
     134
     135The server responds with a `201 Created` response.