對 Amazon ECS 部署策略更新進行疑難排解 - Amazon Elastic Container Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

對 Amazon ECS 部署策略更新進行疑難排解

本節提供遷移部署策略時可能遇到的常見問題的解決方案。

多個服務修訂版或任務集

下列問題與部署時存在多個服務修訂版有關。

更新 ECS 部署控制器時存在多項任務集

錯誤訊息Updating the deployment controller is not supported when there are multiple tasksets in the service. Please ensure your service has only one taskset and try again.

解決方案:嘗試變更具有多個作用中任務集之服務的部署控制器類型時,會發生此錯誤。若要為 CODE_DEPLOYEXTERNAL 部署控制器解決此問題,請執行下列動作:

  1. 檢查目前的任務集:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].taskSets"
  2. 等待任何進行中的部署完成。

  3. 強制執行新部署以清理任務集:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --force-new-deployment
  4. 如有必要,手動刪除額外的任務集:

    aws ecs delete-task-set --cluster your-cluster-name --service your-service-name --task-set task-set-id
  5. 在僅剩一個任務集後,重試更新部署控制器。

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

更新 ECS 部署控制器時缺少主要任務集

錯誤訊息Updating the deployment controller requires a primary taskset in the service. Please ensure your service has a primary taskset and try again.

解決方案:嘗試變更沒有主要任務集之服務的部署控制器類型時,會發生此錯誤。若要解決此問題:

  1. 驗證服務狀態與任務集。如果服務中存在任務集,則應標記為 ACTIVE

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].taskSets[*].[status,id]

    如果沒有處於 ACTIVE 狀態的任務集,請遷移部署。如需詳細資訊,請參閱遷移方法

  2. 如果服務沒有執行中的任務,請更新服務,以部署至少一項任務:

    aws ecs update-service-primary-task-set --cluster your-cluster-name --service your-service-name --primary-task-set your-taskset-id

    這會將服務中 (先前為 ACTIVE 的) 任務集標記為 PRIMARY 狀態。

  3. 等待任務達到穩定的執行狀態。您可以使用下列命令檢查狀態:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].deployments"
  4. 在服務的主要任務集存在執行中任務後,重試更新部署控制器。

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

部署失敗偵測類型與部署控制器不相符

下列問題和部署失敗偵測類型與部署控制器不相符有關。

使用非 ECS 控制器的部署斷路器

錯誤訊息Deployment circuit breaker feature is only supported with ECS deployment controller. Update to ECS deployment controller and try again.

解決方案:嘗試在未使用 ECS 部署控制器的服務上啟用部署斷路器功能時,會發生此錯誤。部署斷路器僅與 ECS 部署控制器相容。

  1. 檢視服務目前的部署控制器:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].deploymentController"
  2. 更新服務以使用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS
  3. 服務使用 ECS 部署控制器後,啟用部署斷路器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-configuration "deploymentCircuitBreaker={enable=true,rollback=true}"

如需詳細資訊,請參閱 Amazon ECS 部署斷路器如何偵測失敗

使用非 ECS 控制器的警示型復原

錯誤訊息Alarm based rollback feature is only supported with ECS deployment controller. Update to ECS deployment controller and try again.

解決方案:嘗試在未使用 ECS 部署控制器的服務上設定警示型復原時,會發生此錯誤。警示型復原功能僅與 ECS 部署控制器相容。

  1. 檢視服務目前的部署控制器:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].deploymentController"
  2. 更新服務以使用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS
  3. 服務使用 ECS 部署控制器後,設定警示型復原:

    aws ecs update-service --cluster your-cluster-name --services your-service-name --deployment-configuration "alarms={alarmNames=[your-alarm-name],enable=true,rollback=true}"

如需詳細資訊,請參閱CloudWatch 警示如何偵測 Amazon ECS 部署失敗

Service Connect 與部署控制器不相符

下列問題和 Service Connect 與部署控制器不相符有關。

使用 Service Connect 的 EXTERNAL 控制器

錯誤訊息The EXTERNAL deployment controller type is not supported for services using Service Connect.

解決方案:嘗試搭配已啟用 Service Connect 的服務使用 EXTERNAL 部署控制器時,會發生此錯誤。EXTERNAL 控制器與 Service Connect 不相容。

  1. 檢查服務是否啟用了 Service Connect:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].serviceConnectConfiguration"
  2. 如果需要使用 EXTERNAL 部署控制器,請更新服務以停用 Service Connect:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --service-connect-configuration "{}"
  3. 或者,如果必須使用 Service Connect,請改用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

使用非 ECS 控制器的 Service Connect

錯誤訊息Service Connect feature is only supported with ECS (rolling update) deployment controller. Update to ECS deployment controller and try again.

解決方案:嘗試在未使用 ECS 部署控制器的服務上啟用 Service Connect 時,會發生此錯誤。Service Connect 功能僅與 ECS 部署控制器相容。

  1. 檢視服務目前的部署控制器:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].deploymentController"
  2. 更新服務以使用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS
  3. 服務使用 ECS 部署控制器後,即可啟用 Service Connect:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --service-connect-configuration "enabled=true,namespace=your-namespace"

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

控制器類型與排程策略不相符

下列問題和控制器類型與排程策略不相符有關。

使用 DAEMON 排程策略的 CODE_DEPLOY 控制器

錯誤訊息The CODE_DEPLOY deployment controller type is not supported for services using the DAEMON scheduling strategy.

解決方案:嘗試搭配使用了 DAEMON 排程策略的服務使用 CODE_DEPLOY 部署控制器時,會發生此錯誤。CODE_DEPLOY 控制器僅與 REPLICA 排程策略相容。

  1. 檢查服務目前的排程策略:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].schedulingStrategy"
  2. 如果需要使用藍/綠部署,請將服務變更為使用 REPLICA 排程策略:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --scheduling-strategy REPLICA
  3. 或者,如果必須使用 DAEMON 排程策略,請改用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

使用 DAEMON 排程策略的 EXTERNAL 控制器

錯誤訊息The EXTERNAL deployment controller type is not supported for services using the DAEMON scheduling strategy.

解決方案:嘗試搭配使用了 DAEMON 排程策略的 ECS 服務使用 EXTERNAL 部署控制器時,會發生此錯誤。EXTERNAL 控制器僅與 REPLICA 排程策略相容。

  1. 檢查服務目前的排程策略:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].schedulingStrategy"
  2. 如果需要使用 EXTERNAL 部署控制器,請將服務變更為使用 REPLICA 排程策略:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --scheduling-strategy REPLICA
  3. 或者,如果必須使用 DAEMON 排程策略,請改用 ECS 部署控制器:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --deployment-controller type=ECS

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

使用外部啟動類型的服務登錄檔

錯誤訊息Service registries are not supported for external launch type.

解決方案:嘗試為使用 EXTERNAL 啟動類型的服務設定服務探索 (服務登錄檔) 時,會發生此錯誤。服務探索與 EXTERNAL 啟動類型不相容。

  1. 檢查服務目前的啟動類型:

    aws ecs describe-services --cluster your-cluster-name --services your-service-name --query "services[0].launchType"
  2. 如果需要使用服務探索,請將服務變更為使用 EC2FARGATE 啟動類型:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --launch-type FARGATE
  3. 或者,如果必須使用 EXTERNAL 啟動類型,請移除服務登錄檔組態:

    aws ecs update-service --cluster your-cluster-name --service your-service-name --service-registries "[]"

如需詳細資訊,請參閱Amazon ECS 服務部署控制器與策略

還原部署控制器更新

如果決定要返回先前的部署控制器,可以執行下列其中一項動作:

  • 如果您使用 CloudFormation,則可以使用先前的範本來建立新的堆疊。如需詳細資訊,請參閱 CloudFormation User Guide 中的 Create a stack from

  • 如果您使用 Amazon ECS 主控台或 AWS CLI,則可以更新服務。如需詳細資訊,請參閱更新 Amazon ECS 服務

    如果您使用 update-service 命令,請使用 --deployment-controller 選項,並將其設定為先前的部署控制器。