Sometimes deployment or other processes running within pods on nodes in a cluster can run for periods of time longer than expected due to various reasons. While it’s important to allow those processes to gracefully terminate when they’re no longer needed, there are circumstances where you need to release control of node pools and clusters with long running operations using an abort command.

AKS now supports aborting a long running operation, allowing you to take back control and run another operation seamlessly. This design is supported using the Azure REST API or the Azure CLI.

The abort operation supports the following scenarios:

  • If a long running operation is stuck or suspected to be in a bad state or failing, the operation can be aborted provided it’s the last running operation on the Managed Cluster or agent pool.
  • If a long running operation is stuck or failing, that operation can be aborted.
  • An operation that was triggered in error can be aborted as long as the operation doesn’t reach a terminal state first.

Before you begin

This article assumes that you have an existing AKS cluster. If you need an AKS cluster, start with reviewing our guidance on how to design, secure, and operate an AKS cluster to support your production-ready workloads. For more information, see AKS architecture guidance.

Abort a long running operation

You can use the az aks nodepool command with the operation-abort argument to abort an operation on a node pool or a managed cluster.

The following example terminates an operation on a node pool on a specified cluster by its name and resource group that holds the cluster.

Azure CLI

az aks nodepool operation-abort --resource-group myResourceGroup --cluster-name myAKSCluster --name myNodePool 

The following example terminates an operation against a specified managed cluster its name and resource group that holds the cluster.

az aks operation-abort --name myAKSCluster --resource-group myResourceGroup

In the response, an HTTP status code of 204 is returned.

Azure REST API

You can use the Azure REST API Abort operation to stop an operation against the Managed Cluster.

The following example terminates a process for a specified agent pool.

/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/agentPools/{agentPoolName}/abort

The following example terminates a process for a specified managed cluster.

/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/abort

In the response, an HTTP status code of 204 is returned.

The provisioning state on the managed cluster or agent pool should be Canceled. Use the REST API Get Managed Clusters or Get Agent Pools to verify the operation. The provisioning state should update to Canceled within a few seconds of the abort request being accepted. Operation status of last running operation ID on the managed cluster/agent pool, which can be retrieved by performing a GET operation against the Managed Cluster or agent pool, should show a status of Canceling.