對 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 和部署控制器不相符有關。

EXTERNAL 具有 Service Connect 的 控制器

錯誤訊息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 服務部署控制器和策略

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

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

CODE_DEPLOY 具有DAEMON排程策略的 控制器

錯誤訊息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 服務部署控制器和策略

EXTERNAL 控制器搭配 DAEMON 排程策略

錯誤訊息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 服務部署控制器和策略

還原部署控制器更新

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

  • 如果您使用 AWS CloudFormation,則可以使用先前的範本來建立新的堆疊。如需詳細資訊,請參閱AWS CloudFormation 《 使用者指南》中的從 建立堆疊

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

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