# Update

**Spinbox is experimental: APIs change and data may be lost.** What is built and what proves it is on [Status](https://docs.spinbox.dev/reference/status.md); what Spinbox does not do is on [Limitations](https://docs.spinbox.dev/overview/limitations.md).

> Move an installation to a new release, and what happens to its machines and workspaces while it rolls out.

<!-- Generated by tools/refgen from spin-terraform-aws's README.md. Edit the README, not this file. -->

An installation on a channel (`spin_version = "edge"` or `"stable"`) is updated by its next plan:
the channel names the newer release, and the plan shows its images and the key policies its builds
change. One on a release changes `spin_version` in `terraform.tfvars` to the new one. Either way:

```bash
tofu plan     # the image, the launch templates and the documents change, and nothing else
tofu apply
```

The module has releases of its own, `v<YYYYMMDD>.<NN>` tags: an installation that pins one
(`?ref=v<YYYYMMDD>.<NN>`) gets the module's changes when you move the ref, not when main moves. The
spin release it runs is `spin_version`'s, and moves without the module's ref. The newest is the first
on [its releases](https://github.com/spin-stack/spin-terraform-aws/releases).

The control plane and the proxy are each replaced beside themselves. The old proxy serves until the
new one does. The control plane's database has one writer, so the old control plane serves until
the new one asks for it, then archives what it wrote and stops: the installation has no control
plane until the new one has restored the database and started - seconds, which `spin` waits out
for a read and a workspace does not notice. How it went is `tofu output update_status`:
`InProgress`, `Successful`, or `RollbackSuccessful` with the reason. A new control plane that
failed before it asked for the database leaves the old one serving; one that failed after hands the name back, and
the old machine's watch starts its control plane within a minute, which restores the database from
the archive first - or takes the name back after fifteen minutes when the new machine died without
handing it. `tofu output boot_log` - one command per role, since a role's machines are one stream prefix - says
why the new one did not come up. Until the launch hook gives up on a new machine that never comes
up, the refresh holds the group and an apply that changes it is refused; `tofu output update_abort`,
by group, is the command that rolls it back now. A change to anything else a machine starts on -
`installation_config`, the autoscaling settings, the control plane's or the proxy's instance
type - rolls out the same way. A change to a machine's document alone reaches it when it next starts; to start one now:

```bash
aws autoscaling start-instance-refresh --auto-scaling-group-name <group>
```

A runner cannot take a release in place either - its root is read-only and verified - and how it
gets one is `runner_rollout`. `idle`, the default, moves no workspace for it: the control plane
empties the group once nothing runs, starts or is still being saved to the bucket, and the next
host it starts boots the new release. A control plane serves hosts of its own release and no other:
once the update has replaced it, a host still on the old release is refused when it registers again.
What becomes of the workspaces still running on such a host is open (spin-stack/spin#1332).
`rolling` is for a fleet that never empties: the hosts are replaced at once, one at a time with
the new one first, each old one leaving by its drain - its workspaces suspended to the bucket and
resumed on another host.

A release older than the one that last started the database refuses to start on it: going back
past a change to the schema is a restore of the database from its archive to a point before it,
not an update.
