Package buildbot :: Package db :: Module buildrequests :: Class BuildRequestsConnectorComponent
[frames] | no frames]

Class BuildRequestsConnectorComponent

source code

               object --+    
                        |    
base.DBConnectorComponent --+
                            |
                           BuildRequestsConnectorComponent

A DBConnectorComponent to handle buildrequests. An instance is available at master.db.buildrequests.

Build Requests are represented as dictionaries with keys brid, buildsetid, buildername, priority, claimed (boolean), claimed_at, mine (boolean), complete, results, submitted_at, and complete_at. The two time parameters (*_at) are presented as datetime objects.

Instance Methods
 
getBuildRequest(self, *args, **kwargs)
Get a single BuildRequest, in the format described above.
source code
 
getBuildRequests(self, *args, **kwargs)
Get a list of build requests matching the given characteristics.
source code
 
claimBuildRequests(self, *args, **kwargs)
Try to "claim" the indicated build requests for this buildmaster instance.
source code
 
reclaimBuildRequests(self, *args, **kwargs)
Re-claim the given build requests, updating the timestamp, but checking that the requsts are owned by this master.
source code
 
unclaimBuildRequests(self, *args, **kwargs)
Release this master's claim on all of the given build requests.
source code
 
completeBuildRequests(self, *args, **kwargs)
Complete a set of build requests, all of which are owned by this master instance.
source code
 
unclaimExpiredRequests(self, old, _reactor=reactor)
Find any incomplete claimed builds which are older than old seconds, and clear their claim information.
source code

Inherited from base.DBConnectorComponent: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables

Inherited from base.DBConnectorComponent: connector

Instance Variables

Inherited from base.DBConnectorComponent: db

Properties

Inherited from object: __class__

Method Details

getBuildRequest(self, *args, **kwargs)

source code 

Get a single BuildRequest, in the format described above. Returns None if there is no such buildrequest.

Note that build requests are not cached, as the values in the database are not fixed.

Parameters:
  • brid (integer) - build request id
Returns:
Build request dictionary as above or None, via Deferred
Decorators:
  • @with_master_objectid

getBuildRequests(self, *args, **kwargs)

source code 

Get a list of build requests matching the given characteristics. Note that unclaimed, my_claimed, and other_claimed all default to False, so at least one must be provided or no results will be returned.

The claimed parameter can be None (the default) to ignore the claimed status of requests; True to return only claimed builds, False to return only unclaimed builds, or "mine" to return only builds claimed by this master instance. A request is considered unclaimed if its claimed_at column is either NULL or 0, and it is not complete. If bsid is specified, then only build requests for that buildset will be returned.

A build is considered completed if its complete column is 1; the complete_at column is not consulted.

Since this method is often used to detect changed build requests, it always bypasses the cache.

Parameters:
  • buildername (string) - limit results to buildrequests for this builder
  • complete - if true, limit to completed buildrequests; if false, limit to incomplete buildrequests; if None, do not limit based on completion.
  • claimed - see above
  • bsid - see above
Returns:
List of build request dictionaries as above, via Deferred
Decorators:
  • @with_master_objectid

claimBuildRequests(self, *args, **kwargs)

source code 

Try to "claim" the indicated build requests for this buildmaster instance. The resulting deferred will fire normally on success, or fail with AleadyClaimedError if any of the build requests are already claimed by another master instance. In this case, none of the claims will take effect.

As of 0.8.5, this method can no longer be used to re-claim build requests. All given brids must be unclaimed. Use reclaimBuildRequests to reclaim.

On database backends that do not enforce referential integrity (e.g., SQLite), this method will not prevent claims for nonexistent build requests. On database backends that do not support transactions (MySQL), this method will not properly roll back any partial claims made before an AlreadyClaimedError was generated.

Parameters:
  • brids (list) - ids of buildrequests to claim
  • _reactor - reactor to use (for testing)
Returns:
Deferred
Decorators:
  • @with_master_objectid

reclaimBuildRequests(self, *args, **kwargs)

source code 

Re-claim the given build requests, updating the timestamp, but checking that the requsts are owned by this master. The resulting deferred will fire normally on success, or fail with AleadyClaimedError if any of the build requests are already claimed by another master instance, or don't exist. In this case, none of the reclaims will take effect.

Parameters:
  • brids (list) - ids of buildrequests to reclaim
  • _reactor - reactor to use (for testing)
Returns:
Deferred
Decorators:
  • @with_master_objectid

unclaimBuildRequests(self, *args, **kwargs)

source code 

Release this master's claim on all of the given build requests. This will not unclaim requests that are claimed by another master, but will not fail in this case. The method does not check whether a request is completed.

Parameters:
  • brids (list) - ids of buildrequests to unclaim
Returns:
Deferred
Decorators:
  • @with_master_objectid

completeBuildRequests(self, *args, **kwargs)

source code 

Complete a set of build requests, all of which are owned by this master instance. This will fail with NotClaimedError if the build request is already completed or does not exist.

Parameters:
  • brids (integer) - build request IDs to complete
  • results (integer) - integer result code
  • _reactor - reactor to use (for testing)
Returns:
Deferred
Decorators:
  • @with_master_objectid

unclaimExpiredRequests(self, old, _reactor=reactor)

source code 

Find any incomplete claimed builds which are older than old seconds, and clear their claim information.

This is intended to catch builds that were claimed by a master which has since disappeared. As a side effect, it will log a message if any requests are unclaimed.

Parameters:
  • old (int) - number of seconds after which a claim is considered old
  • _reactor - for testing
Returns:
Deferred