AWS Delete ECS Service with Bamboo - 该服务无法停止

AWS Delete ECS Service with Bamboo - The service cannot be stopped

我正在尝试使用 Bamboo ECS 服务删除任务停止 AWS 上的服务。但是,我收到以下错误:

Deleting service 'my-service' on cluster 'my-cluster':
    Service request rejected by AWS!
    com.amazonaws.services.ecs.model.InvalidParameterException: The service cannot be stopped while it is scaled above 0. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: 03dab8da-xyz)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1695)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1350)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1101)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:758)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:732)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:714)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access0(AmazonHttpClient.java:674)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:656)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:520)
        at com.amazonaws.services.ecs.AmazonECSClient.doInvoke(AmazonECSClient.java:3289)
        at com.amazonaws.services.ecs.AmazonECSClient.invoke(AmazonECSClient.java:3256)
        at com.amazonaws.services.ecs.AmazonECSClient.invoke(AmazonECSClient.java:3245)
        at com.amazonaws.services.ecs.AmazonECSClient.executeDeleteService(AmazonECSClient.java:859)
        at com.amazonaws.services.ecs.AmazonECSClient.deleteService(AmazonECSClient.java:831)
        at net.utoolity.atlassian.bamboo.taws.ECSServiceTask.executeDelete(ECSServiceTask.java:344)
        at net.utoolity.atlassian.bamboo.taws.ECSServiceTask.execute(ECSServiceTask.java:141)
        at net.utoolity.atlassian.bamboo.taws.AWSTask.execute(AWSTask.java:164)
        at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks(TaskExecutorImpl.java:319)
        at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:252)
        at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:319)
        at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)
        at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)
        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203)
        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175)
        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild[=10=](BuildAgentControllerImpl.java:129)
        at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:123)
        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.run(DefaultBuildAgent.java:126)
        at com.atlassian.bamboo.utils.BambooRunnables.run(BambooRunnables.java:48)
        at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
        at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
        at com.atlassian.bamboo.security.ImpersonationHelper.run(ImpersonationHelper.java:41)
        at java.lang.Thread.run(Thread.java:745)
    Finished task 'delete ecs service' with result: Error

我假设原因是这个 ECS 服务中已经有一个任务仍然 运行。但是,当我使用 aws-cli 命令时,服务被删除没有任何问题:

aws ecs delete-service --cluster my-cluster --service my-service --force

可能是Bamboo任务中没有强制选项。有什么想法吗?

解决方案是先更新 ECS 服务并将所需计数设置为 0,然后删除该服务。