Skip to content

Deploy bisect ​

A rollback goes back to the latest version known to work. When several commits landed since then (ten containers each getting a hook, or a busy team pushing fixes), one bad commit costs all the good ones. A deploy bisect finds the bad commit by deploying versions in between, and reverts only that one.

A deploy bisect over six commits Commit a0 worked; six commits later, c6 broke the service. vulnboxd first rolls back to a0, so the service is up. It then deploys c3, which works, then c5, which is broken, then c4, which is broken, so c4 is the first bad commit. Finally it deploys c6 with only c4 reverted, which works: the other five commits stay. a0c1c2c3c4c5c6workedculpritbroke (newest)roll backworksthe version that worked serves meanwhiletest 1worksc3 works: the culprit is latertest 2brokenc5 is broken: it is c4 or c5test 3brokenc4 is broken: c4 is the culpritresultworksc6 with only c4 reverted works
log₂ n test deploys for n commits. Each step is a pushed commit, built and deployed like any other.

How it works ​

  1. The version that worked goes back first, so the service is up while the search runs. After an automatic rollback that has just happened; a bisect started by hand makes that commit itself (nothing, if it already runs).
  2. A binary search over the commits since then. vulnboxd deploys the service as it was at the commit halfway, checks it, and narrows down — log₂(n) deploys for n commits. Every step is a pushed commit, built and deployed like a rollback (at once, or in the window, following rollback.when).
  3. The first bad commit is reverted alone on top of the newest version, which is checked too. If it still does not work, the search goes on over the commits after it (several bad commits), up to max_culprits.
  4. Bounded: out of steps (max_steps), out of time (max_time), or stuck, it gives up and puts back the newest version it saw working — at worst the one it started from, which is where the plain rollback would have left it.

Starting one ​

By hand, from the box:

sh
sudo vulnboxctl bisect web start                 # between what the latest rollback went between
sudo vulnboxctl bisect web start --good 0642173  # or say which commit worked (and --bad which broke)
sudo vulnboxctl bisect web                       # where it is (show; --json for the file)
sudo vulnboxctl bisect web stop                  # stop; the newest version found working goes back

From the hub: the Vulnbox screen shows the same and can start and stop it, unless agent.bisect is off. A running bisect is a line in the service's row. Below the list, the selected service's Deploy bisect panel shows the commits in the range with their status (the culprit highlighted, pinned commits marked, the one being tested), every step with its verdict, and Start (with optional good and bad commits) and Stop, both confirmed first.

Alerts say when a bisect starts, which commit it found and reverted, and how it ended. Its record is <state_dir>/<service>/bisect.json.

Which commits it looks at ​

The commits on the branch's first-parent history after the version that worked, up to the one that broke, that change the service's code:

  • a merge counts as one change, against its first parent;
  • commits that only change the rules file, or nothing of this service (another service in the same repository), are left out: rules have their own history and their own rollback, and need no deploy;
  • a commit whose version does not build is skipped, as git bisect skip does;
  • a commit marked Vulnboxd-Skip-Rollback is never reverted: if it is the culprit, vulnboxd says so and leaves it in;
  • vulnboxd's own bisect commits are steps, not changes, and are never in a later bisect's range.

How a version is judged ​

vulnboxd's health check after the deploy (containers running, ports answering), looked at again 5 seconds later, since a container that crashes right after it started looks healthy at first. When the checker started the bisect and there is a game (verdict: auto), also the checker's verdict for a tick the version was live for — slower, a tick or two per step, but it catches what only the checker sees. A bad verdict is checked a second time before it is believed (confirm), since checkers can be flaky.

While it runs ​

While a bisect runs, the service's own rollbacks stand aside and the bisect decides. A commit someone else pushes to the service stops it, and is built and deployed as usual: vulnboxd never overwrites a teammate's work. A daemon that restarts in the middle puts the version the bisect started from back.

Its commits ​

Every bisect commit says what they hold and carry a Vulnboxd-Bisect trailer:

text
3c9e1a2 Bisect web: test 9b1f00e2c7d1 (3 of 6)

The service as it was at 9b1f00e2c7d1 "cache sessions", to tell whether it works.
Step 2 of at most 8; vulnboxd deploys it, checks it and moves on.

Vulnboxd-Bisect: 1790000000-4b7c2d1e
Committed by vulnboxd.
text
5d0f7b3 Bisect web: revert 9b1f00e2c7d1 "cache sessions"

The bisect found 9b1f00e2c7d1 broke web. This is the newest version with it (and any culprit found
before) reverted: 4b7c2d1e0a3f "fix note id check" without 9b1f00e2c7d1. The other commits stay.

A version "as at commit c" is the service's directory as in c with the culprits found so far reverted out of it by a three-way merge, and the rules file as it is now. A culprit that a later commit builds on may not revert cleanly; such a version is skipped, and if the newest one cannot be put together the bisect gives up as above.

Costs and settings ​

Every step is a deploy, and a version that is broken is down until the next one replaces it, plus a tick or two per step when the checker decides. That is why it starts by itself only when you turn it on (auto: true); by hand it is always there. Turn it on for services where losing a batch of good commits — patches — costs more than a few bad deploys.

yaml
rollback:
  bisect:
    auto: false        # start one after a rollback of several commits
    min_commits: 2     # fewer, and the rollback already is the answer
    max_commits: 64    # a longer range is rolled back as a whole
    max_steps: 8       # test deploys (and checks of the result)
    max_time: 30m
    max_culprits: 3
    verdict: auto      # auto, health or checker
    confirm: true
  services:
    notes: { bisect: true }   # per service

The settings are under rollback.bisect in the reference.

Limits ​

  • Every step is a real deploy of the live service. A second instance tested in the background, while the working version keeps serving, is not built: published ports, fixed container_names and bind mounts would be shared with the live service.
  • Steps follow rollback.when; with window, each step waits for the end of a tick.
  • A commit marked Vulnboxd-Skip-Rollback is never reverted, even when it is the culprit (Keeping a commit).