本文介绍如何排查尝试启动、升级或缩放 Microsoft Azure Kubernetes 服务 (AKS) 群集时发生的 OperationNotAllowed 错误。
先决条件
现象
遇到多个症状,其中包括以下错误消息之一:
不允许操作:正在进行另一个操作(<操作名称>),请等待它完成,然后再开始新操作。 有关详细信息,请参阅https://aka.ms/aks-pending-operation
或者,如果是代理池上的操作:
不允许操作:正在进行另一个代理池操作(<操作名称>),请等待它完成,然后再开始新操作。 有关详细信息,请参阅https://aka.ms/aks-pending-operation
或:
不允许使用托管群集操作:代理池(agent-pool-name)正在进行另一个操作(<>操作名称<>),请在启动新操作之前等待它完成。 有关详细信息,请参阅https://aka.ms/aks-pending-operation
原因
某些操作需要一些时间才能运行。 这些操作会阻止其他操作(如果未完成)。
解决方案 1:等待操作完成
在以下示例中,如果在从另一个客户端更新群集时从一个客户端启动群集,则会发生“OperationNotAllowed”错误。
az aks start -n <myAKSCluster> -g <myResourceGroup>
(OperationNotAllowed) managed cluster is in Provisioning State(Updating) and Power State(Running), starting cannot be performed The previous operation started at '2024-02-21T13:33:55Z' and elapsed time is: '00:00:00' (RFC3339 format)
Code: OperationNotAllowed
Message: managed cluster is in Provisioning State(Starting) and Power State(Running), starting cannot be performed The previous operation started at '2024-02-21T13:33:55Z' and elapsed time is: '00:00:00' (RFC3339 format)
若要解决此问题,可以等待阻止操作完成,或者尝试使用 az aks operation-abort 命令中止长时间运行的操作。
解决方案 2:确保一行中不执行两个类似的操作
如果在已处于所需状态的群集上执行操作,则会发生“OperationNotAllowed”错误。
例如,如果群集已停止,则执行另一个停止操作将触发此错误:
az aks stop -n <myAKSCluster> -g <myResourceGroup>
(OperationNotAllowed) managed cluster is not currently running, stopping cannot be performed; The stop operation started at '2024-02-13T15:01:15Z' and elapsed time is: '7 days and 01:16:37' (RFC3339 format)
Code: OperationNotAllowed
Message: managed cluster is not currently running, stopping cannot be performed; The stop operation started at '2024-02-13T15:01:15Z' and elapsed time is: '7 days and 01:16:37' (RFC3339 format)
若要解决此问题,请在尝试再次停止群集之前启动群集。
解决方案 3:在尝试操作之前获取当前群集状态
还可以在尝试操作之前确定群集的当前状态。 若要帮助诊断问题,请运行以下 az aks show 命令来检索有关群集的详细状态。
az aks show --resource-group <myResourceGroup> --name <myAKSCluster> --output table
然后,使用下表根据命令结果执行相应的操作。 (请参阅 ProvisioningState 命令输出表中的 az aks show 列。
| 命令结果 | 操作 |
|---|---|
| 群集正在积极更新 | 等待操作完成。 |
| 群集更新失败 | 找到活动日志中失败的原因。 |
| 群集更新成功 | 重试启动、缩放或其他以前失败的操作。 |
解决方案 4:重试操作
在某些情况下,由于暂时性问题导致操作失败,并且状态不一致。
在下面的示例中,在节点池 <代理池代理池> 上发出了删除操作,但尚未完成该删除。 删除启动后,无法对资源执行其他操作。 这就是为什么缩放操作失败并出现“OperationNotAllowed”错误的原因。
{
"code": "OperationNotAllowed",
"details": null,
"message": "Unable to perform 'Scaling' operation on 'agentpool' since deletion was issued on 'agentpool'. The only allowed operation is deletion once deletion has started. The delete operation started at '2024-01-09T04:29:12Z' and elapsed time is: '00:30:28' (RFC3339 format)",
"subcode": ""
}
若要解决此问题,请等待删除完成。 如果几个小时后未完成,请稍后重试该删除。
联系我们寻求帮助
如果有疑问,可以询问 Azure 社区支持。 你还可以将产品反馈提交到 Azure 反馈社区。