【问题标题】:Code deploy reports: "Deployment Failed: No hosts succeeded", while deploying from S3 .zip revision to EC2 instance代码部署报告:“部署失败:没有主机成功”,同时从 S3 .zip 修订版部署到 EC2 实例
【发布时间】:2016-03-16 14:57:37
【问题描述】:

我正在尝试使用托管在单独 EC2 实例中的 Jenkins 创建从 Bitbucket 到 aws EC2 实例的自动化 CI 工作流。

我创建并配置了所需的一切(IAM 角色、aws 客户端和代码部署代理),如下文所述:
https://pranavpshah.wordpress.com/configure-aws-codedeploy/

顺便说一句,所有实例都基于 ubuntu 并在私有 VPC 中运行,我正在部署一个 node.js 应用程序。

例如,每次我推送到 Bitbucket 存储库时,我都可以在 S3 存储桶中成功创建一个 .zip 版本。但在代码部署仪表板中,我得到“部署失败没有主机成功”。错误信息。

每次我启动该过程时,“进行中”状态都需要 5 分钟以上。

当部署过程以失败状态完成时,我检查了 /var/log/aws/codedeploy-agent/codedeploy-agent.log 文件,这是我得到的:

2015-12-04 17:17:36 INFO  [codedeploy-agent(28199)]: Stopping master 27971
2015-12-04 17:17:36 INFO  [codedeploy-agent(27971)]: master 27971: Received TERM - stopping children and shutting down
2015-12-04 17:17:36 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: Received TERM - setting internal shutting down flag and possibly finishing last run
2015-12-04 17:17:55 INFO  [codedeploy-agent(27975)]: [Aws::CodeDeployCommand::Client 200 60.113784 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

2015-12-04 17:17:56 INFO  [codedeploy-agent(27975)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 27971: shutting down
2015-12-04 17:17:57 INFO  [codedeploy-agent(28219)]: master 28219: Spawned child 1/1
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registering Plugins: ["codedeploy"].
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Loading plugin codedeploy from /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/register_plugin
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: Registered Plugins: #<Set: {InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller}>.
2015-12-04 17:17:57 INFO  [codedeploy-agent(28223)]: On Premises config file does not exist or not readable
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Configuring deploy control client: Region = "us-west-2"
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Deploy control endpoint override = nil
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Initializing Host Agent: Host Identifier = arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Validating CodeDeploy Plugin Configuration
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControlCertVerifier: Actual certificate subject is '/C=US/ST=Washington/L=Seattle/O=Amazon.com, Inc./CN=codedeploy-commands.us-west-2.amazonaws.com'
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: CodeDeploy Plugin Configuration is valid
2015-12-04 17:17:57 DEBUG [codedeploy-agent(28223)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Calling PollHostCommand:
2015-12-04 17:17:58 INFO  [codedeploy-agent(28219)]: Started master 28219 with 1 children
2015-12-04 17:18:58 INFO  [codedeploy-agent(28223)]: [Aws::CodeDeployCommand::Client 200 60.534255 0 retries] poll_host_command(host_identifier:"arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed")  

我是否在配置中遗漏了什么?
请问有什么帮助吗?

【问题讨论】:

    标签: deployment jenkins amazon-s3 amazon-ec2 aws-code-deploy


    【解决方案1】:
    1. 我刚刚检查了部署 ID“d-FEPBDKJMC”的详细信息,似乎实例 ID 是“arn:aws:ec2:us-west-2:219450671821:instance/i-d796060e”而不是“arn:aws:ec2:us-west-2:219450671821:instance/i-348913ed”在您粘贴的主机代理日志中。所以可能应该检查正确实例上的日志。

    2. 部署时跳过了所有生命周期事件,我怀疑主机代理根本没有拉取命令。由于您提到该实例在 VPC 下,请确保 Codedeploy 和 S3 端点已列入白名单(我们需要连接到这些端点进行部署)。这里还有一个关于 Codedeploy 与 VPC 合作的文档,请点击安全性:https://aws.amazon.com/codedeploy/faqs/

    【讨论】:

      【解决方案2】:

      您确定实例具有访问 S3 的角色吗?我错过了这一点,并且没有附加到我的实例的角色来访问 S3。

      http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-iam-instance-profile.html#getting-started-create-ec2-role-console

      【讨论】:

        猜你喜欢
        • 2016-02-11
        • 2016-07-10
        • 2018-05-22
        • 2016-09-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-14
        相关资源
        最近更新 更多