This topic describes how to manage rolling update tasks. Rolling update tasks can be used to update the configurations of ECS instances in batches. You can use Rolling Update to perform batch operations on ECS instances in the In Service state in a scaling group. You can perform operations such as updating images or executing scripts.

Prerequisites

  • No scaling activities are in progress in a scaling group.
  • A script or an image is prepared.
    Note A custom image is prepared for updating images in batches. Other types of images are not supported.

Background information

You can update the configurations of ECS instances by updating images or executing scripts. The applicable scenarios are as follows:
  • Image updates are more comprehensive. You can perform image updates to update the operating systems of all ECS instances in a scaling group at a time.
  • Scripts are more flexible. You can use scripts to perform one or more O&M operations that are suitable for the following scenarios:
    • View and update some system configurations such as the disk space.
    • Install commonly used software such as Apache.
    • Deploy business code.

Limits

  • You can update images or execute scripts only for ECS instances in the In Service state.
  • You can execute only one rolling update task at a time.

Create and execute a rolling update task

  1. Log on to the Auto Scaling console.
  2. In the top navigation bar, select a region.
  3. Find the target scaling group and use one of the following methods to open the details page of the scaling group:
    • Click the ID of the scaling group in the Scaling Group Name/ID column.
    • Click Manage in the Actions column.
  4. In the left-side navigation pane, click Rolling Update.
  5. Click Create Execution Task.
  6. In the Create Execution Task dialog box that appears, configure the required parameters and click Create Task.
    The following table describes the parameters that you must configure.
    Section Description
    Task Description The description of the rolling update task.
    Task Type
    • Image Update

      You can replace the current images of ECS instances. During the process, the ECS instances are restarted. You must specify the following parameters:

      • Image for Update: You can select only a custom image. The image that is used in the current scaling configuration is updated.
      • Image for Rollback: the image that you use to execute a rollback task. You can select a custom, public, shared, or Marketplace image.
        Note When you create a rollback task, this image is used by default. You can select other images.
    • Script Execution

      Cloud Assistant is used to execute scripts. ECS instances are not stopped when the scripts are executed. For more information, see Cloud Assistant overview. You must specify the following parameters:

      • In the Script Type section, select one of the following script types:
        • Linux Shell: such as echo hello and hostname
        • Windows Bat: such as dir c:\
        • Windows PowerShell: such as Get-Services
      • Script for Execution: the script that is used to execute tasks for ECS instances
      • Script for Rollback: the script that is used to execute rollback tasks
        Note When you create a rollback task, this script is used by default. You can edit the scripts.
    Execution Batch The number of times this task is executed. The ECS instances are divided into multiple batches, and the task is run on these batches. For example, if a scaling group has 10 ECS instances in the In Service state, and the execution batch is 2, this task is executed in two batches.
    Suspension Policy
    • Automatic: The task is completed without interruptions.
    • Suspend First Batch: Auto Scaling suspends the task after the first batch is complete. You must manually continue the task. After you manually continue the task, the subsequent batches will not be suspended.
    • Suspend Each Batch: Auto Scaling suspends the task each time after a batch is complete. You must manually continue the task after each batch.
  7. Read the execution impact and click OK if you confirm the information.
    After you confirm the information, the rolling update task is automatically executed.
  8. Perform the following operations based on the execution status of the rolling update task:
    • If the suspension policy of a rolling update task is Suspend First Batch or Suspend Each Batch, the task will enter the Pending (Batch Suspension) state once or more times. Confirm that the ECS instances that have been updated meet your requirements. Perform the following operations if you confirm the information:
      1. Click Continue in the Actions column.
      2. In the Continue Execution Task dialog box that appears, click OK.
    • If the execution of a rolling update task fails, the task enters the Pending (Failure Suspension) state. If you want to continue this task, perform the following operations:
      1. Click Details in the Actions column.
      2. Find an ECS instance in the Failure state. Click Retry, Skip, or Cancel in the Actions column.
        • Click Retry to execute the rolling update for this ECS instance again.
        • Click Skip to execute the rolling update for the next ECS instance. The status of the current ECS instance is changed to Success.
          Notice You must manually remove the ECS instance that is skipped from the Standby state.
        • Click Cancel to execute the rolling update for the next ECS instance. The status of the current ECS instance is changed to Failure.
    • If you want to cancel the rolling update task, click Cancel in the Actions column.
      Notice After you cancel the rolling update task, you must manually resume the suspended scaling processes and remove the ECS instances that are in the Failure state or are being updated in the current batch from the Standby state.
    • For more information about how to roll back a rolling update task, see Roll back a rolling update task.

Roll back a rolling update task

You can roll back a rolling update task that is in the Pending state (contains Batch Suspension and Failure Suspension) or is last executed to resume the configurations of ECS instances when an exception occurs. You cannot roll back a rollback task.
Note Before you roll back a rolling update task in the Pending state, the rolling update task will be canceled. Instances that have been updated will be rolled back.
  1. In the execution task list, find the target task and click Rollback in the Actions column.
  2. In the Create Rollback Task dialog box that appears, configure the required parameters.
    The following table describes the parameters that you must configure.
    Section Description
    Task Description The description of the rollback task.
    Task Type The task type is consistent with that of the rolling update task. You cannot modify the task type.
    • If the task type is Image Update, the image that is used when you create the rolling update task is automatically selected. You can select other images.
    • If the task type is Script Execution, the script that is specified when you create the rolling update task is automatically filled. You can edit the script.
    Execution Batch The number of times this task is executed. The ECS instances are divided into multiple batches, and the task is run on these batches. Each batch contains at least one ECS instance. For example, if a scaling group has 10 ECS instances in the In Service state, and the execution batch is 2, this task is executed in two batches.
    Suspension Policy
    • Automatic: The task is completed without interruptions.
    • Suspend First Batch: Auto Scaling suspends the task after the first batch is complete. You must manually continue the task.
    • Suspend Each Batch: Auto Scaling suspends the task each time after a batch is complete. You must manually continue the task after each batch.
  3. Click Create Task.
  4. Read the rollback impact and click OK if you confirm the information.
    After you confirm the information, the rollback task is automatically executed.

View the details of a rolling update task

You can view the details of a rolling update task and retry or skip a task for an ECS instance.

  1. In the execution task list, find the target task and click Details in the Actions column.
  2. View the basic task information.
    The basic task information contains the task status and type. If the task type is Script Execution, click Script Details to view the details of the script.
  3. View the execution instance list.
    ECS instances in various states are displayed.
    • If an ECS instance is not updated, you can skip or cancel the task for the instance.
    • If an ECS instance fails to be updated, you can retry, skip, or cancel the task for the instance in the Actions column.
    • If the task type is Script Execution, click View in the Result column to view the execution result of the script.
    The difference between retrying, skipping, and canceling a task for an ECS instance is as follows:
    • Click Retry to execute the rolling update for this ECS instance again.
    • Click Skip to execute the rolling update for the next ECS instance. The status of the current ECS instance is changed to Success.
      Notice You must manually remove the ECS instance that is skipped from the Standby state.
    • Click Cancel to execute the rolling update for the next ECS instance. The status of the current ECS instance is changed to Failure.

Sample rolling update tasks

The status of a scaling group is as follows:
  • The effective scaling configuration uses the CentOS 6.4 64-bit public image.
  • The scaling group has 10 ECS instances in the In Service state. The instances are created based on the effective scaling configuration.

This example shows how to use Rolling Update to update the images of ECS instances in a scaling group to the Alibaba Cloud Aliyun Linux 2 image, and how to install Apache after the images are updated.

  1. Select the Aliyun Linux 2.1903 LTS 64-bit image when you create an ECS instance.
    In this example, specify the name of the ECS instance as Instance-ForCustomImage and configure other required parameters. For more information about the procedure, see Create an instance by using the provided wizard.
  2. Create a custom image for the Instance-ForCustomImage instance.
    In this example, specify the name of the custom image as Image-AliyunLinux and configure other required parameters. For more information about the procedure, see Create a custom image from an instance.
  3. Optional:Select an ECS instance in the scaling group to create a custom image and use the image for rollback. If you do not want to save the configurations or data of the current instance, skip this step.
    In this example, specify the name of the custom image as Image-CentOSBck and configure other required parameters.
  4. Create and execute an image update task.
    The following table describes the parameters that you must configure.
    Section Example
    Task Description Update the image from CentOS 6.4 64-bit to Aliyun Linux 2.1903 LTS 64-bit in batches
    Task Type Image Update
    Image for Update Image-AliyunLinux
    Image for Rollback Image-CentOSBck
    Execution Batch 2
    Suspension Policy Automatic
    After the image update task is completed, the images of 10 ECS instances in the scaling group are updated to Aliyun Linux 2.1903 LTS 64-bit.
  5. Create and execute a script execution task.
    The following table describes the parameters that you must configure.
    Section Example
    Task Description Install Apache and view the status of Apache
    Task Type Script Execution
    Script for Execution
    # Install Apache.
    yum install -y httpd
    # Start Apache.
    systemctl start httpd
    # Enable Apache to run at startup.
    systemctl enable httpd
    # View the status of Apache.
    systemctl status httpd
    Script for Rollback
    # View the status of Apache.
    systemctl status httpd
    Execution Batch 2
    Suspension Policy Automatic
    After the script execution task is completed, Apache is installed on the 10 ECS instances in the scaling group. The status of Apache is active.View the status of Apache