freight icon indicating copy to clipboard operation
freight copied to clipboard

Deploy Queue and Auto Deploy

Open mitsuhiko opened this issue 9 years ago • 13 comments

The end goal is to have a way to track branches and automatically deploy whenever commits therein happen. However the same problem happens if two commits are scheduled by any mean. So to isolate the problem, we want the following:

  • queue a commit by enqueueing a commit sha
    • this can happen based on a hook
    • alternatively manually
  • when multiple commits are queued up, we skip irrelevant commits to the same target

The proposal is to have a deploy stack for each target (production, staging etc.).

  • When a new commit should be deployed it's added to the queue.
  • If it's a named target (like a branch) then the target is resolved immediately into a commit hash
  • it's pushed to the top of the stack for the target
  • Items can be removed from anywhere within the stack to revoke a pending deploy (stack with benefits)

Independently of this there is the deploy logic:

  • There is a system that monitors the stack for each target and always deploys top.
  • Once the deploy is done it looks at the stack and if it's not empty, it deploys the top again.
  • At any point any stack items older than the last deploy are ignored.
  • In an ideal situation this ends up in an empty stack.

Example:

DEPLOY A (stack was empty, deploy starts)
DEPLOY B
DEPLOY C
DEPLOY D
DEPLOY E
STACK state: B C D [E] (E is top, A was already removed immediately)

Once A finished deploying E is the top of the stack as it's newer than the deploy of A. When E is done, D C and B are removed from the stack as they are too far in the past timestamp wise. If E would have been revoked before deployed, D would have been deployed as expected.

mitsuhiko avatar Jul 22 '15 16:07 mitsuhiko