AWS代码部署+ bitbucket =失败(错误代码HEALTH_CONSTRAINTS)

时间:2016-08-04 08:25:28

标签: amazon-web-services aws-code-deploy

我根据这篇文章设置了所有内容

https://aws.amazon.com/tw/blogs/apn/announcing-atlassian-bitbucket-support-for-aws-codedeploy/

这是我的环境:

实例(与amazon linux免费套餐)
   - 安装了apache 2.4

安全小组
   - 只有22(只有我的IP可以访问)和80端口打开

Iptables 停止了

设置了

2个角色 - 一个用于链接S3< - >到位桶   (附上自定义政策)
- 一个角色是部署组   (附带AWSCodeDeployRole政策)

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "codedeploy.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

尝试部署的脚本https://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Linux.zip

权限 / var / www / *由具有755权限的ec2-user拥有

代理 service codedeploy-agent status = AWS CodeDeploy代理作为PID 7200

运行

线索: 我的s3存储桶中有一些zip文件是为每次部署而上传的。

错误代码:HEALTH_CONSTRAINTS

任何人都知道部署失败的原因是什么?

update1 使用iam配置文件重新启动实例后,可以部署应用程序。但它仍然失败,当我点击查看事件时,有如下日志:

Error CodeScriptFailed
Script Namescripts/install_dependencies
MessageScript at specified location: scripts/install_dependencies run as user root failed with exit code 1
Log TailLifecycleEvent - BeforeInstall
Script - scripts/install_dependencies
[stdout]Loaded plugins: priorities, update-motd, upgrade-helper
[stdout]Resolving Dependencies
[stdout]--> Running transaction check
[stdout]---> Package httpd.x86_64 0:2.2.31-1.8.amzn1 will be installed
[stdout]--> Processing Dependency: httpd-tools = 2.2.31-1.8.amzn1 for package: httpd-2.2.31-1.8.amzn1.x86_64
[stdout]--> Processing Dependency: apr-util-ldap for package: httpd-2.2.31-1.8.amzn1.x86_64
[stdout]--> Running transaction check
[stdout]---> Package apr-util-ldap.x86_64 0:1.4.1-4.17.amzn1 will be installed
[stdout]---> Package httpd-tools.x86_64 0:2.2.31-1.8.amzn1 will be installed
[stdout]--> Processing Conflict: httpd24-2.4.23-1.66.amzn1.x86_64 conflicts httpd < 2.4.23
[stdout]--> Processing Conflict: httpd24-tools-2.4.23-1.66.amzn1.x86_64 conflicts httpd-tools < 2.4.23
[stdout]--> Finished Dependency Resolution
[stderr]Error: httpd24-tools conflicts with httpd-tools-2.2.31-1.8.amzn1.x86_64
[stderr]Error: httpd24 conflicts with httpd-2.2.31-1.8.amzn1.x86_64
[stdout] You could try using --skip-broken to work around the problem
[stdout] You could try running: rpm -Va --nofiles --nodigest

任何人有什么问题?

4 个答案:

答案 0 :(得分:5)

错误代码HEALTH_CONSTRAINTS表示失败的实例多于预期,这是由部署配置定义的。

有关部署失败原因的详细信息,请在部署控制台https://region.console.aws.amazon.com/codedeploy/home?region=region#/deployments上单击失败的deploymentID,然后它将重定向到部署详细信息页面,其中包含指定的所有实例部署,每行包含实例的生命周期事件。然后单击ViewEvents,如果有View Logs链接,则可以看到此实例部署失败的原因。

如果控制台没有足够的信息来满足您的需求,则可以在较少的/var/log/aws/codedeploy-agent/codedeploy-agent.log中找到该实例上的日志。它包含最近部署的日志。

答案 1 :(得分:1)

这是因为codeDeploy通过命中实例来检查ec2实例的运行状况。在部署之前,您需要在实例上运行以下bash脚本并检查脚本是否有效。必须启动httpd服务。重新启动实例。

import sys
import RPi.GPIO as GPIO
import os
from time import sleep
import urllib2

DEBUG = 1
# Setup the pins we are connect to

#CONNECT OUT PIN 
co2pin = 16

#Setup API and delay
myAPI = ""
myDelay = 16 #how many seconds between posting data

GPIO.setmode(GPIO.BCM)
GPIO.setup(co2pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)


def Cotime(co2pin):
    co = 0  
    if (GPIO.input(co2pin) == True):
    co += 1
    return (str(co))


if __name__ == '__main__':
    baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI
    print baseURL

    while True:
    try:
        co = Cotime(co2pin)
        f = urllib2.urlopen(baseURL +"&field3=%s" % (co))
        print f.read()
        print 'Value Detected' +str(co)
        f.close()
        sleep(int(myDelay))
    except:
        print 'exiting.'
        break

答案 2 :(得分:0)

这取决于您的部署配置,但基本上一个或多个部署失败。

  

HEALTH_CONSTRAINTS:部署失败的实例太多了   已在指定的实例运行状况约束中成功部署

     

http://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ErrorInformation.html

检查deployment configuration settings。部署的总体失败/成功基于这些设置。试试CodeDeployDefault.AllAtOnce,然后根据需要拨入。

另外,请仔细检查AWS CodeDeploy Instance Health设置,尤其是minimum-healthy-hosts

答案 3 :(得分:0)

您要求在appspec.yaml文件中安装的某个依赖项与httpd24-tools服务之间似乎存在冲突。

[stderr]Error: httpd24-tools conflicts with httpd-tools-2.2.31-1.8.amzn1.x86_64
[stderr]Error: httpd24 conflicts with httpd-2.2.31-1.8.amzn1.x86_64
[stdout] You could try using --skip-broken to work around the problem

因此,尝试解决依赖安装问题。您可以尝试在ec2上手动安装依赖项并找到解决此冲突的方法,当您解决它时,将解决方案带到appspec.yaml文件并通过代码部署安装依赖项。