Skip to main content

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​

shell
# 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​

  1. Checks the source. It must be a COMPLETED PROVISION deployment. Any other deployment is refused.
  2. Copies the source's params, except md_metadata, which is built again for the instance as it is now.
  3. Copies the source's connection_params, the connections the instance resolved at the time of the source run.
  4. Copies the source's bundle version and version constraint.
  5. Creates a PROPOSED PROVISION deployment with these values, and a message of Rollback 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​

  • rollbackDeployment needs instance:propose on the instance.
  • approveDeployment and rejectDeployment need instance:deploy on the instance. No permission is specific to rollbacks.
  • planDeployment needs instance: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​

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 valueOn the rollback proposal
paramsCopied, except md_metadata
md_metadataBuilt again from the instance's current organization, project, environment, and identifiers
connection_paramsCopied
Bundle versionCopied
version constraintCopied
SecretsNot 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 PROVISION run 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:deploy still approves the proposal with approveDeployment, 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​