1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 01:12:41 +01:00
phorge-phorge/src/applications/harbormaster
epriestley 78bf266bde Allow Harbormaster build targets to wait for messages
Summary:
This hooks up all the pieces of the build pipeline so `harbormaster.sendmessage` actually works. Particularly:

  - Candidate build steps (i.e., those which interact with external systems) can now "Wait for Message". This pauses them indefinitely when they complete, until something calls `harbormaster.sendmessage`.
  - After processing a target, we check if we should move it to PASSED or WAITING.
  - Before updating a build, we move WAITING targets with pending messages to either PASSED or FAILED.
  - I added an explicit "Building" state, which doesn't affect workflows but communicates more information to human users.

A big part of this is avoiding races. I believe we get the correct behavior no matter which order events occur in:

  - We update builds after targets complete and after we receive messages, so we're guaranteed to update once both these conditions are true. This means messages can't be lost (even if they arrive before a build completes).
  - The minor changes to the build engine logic mean that firing additional build updates is always safe, no matter what the current state of the build is.
  - The build itself is protected by a lock in the build engine.
  - The target is not covered by an explicit lock, but for all states only the engine (waiting) //or// the worker (all other states) can interact with it. All of the interactions also move the target state forward to the same destination and have no other side effects.
  - Messages are only consumed inside the engine lock, so they don't need an explicit lock.

Test Plan:
  - Made an HTTP request wait after completion, then ran a pile of builds through it using `bin/harbormaster build` and the web UI.
  - Passed and failed message-awaiting builds with `harbormaster.sendmessage`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley, zeeg

Differential Revision: https://secure.phabricator.com/D8788
2014-04-16 13:01:46 -07:00
..
application Don't create invalid build steps while adding them 2014-03-25 16:12:05 -07:00
capability Harbormaster v(-2) 2013-10-22 15:01:06 -07:00
conduit Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
config Migrate "Run Command" to use Drydock hosts 2013-12-05 14:06:22 +11:00
controller Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
customfield Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
editor Use ApplicationTransactions and CustomField to implement build steps 2014-03-25 16:08:40 -07:00
engine Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
event Replace "Cancel Build" with "Stop", "Resume" and "Restart" 2014-01-06 12:32:20 -08:00
interface Add bin/harbormaster to make builds easier to debug 2013-12-26 10:40:52 -08:00
management Extend all "ManagementWorkflow" classes from a base class 2013-12-27 13:15:40 -08:00
phid Render build status on revisions and commits 2013-11-09 15:04:00 -08:00
query Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
remarkup Harbormaster v(-2) 2013-10-22 15:01:06 -07:00
step Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
storage Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00
view Replace some hsprintf() by phutil_tag() 2013-11-11 09:23:23 -08:00
worker Allow Harbormaster build targets to wait for messages 2014-04-16 13:01:46 -07:00