All Products
Search
Document Center

Auto Scaling:Rolling update

Last Updated:Dec 29, 2023

Rolling update tasks can be used to update the configurations of multiple Elastic Compute Service (ECS) instances or elastic container instances at the same time. You can enable the Rolling Update feature to update images, run scripts, or install CloudOps Orchestration Service (OOS) packages on multiple ECS instances or elastic container instances that are in the In Service state at the same time.

Prerequisites

  • Images are created before you update images for ECS instances or elastic container instances in a scaling group.

  • Scripts are prepared before you run scripts on ECS instances or elastic container instances in a scaling group.

  • OOS packages are prepared before you install the OOS packages on ECS instances or elastic container instances in a scaling group. For more information, see Manage custom software on multiple ECS instances.

Rolling update tasks

Type

Description

Image update

You can create an image update task to update the OSs of multiple ECS instances or elastic container instances that are in the In Service state at the same time. The ECS instances or elastic container instances must be in the same scaling group.

Before you run an image update task, take note that the image update task may have the following impacts on the instance configuration source of the scaling group:

  • If the instance configuration source is a scaling configuration, the image in the scaling configuration that is in the Enabled state is automatically updated. The images in scaling configurations that are in the Disabled state in the scaling group are not updated.

  • If the instance configuration source is a launch template, the image in the launch template is not automatically updated. You must manually update the image in the launch template.

Note

You can create rolling update tasks or automatic update tasks to update images in your scaling configurations based on your business requirements. For more information, see Compare rolling update with automatic update.

Script running

You can create a script running task to perform one or more O&M operations at the same time. Example:

  • View and update system configurations such as disk space.

  • Install common software such as Apache.

  • Deploy service code.

OSS package installation

You can create an OSS package installation task to install or uninstall software on multiple ECS instances or elastic container instances at the same time.

Compare rolling update with automatic update

  • Automatic update: suitable for scenarios in which applications are frequently published. You can create automatic update tasks only in scaling groups of the ECS type. After you create automatic update tasks in the Auto Scaling console, Auto Scaling automatically creates custom images for original ECS instances in scaling groups. This ensures that new ECS instances in scaling groups are all created based on the latest custom images. For more information, see Automatically update an image in a scaling configuration.

  • Rolling update: suitable for scenarios in which you must update the configurations of multiple ECS instances or elastic container instances at the same time. You can create and execute rolling update tasks in all regions that support OOS. You can enable this feature to gradually update the images of all existing ECS instances or elastic container instances that are in the In Service state in your scaling group to the latest version.

Create and run a rolling update task

Before you create and run a rolling update task, take note of the following items:

  • The Rolling Update feature is available only in regions where OOS is supported.

  • The scaling group for which you want to enable the Rolling Update feature must have no ongoing scaling activities.

  • You can run only one rolling update task at a time.

  1. Log on to the Auto Scaling console.

  2. In the left-side navigation pane, click Scaling Groups.

  3. In the top navigation bar, select the region where Auto Scaling is activated.

  4. Find a scaling group and use one of the following methods to go to the scaling group details page:

    • Click the ID of the scaling group in the Scaling Group Name/ID column.

    • Click Details in the Actions column.

  5. In the upper part of the scaling group details page, click the Rolling Update tab.

  6. Click Create Execution Task.

  7. In the Create Execution Task dialog box, configure parameters based on your business requirements and click Create Task.

    The following table describes the parameters.

    Parameter

    Description

    Task Description

    The description of the rolling update task.

    Task Type

    • Update Image: You can create tasks of this type to replace the current images of ECS instances or elastic container instances. You can select a public image, a custom image, a shared image, or an image from Alibaba Cloud Marketplace. The ECS instances or elastic container instances are restarted during the update. You must also configure the following parameters:

      • Image for Update: the image that is used in the update task.

      • Image for Rollback: the image that is used in the rollback task.

        Note

        When you create a rollback task, the image that you selected for the Image for Rollback parameter is used. You can select other images based on your business requirements.

    • Script Execution: You can create this type of task and use Cloud Assistant to run scripts without the need to stop ECS instances or elastic container instances. You must also configure the following parameters:

      • In the Script Type section, select one of the following script types:

        • Linux Shell: Examples of this script type are echo hello and hostname.

        • Windows Bat: An example of this script type is dir c:\.

        • Windows PowerShell: An example of this script type is Get-Services.

      • Script for Execution: the script that is used to run the update task.

      • Script for Rollback: the script that is used to run the rollback task.

        Note

        When you create a rollback task, the script that you selected for the Script for Rollback parameter is used. You can modify the script based on your business requirements.

    • Install OOS Package: You can create this type of task to install OOS packages. Select the name and version of the package that you want to install.

    Execution Batch

    The number of batches that are required to run the task. The task is run in multiple batches, and each ECS instance or elastic container instance is updated as part of a specific batch. Each batch contains at least one ECS instance or elastic container instance. For example, if a scaling group has 10 ECS instances that are in the In Service state and the Execution Batch parameter is set to 2, the task is run in two batches with five ECS instances in each batch.

    Suspension Policy

    • Without Suspension: Auto Scaling runs the task without interruptions.

    • Suspend First Batch: Auto Scaling suspends the task after the first batch is completed. If you want to continue the task, you must manually resume the task. After you manually resume the task, the task is not suspended in subsequent batches.

    • Suspend Each Batch: Auto Scaling suspends the task each time after a batch is completed. You must manually continue the task after each batch is complete.

    Advanced Settings

    Optional. If you set Task Type to Update Image, you can specify the maximum number of errors that are allowed before the rolling update task stops. If you do not configure the Error Threshold parameter, the default value is 0, which indicates that the rolling update task fails if one error occurs.

  8. Read and understand the impacts of the rolling update task and click OK.

    Then, the rolling update task is automatically run. The rolling update task has the following impacts on the scaling group and on the ECS instances or elastic container instances in the scaling group:

    • If scaling activities are in progress during the execution of the rolling update task, Auto Scaling suspends the scaling activities. After the rolling update task is completed, Auto Scaling resumes the scaling activities. If you manually suspend scaling activities before the rolling update task is run, the scaling activities remain suspended until the task is completed. This ensures that the status of the scaling activities remains unchanged before and after the task is run.

    • Auto Scaling changes the status of ECS instances or elastic container instances to Standby in batches and restores the instances to the In Service state after the rolling update task is completed.

      Important

      If the scaling group is associated with Server Load Balancer (SLB) instances, the SLB weights of the ECS instances or elastic container instances that are in the Standby state are set to zero and no business traffic is received.

  9. Perform the operations that are described in the following table based on the status of the rolling update task.

    Operation

    Description

    Procedure

    Continue the rolling update task

    If the suspension policy of the rolling update task is Suspend First Batch or Suspend Each Batch, the task enters the Pending (Batch Suspension) state once or multiple times. Check whether the updated ECS instances or elastic container instances meet your business requirements. After you confirm the relevant information, continue the rolling update task.

    1. Click Continue in the Actions column.

    2. In the Continue Execution Task message, click OK.

    Complete the rolling update task

    If the rolling update task fails to be run, the task enters the Pending (Failure Suspension) state. If you want to complete the rolling update task, select an appropriate update operation.

    1. Click Details in the Actions column.

    2. Find the ECS instance or elastic container instance that is in the Failure state and click Retry, Skip, or Cancel in the Actions column.

      • Click Retry to retry rolling update for the ECS instance or elastic container instance again.

      • Click Skip to perform rolling update for the next ECS instance or elastic container instance. The status of the ECS instance or elastic container instance that is skipped is changed to Success.

        Important

        You must manually remove the ECS instance or elastic container instance that is skipped from the Standby state.

      • Click Cancel to perform rolling update for the next ECS instance or elastic container instance. The status of the ECS instance or elastic container instance for which the rolling update task is canceled is changed to Failure.

    Cancel the rolling update task

    If the rolling update task does not meet your business requirements, you can cancel the task.

    Choose Dingtalk_20231212165532.jpg > Cancel in the Actions column.

    Important

    After you cancel the rolling update task, you must manually resume the suspended scaling activities and remove the ECS instances or elastic container instances that are in the Failure state or are being updated in the current batch from the Standby state.

    Roll back the rolling update task

    If the rolling update task is in the Pending (Batch Suspension) or Pending (Failure Suspension) state or is recently run, you can roll back the rolling update task.

    For more information, see Roll back a rolling update task.

Roll back a rolling update task

To restore the configurations of ECS instances or elastic container instances when an error occurs, you can roll back a rolling update task that is in the Pending (Batch Suspension) or Pending (Failure Suspension) state. You can also roll back the most recent rolling update task that is run. If you roll back a rolling update task that is in the Pending state, the rolling update task is canceled and the instances that are updated are rolled back.

Important

You can roll back only a rolling update task. You cannot roll back a rollback task.

  1. On the Rolling Update tab, find the desired task and click Rollback in the Actions column.

  2. In the Create Rollback Task dialog box, configure parameters based on your business requirements.

    The following table describes the parameters.

    Parameter

    Description

    Task Description

    The description of the rollback task.

    Task Type

    The task type is the same as that of the rolling update task and cannot be edited.

    • If the task type is Update Image, the image that you selected for the Image for Rollback parameter when you created the rolling update task is automatically selected. You can select other images based on your business requirements.

    • If the task type is Script Execution, the script that you selected for the Script for Rollback parameter when you created the rolling update task is automatically used. You can modify the script based on your business requirements.

    • If the task type is Install OOS Package, the version of the OOS package that you specified when you created the rolling update task is automatically selected. You can select other versions based on your business requirements. You cannot select other packages.

    Execution Batch

    The number of batches that are required to run the task. The task is run in multiple batches, and each ECS instance or elastic container instance is rolled back as part of a specific batch. Each batch contains at least one ECS instance or elastic container instance. For example, if a scaling group has 10 ECS instances that are in the In Service state, and the Execution Batch parameter is set to 2, the task is run in two batches with five ECS instances in each batch.

    Suspension Policy

    • Without Suspension: Auto Scaling runs the task without interruptions.

    • Suspend First Batch: Auto Scaling suspends the task after the first batch is completed. If you want to continue the task, you must manually resume the task.

    • Suspend Each Batch: Auto Scaling suspends the task each time a batch is completed. You must manually continue the task.

    Advanced Settings

    Optional. If you set Task Type to Update Image, you can specify the maximum number of errors that are allowed before the rollback task stops.

  3. Click Create Task.

  4. Read and understand the impacts of the rollback task and click OK.

    Then, the rollback task is automatically run.

View the details of a rolling update task

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

  1. On the Rolling Update tab, find the desired task and click Details in the Actions column.

  2. View the basic information of the task.

    The basic task information includes the task status and the task type. If the task type is Script Execution, click Script Details to view the details of the script.

  3. View the instance list.

    The ECS instances or elastic container instances that are in various states are displayed.

    • If rolling update is not completed for an ECS instance or elastic container instance, you can skip or cancel rolling update for the instance.

    • If an ECS instance or elastic container instance fails to be updated, you can retry, skip, or cancel rolling update for the instance in the Actions column.

    • If the task type is Script Execution, click View in the Result column to view the output of the script.

    The following section describes the differences between retrying, skipping, and canceling rolling update for an ECS instance or elastic container instance:

    • Click Retry to retry rolling update for the ECS instance or elastic container instance.

    • Click Skip to perform rolling update for the next ECS instance or elastic container instance. The status of the ECS instance or elastic container instance that is skipped is changed to Success.

      Important

      You must manually remove the ECS instance or elastic container instance that is skipped from the Standby state.

    • Click Cancel to perform rolling update for the next ECS instance or elastic container instance. The status of the ECS instance or elastic container instance for which the rolling update task is canceled is changed to Failure.

Enable monitoring and alerting for a rolling upgrade task

You can enable monitoring and alerting for separate rolling update tasks based on your business requirements. This way, you can easily troubleshoot rolling update issues based on alert details.

  1. Log on to the CloudMonitor console.

  2. In the left-side navigation pane, choose Event Center > System Event.

  3. On the System Event page, specify filter conditions and click Search to query the rolling update failure events of the specified scaling group.

    For example, if you select Critical as the filter condition, enter the following keyword:

    (ACS-ESS-RollingUpdateByConfigureOOSPackage or ACS-ESS-RollingUpdateByReplaceSystemDiskInScalingGroup or ACS-ESS-RollingUpdateByRunCommandInScalingGroup or ACS-ESS-RollingUpdateByUpdateContainerGroup) and ${your_scaling_group_id}
    Note

    Replace {your_scaling_group_id} with your actual scaling group ID, such as asg-bp180y8dj5eku2j4****.

    资源告警.png

  4. Click Save as Alert.

  5. In the Create/Modify Event-triggered Alert Rule panel, configure the following parameters based on your business requirements and click OK.

    gundong.png

  6. In the left-side navigation pane, choose Alerts > Alert History.

    On the Alert History page, you can view the details of the alert. 2023-12-12_18-34-22.png