Roll Back a Deployment
A rollback returns an instance to the state of a past deployment: its bundle version, params, and connections. It is created as a proposal, and nothing runs until someone with instance:deploy approves it.
Roll back when:
- A deployment left an instance in a bad state, and you want the last known-good run.
- An upgrade misbehaves in production, and you want the prior version with the params it had then.
- You rehearse incident response and want to test the rollback path.
To deploy an older bundle version with the current params, change the instance's version constraint and deploy it instead. A rollback reproduces one past run.
CLI​
# Find the deployment to return to
mass deployment list ecomm-production-db --action provision --status completed
# Propose the rollback
mass instance rollback <deployment-id>
# Approve it
mass deployment approve <proposed-deployment-id>
mass deployment reject <proposed-deployment-id> discards it.
rollbackDeployment​
- Checks the source. It must be a
COMPLETEDPROVISIONdeployment. Any other deployment is refused. - Copies the source's params, except
md_metadata, which is built again for the instance as it is now. - Copies the source's
connection_params, the connections the instance resolved at the time of the source run. - Copies the source's bundle version and version constraint.
- Creates a
PROPOSEDPROVISIONdeployment with these values, and a message ofRollback to deployment <id> (v<version>), followed by the source's message. The V2 API does not expose the link to the source deployment.
The proposal accepts approveDeployment, rejectDeployment, and planDeployment, like any other proposal.
Approval​
Approving a rollback also sets the instance's bundle version and version constraint to the source's, and reconciles its connections with that bundle version. Later edits start from the rolled-back state. Without the pin, the next deployment would return to the release that the rollback left.
To apply a past snapshot once and keep the current version constraint, use proposeDeployment instead of rollbackDeployment.
Permissions​
rollbackDeploymentneedsinstance:proposeon the instance.approveDeploymentandrejectDeploymentneedinstance:deployon the instance. No permission is specific to rollbacks.planDeploymentneedsinstance:plan.
With instance:propose and instance:deploy in production, as in the SRE example, an on-call engineer can propose and approve a rollback. In an environment with separation of duty, another person approves it.
GraphQL​
# 1. Find the deployment to return to
query LastGoodDeployment {
deployments(
organizationId: "acme"
filter: {
instanceId: { eq: "ecomm-production-db" }
action: { eq: PROVISION }
status: { eq: COMPLETED }
}
sort: { field: CREATED_AT, order: DESC }
) {
items { id version message createdAt }
}
}
# 2. Propose the rollback. id is the source deployment.
mutation {
rollbackDeployment(organizationId: "acme", id: "<source-deployment-id>") {
successful
result { id status action version message }
messages { field message }
}
}
# 3. Optional: plan the proposal to see the diff
mutation {
planDeployment(organizationId: "acme", id: "<proposal-id>") {
successful
result { id status }
}
}
# 4. Approve it
mutation {
approveDeployment(organizationId: "acme", id: "<proposal-id>") {
successful
result { id status }
}
}
rejectDeployment discards the proposal and leaves the instance unchanged. The proposal and the rejection are both in the audit log.
What the proposal holds​
| Source value | On the rollback proposal |
|---|---|
params | Copied, except md_metadata |
md_metadata | Built again from the instance's current organization, project, environment, and identifiers |
connection_params | Copied |
| Bundle version | Copied |
version constraint | Copied |
| Secrets | Not part of a deployment. The instance's current secrets apply. |
Limits​
- Secrets are not rolled back. They are on the instance, not on deployments. Revert a bad secret change separately.
- Data is not migrated. A rollback restores the bundle and params. It does not run reverse migrations.
- Only infrastructure in the deployment's state is reconciled. The rollback's
PROVISIONrun removes resources that the failed deployment created in its IaC state. Resources created outside Massdriver stay. - The approval gate always applies. A requester with
instance:deploystill approves the proposal withapproveDeployment, which records the approval in the audit log.
Roll back when a deployment fails​
The rollback-on-failure automation calls rollbackDeployment and approveDeployment when a PROVISION deployment of an opted-in instance fails. It returns the instance to its most recent COMPLETED PROVISION deployment. In an environment with separation of duty, the proposal waits for a person to approve it.
Reference​
mass instance rollback,mass deployment approve,mass deployment rejectrollbackDeployment,proposeDeployment,approveDeployment,rejectDeployment, andplanDeploymentin the V2 API- Instance permissions
- Deployments