When a deployment in an Elastic Compute Service (ECS) cluster encounters issues mid-rollout, you can stop the update immediately by calling the AbortChangeOrder operation through the Enterprise Distributed Application Service (EDAS) SDK for Java. This prevents remaining instances from being updated with a problematic version.
AbortChangeOrder stops the update but does not roll back instances already updated. If the new version has issues, roll back the application separately. See Roll back an application deployed in an ECS cluster to a historical version.
Prerequisites
Before you begin, make sure that you have:
EDAS SDK for Java installed. See "Use EDAS SDK for Java to call EDAS API"
An application with an active update started through one of the following methods:
The region ID of the application. This example uses
cn-hangzhou(Optional) The change order ID. If you did not record the ID when starting the update, call ListRecentChangeOrder to retrieve the
ChangeOrderIdvalue. This example uses47e2b863-adc8-4a0e-ac23-8361b95a****
Terminate the update
Call AbortChangeOrder with the ChangeOrderId parameter set to the change order ID of the active update.
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.edas.model.v20170801.AbortChangeOrderRequest;
import com.aliyuncs.edas.model.v20170801.AbortChangeOrderResponse;
public class AbortChangeOrder {
public static void main(String[] args) {
// Retrieve credentials from environment variables.
// Use a RAM user instead of an Alibaba Cloud account for least-privilege access.
// To prevent credential leaks, do not hardcode your AccessKey ID or AccessKey secret in the code.
String aliyun_user_ak = System.getenv("ACCESS_KEY_ID");
String aliyun_user_sk = System.getenv("ACCESS_KEY_SECRET");
// Specify the region ID where the application is deployed.
String region_id = "cn-hangzhou";
DefaultProfile defaultProfile = DefaultProfile.getProfile(region_id, aliyun_user_ak, aliyun_user_sk);
DefaultAcsClient client = new DefaultAcsClient(defaultProfile);
// Create the request and set the change order ID.
AbortChangeOrderRequest request = new AbortChangeOrderRequest();
request.setChangeOrderId("47e2b863-adc8-4a0e-ac23-8361b95a****");
try {
AbortChangeOrderResponse response = client.getAcsResponse(request);
System.out.println("Message=" + response.getMessage() + "\nRequestId=" + response.getRequestId());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}Replace the following placeholders with your actual values:
| Placeholder | Description |
|---|---|
ACCESS_KEY_ID | AccessKey ID of your Resource Access Management (RAM) user, stored as an environment variable |
ACCESS_KEY_SECRET | AccessKey secret of your RAM user, stored as an environment variable |
cn-hangzhou | Region ID where the application is deployed |
47e2b863-adc8-4a0e-ac23-8361b95a**** | Change order ID of the active update |
Sample response:
Message=success
RequestId=19C54DC3-C66C-40D0-AEED-8D5A1F00F3BAVerify the result
After terminating the update, call GetChangeOrderInfo with the same change order ID to confirm the status.
In the response, check changeOrderInfo.Status. A value of 6 confirms that the update was stopped. See the following table for all possible values.
Sample response:
{
"Message": "success",
"RequestId": "CCC48EB3-E628-45B4-8DF3-ED8551119742",
"Code": 200,
"changeOrderInfo": {
"Status": 6,
"Desc": "create by edas pop api",
"PipelineInfoList": {
"PipelineInfo": [
...
]
}
}
}Change order status values
| Status | Description |
|---|---|
0 | Ready to start |
1 | In progress |
2 | Completed |
3 | Failed |
6 | Stopped (update was terminated) |
8 | Waiting for manual trigger in a manual phased release |
9 | Waiting for automatic trigger in an automatic phased release |
10 | Failed due to a system exception |
What to do next
If the new version has issues, roll back to a previous version. See Roll back an application deployed in an ECS cluster to a historical version.
To start a new deployment, see Single-release deployment, Phased release, or Canary release.