Skip to content

Roll back a deploy

If a new version of an app misbehaves, you can go back to the one before it. The Hub also does this by itself when a freshly deployed version stops answering.

When you push a new image (or redeploy with a changed image) and the app then fails its health checks, the Hub puts the previous image back, on the same node:

  1. The deploy finishes and the app starts. The Hub gives it its usual 3 minutes to start before counting any failed check.
  2. The app then fails 3 health checks in a row. If that happens within 10 minutes of the deploy finishing, the Hub blames the new version and redeploys the image that ran before it.
  3. You get a notification titled “api was rolled back”. It goes to the channels that follow Failed deploys, so you don’t need to change anything.

The Hub doesn’t roll back when:

  • the node itself is offline: that’s a failover, not a bad release;
  • the deploy was a redeploy of the same image, such as after you changed an environment variable: an older image wouldn’t fix that;
  • the app failed more than 10 minutes after its deploy;
  • the failing deploy was itself a rollback, a failover or a move.

There is at most one automatic rollback per deploy. If the app still fails after it, the normal failover takes over.

Terminal window
$ asdl-hub rollback api
api runs ghcr.io/me/api:v2
Roll back to ghcr.io/me/api:v1 (deployed 5h ago)
fix the login redirect
Roll back api? [Y/n] y
Rolling back api…
Done.

It shows which image runs now and which it will put back, with the commit message of that deploy, and asks first. The previous version is the newest image that was successfully deployed before the current one. The app is redeployed on its current node (or the best available node, if that one is down), with its current settings and secrets.

  • It’s refused while another deploy of the app is still running, and when the app has only ever run one version.
  • Run it a second time and it goes back forward: the “previous” version is now the one you just left.
  • The same is available from the API: GET /projects/:id/rollback says what it would restore, and POST /projects/:id/rollback does it (operators and admins).

After a rollback the app runs the old version, and the version you left is now the “previous” one. To get a newer version running again:

  1. Push the fix. This is the normal way: the push deploys like any other, and if it fails its health checks within 10 minutes the Hub rolls it back again.

  2. Go back to the version you left. Run asdl-hub rollback <app> a second time. It swaps to the newest image that differs from the running one, and shows both images before it asks, so check the tags.

  3. Deploy a named image. Set it, then deploy:

    Terminal window
    $ asdl-hub app set api image=ghcr.io/me/api:v3
    $ asdl-hub deploy api

    app set only records the image; deploy is what starts it. This counts as a normal deploy, so the automatic rollback protects it.