6

I'm deploying a docker image from Github to AWS elastic beanstalk using travis. That part goes OK, the actual deployment exits with 0 and there is a .zip file in the S3 bucket.

The issue is that, since this is my first time using AWS I created the app using the Sample Application since the code is deployed from Github, and after the deployment I get the health status as degraded (red exclamation sign) with this message:

ERROR
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.

If I go to Causes I find this:

  • Application deployment failed at 2020-05-01T16:01:58Z with exit status 1 and error: Engine execution has encountered an error.
  • Incorrect application version "travis-e55e05342a8cc16f3f28f8e184735667a9531ffa-1588311901" (deployment 4). Expected version "Sample Application" (deployment 1).

I even deleted the sample application and re-deployed the one that was uploaded and got that particular error. As you can see in the last message I've deployed this 3 times already, getting the same result.

Finally I downloaded the zip file from the S3 bucket and I found inside basically the src and public folders along with all the files in the root folder such as package.json, .gitignore all the docker files, etc.


EDIT

I created two separate repos in github to test this. The first repo is a static page in a Docker container, quite simple. I create an environment in EB and start everything with the sample app. Then I push the changes to github, travis does it's thing and deploys the app to AWS. This works fine and the app's env is updated with no errors. This is the repo: https://github.com/rhernandog/docler-static-page-aws

The second repo is a simple react app. Same procedure, create the environment in EB with the sample app. Push the code to github, travis does it's thing and deploys to AWS. This fails and I keep getting the same error:

Environment health has transitioned from Info to Degraded. Command failed on all
instances. Incorrect application version found on all instances. Expected version
"Sample Application" (deployment 1). Application update failed 1 second ago and
took 2 minutes.

This is the repo for the react app: https://github.com/rhernandog/react-docker-awseb

In terms of Docker, everything works fine in my local machine.


EDIT 2

Based on @stefansundin suggestion I re-deployed the app to EB and check the logs. I ended looking at the full logs for more information and found this: /var/log/cfn-hup.log

2020-05-14 17:07:42,605 [WARNING] Action for aws-eb-command-handler exited with 1, returning FAILURE

The only place where I found an error was in the engine log file: /var/log/eb-engine.log

2020/05/14 17:07:42.514601 [INFO] Executing instruction: Docker Specific Build Application
2020/05/14 17:07:42.514605 [INFO] start build docker app
2020/05/14 17:07:42.514615 [INFO] fetch image name
2020/05/14 17:07:42.514639 [INFO] authenticate with ECR if the image is in an ECR repo
2020/05/14 17:07:42.514644 [INFO] pull docker image if update is not false in dockerrun.aws.json
2020/05/14 17:07:42.514657 [INFO] Running command /bin/sh -c docker pull node:12-alpine AS builder
2020/05/14 17:07:42.558923 [ERROR] "docker pull" requires exactly 1 argument.

So basically this is complaining about this in the dockerfile: FROM node:12-alpine AS builder. You can see the whole file in the repo: https://github.com/rhernandog/react-docker-awseb/blob/master/Dockerfile

The point is: Why this doesn't happen in my local machine? And how can I actually get the files from the build command and copy them to the nginx folder?

That is actually the only error I found in the log files.

Rodrigo
  • 1,638
  • 1
  • 15
  • 27
  • Hi, Can you confirm you are able to run this on docker locally? – Chris Williams May 10 '20 at 07:23
  • Yep, everything works fine locally, both the production build and the dev build using docker compose. In the case of the dev build it even works with the hot reload. I'm on windows but I installed docker using Linux containers. I even changed the Git config to use only LF instead of CRLF in the line end sequence. – Rodrigo May 10 '20 at 15:48

5 Answers5

2

I also got a similar error in my node app:

Incorrect application version "travis-e55e05342a8cc16f3f28f8e184735667a9531ffa-1588311901" (deployment 4). Expected version "Sample Application" (deployment 1)

What turned out to be an issue with my building and deployment scripts were corrected (debugged in Jenkins) the application successfully deploys in beanstalk with no error.

Turns out the issue was not with Beanstalk or app version but with the build mechanism. Something to look into when nothing else works :)

Ajeet Shah
  • 18,551
  • 8
  • 57
  • 87
  • Yes, the best course of action seems to be to check your EB logs first. In my case, I had the wrong Docker image name in the deployment artifact file. – Paul Mar 04 '22 at 03:18
1

I had the same issue for java app in docker container.

I tried all the recommendations from this topic, links from this topic and nothing helped.

In the end, the following action helped:

  1. Enable enhanced health panel https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-enable.html#health-enhanced-enable-console

  2. Go to the extended panel of the desired environment

  3. Select the instance that crashed due to this "version" issue and click reboot

enter image description here

Additionally:

  • In one of the cases, I had to delete all previous versions (section on the left panel) and push a new one and only after that make the above recommendations.
  • Also make sure you have sufficient rights to deploy (codepipeline/deployment)
S.Daineko
  • 1,790
  • 1
  • 20
  • 29
0

AWS Docs say that

To solve this issue, start another deployment. You can redeploy a previous version that you know works, or configure your environment to ignore health checks during deployment and redeploy the new version to force the deployment to complete.

You can also identify and terminate the instances that are running the wrong application version. Elastic Beanstalk will launch instances with the correct version to replace any instances that you terminate. Use the EB CLI health command to identify instances that are running the wrong application version.

Can you try to delete the instances that runs your applications and start a fresh install?

Also, you can use CodePipeline to deploy your codes to Elastic Beanstalk, you can use your S3 folder for the source stage and skip the build process if your code is build on travis and deploy using the deploy stage to install your new app to your Elastic Beanstalk. There might be some misconfiguration while installing the new app to your environment.

I suggest you to terminate your instances and start new instances sorry if I got your question wrong.

Community
  • 1
  • 1
  • 1
    I've done that process quite a few times, with the react app in the repo and another one made with create react app, getting always the same result. With the simple static pages served with nginx there is no problem though, that's why I posted the repos. I haven't used CodePipeline, since I'm just starting with AWS and Docker I'm more familiar with Travis. – Rodrigo May 14 '20 at 05:56
0

I haven't used Docker on Elastic Beanstalk. When my Ruby on Elastic Beanstalk deployments fail, I find that I usually find the problem if I request the 100 last lines from the logs. If you navigate to "Logs" -> "Request Logs" -> "Last 100 Lines", that may help you.

If that fails, I SSH in to the instance and look in the logs in /var/log. Maybe docker ps and docker logs may help you.

stefansundin
  • 2,826
  • 1
  • 20
  • 28
  • I wasn't able to find anything related to the error in the last 100 lines of the logs, since this was over a week ago. I got the full logs but is hard to tell what exactly I'm looking at here. Since I removed the conflicting app version and set back to the sample one I'll re-deploy and get the las 100 lines logs. – Rodrigo May 14 '20 at 05:53
  • I added another edit to the original question with the logs from a recent re-deploy. Let me know if you need more info. – Rodrigo May 14 '20 at 17:40
  • Can you try adding a `Dockerrun.aws.json` file as suggested [in this documentation](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/single-container-docker-configuration.html)? I suspect that they are auto-generating one for you if it is missing, and it is trying to read from your `Dockerfile` but is messing it up. Maybe you can try downloading the application version zip file to see if there is one in there. I suspect the `Image.Name` attribute is wrong. – stefansundin May 16 '20 at 20:25
0

While creating a new webserver environment on platform branch select "Docker running on 64bit Amazon Linux" it will work.