Search code examples
amazon-web-servicesamazon-ec2amazon-elastic-beanstalkamazon-elb

Failed to deploy application: During an aborted deployment, some instances may have deployed the new application version


I can't deploy a new version on Elastic Beanstalk.

Everything was working fine until I tried to deploy a new version where I have lots of issues (It is not the first time I deploy a new version on this environment, I already have deployed dozens). When I manage to fixe all of them I got those errors:

  • Failed to deploy application.
  • During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
  • Unsuccessful command execution on instance id(s) 'i-...'. Aborting the operation

I redeploy the version which does not work.

Here is the Elastic Beanstalk console:

Elastic Beanstalk console

Elastic Beanstalk events

The request logs button from Elastic Beanstalk return nothing. The system log from EC2 instance shows the last working version logs.

I enable the CloudWatch logs from Configuration navigation pane. It added 4 files to CloudWatch logs:

  • /var/log/eb-activity.log -> empty so far
  • /var/log/httpd/access_log -> empty so far
  • /var/log/httpd/error_log -> empty so far
  • /environment-health.log -> Command is executing on all instances (56 minutes or more elapsed).", "Incorrect application version found on all instances. Expected version \"prod-v1.7.28-0\" (deployment 128).

It is an Amazon Linux, t2.medium instance with Apache as web server

What I already try:

  • Change the name of .zip each time to be different of other zip already deploy
  • Terminate the instance and the loadBalancer automatically create a new one
  • Reboot the instance
  • Rebuild Elastic Beanstalk environment
  • Deploy a simplest code

I tried to deploy just a zip with the code below but I got same errors.

<html>
  <head>
    <title>This is the title of the webpage!</title>
  </head>
  <body>
    <p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page, just like this <strong>p</strong> tag and its contents.</p>
  </body>
</html>

It always go back to last working version and when I tried to deploy the new version it does not work.

On some post I see some people telling it is maybe because the instance is too small but before it was working perfectly and the size does not change since then.

If you have some questions or ideas I will be very thankful. Have a nice day !

Answer: The issue was in the logs like you said. I had to ssh into my EC2 instance to reached them. The error was in the file cfn-init-cmd.log. One of the command was waiting for an input so it timed out with no error message.


Solution

  • You should check the logs of the EBS for any hints as to what goes wrong with your deployment. The AWS console can be helpful for that.

    enter image description here

    There are also the logs that can be acquired from EC2:

    enter image description here

    CloudWatch logs is another thing to check.

    enter image description here

    You should also check the autoscaling group, and see if there are any health checks there. What kind of checks are these? What's the grace period?

    Here's a list of reasons that an EC2 health check could fail. You could launch a better ec2 instance for troubleshooting.

    Instance status checks.

    The following are examples of problems that can cause instance status checks to fail:

    Failed system status checks

    Incorrect networking or startup configuration

    Exhausted memory

    Corrupted file system

    Incompatible kernel

    Also rebuilding is really a drastic step as it destroys and rebuilds all your resources. Your ELB DNS for example will be gone, any associated EIP will be released. These things can't be reclaimed.