Skip to main content

Post deployment rollback

Post deployment rollback initiates a rollback of your most recent successful deployment. This allows rapid, predictable recovery from a deployment that succeeded on technical criteria, but that you want to roll back for other reasons.

Important notes

  • Post deployment rollback is currently supported for the following deployment types only:
    • Kubernetes

    • AWS Auto Scale Group (ASG)

    • Tanzu Application Services (TAS)

    • Amazon Elastic Container Service (ECS)

    • Native Helm

      Harness anticipates expanding this feature to other deployment types in the future.

  • You can rollback successful pipelines only. The rollback option is not available for failed pipelines.
  • Only the rollback steps that are part of the stage can be used during rollback.
  • You cannot roll back the same pipeline multiple times. You can perform rollback if the pipeline is executed again.
  • If the pipeline configuration has changed between executions, the previous execution YAML is used as reference to roll back.
  • Rollback steps can use expressions that refer to steps executed during the previous pipeline execution. The expressions are automatically resolved with values from the original execution.
  • The stages should roll back in reverse order when deployment rollback is triggered.
  • Rolling back to a previous post-production deployment is only possible for executions that occurred within the past 30 days.
  • You cannot roll back an execution if it is marked successful by the ignore failures failure strategy.

Roll back deployments

For post deployment rollback, Harness assumes that you have created a pipeline with multiple deployments so that the rollback steps can roll the pipeline back to the last successful deployment.

For more details on creating a pipeline, go to Create your first CD pipeline.

  1. Open your services dashboard.

  2. In Summary, in the Environments & Groups panel, select the deployment you want to roll back, and then select the instances link.

    Here's an example pipeline where the artifacts, library/nginx:stable-perl is deployed first, and library/nginx:stable-bullseye-perl is deployed next.

  3. In Instance Details, select Rollback.

    Here, you're rolling back the deployed instance with the artifact library/nginx:stable-bullseye-perl to the previously deployed instance with artifact library/nginx:stable-perl.

  4. In the Rollback infrastructure dialog, select Confirm.

    The pipeline execution for rollback stage appears in a new tab.

    Once the rollback is complete, your deployed instances will return to the state they were in before the most recent deployment.

Permissions required for Post Deployment Rollback

To perform Post Deployment Rollback, user must have following permissions:-

  1. Pipeline Execute permission.
  2. Environment Rollback permission.
info

A user will be allowed to execute rollbacks on any instance only if they possess these two specified permissions for the pipeline and environment through which deployment occurred. Otherwise, they will be presented with the following message when attempting to click Rollback*.

Obtaining instance key and infrastructure mapping Id to roll back specific services using APIs

You can use APIs to trigger rollback for specific services. For more details, go to Trigger rollback. Note that you need instanceKey and infrastructureMappingId of the service instance for rollback. You can obtain these parameters using a cURL command.

Here's a sample cURL request:

curl --location 'https://https://app.harness.io/ng/api/dashboard/getInstancesDetails?routingId=<Account_Identifier>accountIdentifier=<Account_Identifier>orgIdentifier=<Org_Name>&projectIdentifier=<Project_Name>&serviceId=<Service_Id>&envId=<Environment_Id>&infraIdentifier=<Infrastructure>&buildId=null' \
--header 'x-api-key: <KEY>'

From the response, you can obtain infrastructureMappingId and instanceKey.