Print
카테고리: [ Amazon Web Services ]
조회수: 5681

 

 간혹 CodeDeploy를 하다보면 EC2에 접근도 못하고 HEALTH_CONSTRAINTS로 자꾸 실패할 때가 있다.

 이런 경우, 진짜 행복한 이유는 EC2가 진짜 Status가 Stop이거나 hang걸렸을 때 이다.

 하지만 이 경우보다 다른 경우에 더 많이 발생한다.

 다음의 두가지가 주된 이유다.

 

 1. yaml 파일 작성이 잘못 됨. => 이럴 경우는 EC2에 Deploy 파일이 올라갈 수도 있다. 그리고 이 Error로는 잘 안 나타난다.

 2. 가장 근본적인 원인. CodeDeploy Agent와의 통신 실패.

  이럴 경우 /var/..../codedeploy-agent/... 에서 codedeploy-agent.log를 보면 실패의 근본적인 원인이 나온다.

  가장 큰 경우는 agent가 설치가 되지 않았거나 start가 안된 상태이다. 이 경우는 aws cli나 ps -ef로 확인이 가능하기에 넘어가자.

 오늘 가져온 예시는 codedeploy agent가 InvalidSignatureException 을 떨어트릴 때이다.

 말 그대로 자격증명 실패가 된 것이며, 만료기간이나 시간의 문제가 크다.

 다음의 예를 보자. 실제 codedeploy-agent.log에 찍히는 것이다.

INFO  [codedeploy-agent(xxxx)]: [Aws::CodeDeployCommand::Client 400 0.0zzzzz 0 retries] poll_host_command(host_identifier:"ARN....") Aws::CodeDeployCommand::Errors::InvalidSignatureException Signature not yet current: 2018xxxxxxxxxxx is still later than 2018yyyyyyyyyyyyyy (2018yyyyyyyyyyy + 5 min.) 

ERROR [codedeploy-agent(xxxx)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Cannot reach InstanceService: Aws::CodeDeployCommand::Errors::InvalidSignatureException - Signature not yet current: 2018xxxxxxxxx is still later than 2018yyyyyyyyyyyy (2018yyyyyyyyyyyy+ 5 min.)

원인이 보이는가?

agent의 시간이 Console쪽보다 5분이 빠르다는 것이다.

EC2 시간만 맞춰주면 해결된다. EC2가 왜 AWS NPT와 시간 동기화를 못했는지 확인해보면 된다.