سؤال

I have a PHP application deployed to Amazon Elastic Beanstalk. But I notice a problem that every time I push my code changes via git aws.push to the Elastic Beanstalk, the application deployed didn't picked up the changes. I checked the events log on my application Beanstalk environment and notice that every time the Beanstalk issues:

Deploying new version to instance(s)

it's always followed by:

The following instances have not responded in the allowed command timeout time (they might still finish eventually on their own): [i-d5xxxxx]

The same thing happens when I try to request snapshot logs. The Beanstalk issues:

requestEnvironmentInfo is starting

then after a few minutes it's again followed by:

The following instances have not responded in the allowed command timeout time (they might still finish eventually on their own): [i-d5xxxxx].

هل كانت مفيدة؟

المحلول

I had this problem a few times. It seems to affect only particular instances. So it can be solved by terminating the EC2 instance (done via the EC2 page on the Management Console). Thereafter, Elastic Beanstalk will detect that there are 0 healthy instances and automatically launch a new one.

If this is a production environment and you have only 1 instance and you want minimal down time

  1. configure minimum instances to 2, and Beanstalk will launch another instance for you.
  2. terminate the problematic instance via EC2 tab, Beanstalk will launch another instance for you because minimum instance is 2
  3. configure minimum instance back to 1, Beanstalk will remove one of your two instances.

نصائح أخرى

By default Elastic Beanstalk "throws a timeout exception" after 8 minutes (480 seconds defined in settings) if your commands did not complete in time. You can set an higher time up to 30 minutes (1800 seconds).

{
    "Namespace": "aws:elasticbeanstalk:command",
    "OptionName": "Timeout",
    "Value": "1800"
}

Read here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html

Had the same issue here (single t1.micro instance).

Did solve the problem by rebooting the EC2 instance via the EC2 page on the Management Console (and not from EB page).

Beanstalk deployment (and other features like Get Logs) work by sending SQS commands to instances. SQS client is deployed to instances and checks queue about every 20 secs (see /var/log/cfn-hup.log): 2018-05-30 10:42:38,605 [DEBUG] Receiving messages for queue https://sqs.us-east-2.amazonaws.com/124386531466/93b60687a33e19...

If SQS Client crashes or has network problems on t1/t2 instances then it will not be able to receive commands from Beanstalk, and deployment would time out. Rebooting instance restarts SQS Client, and it can receive commands again.

An easier way to fix SQS Client is to restart cfn-hup service:

sudo service cfn-hup restart

For me, the problem was my VPC security group rules. According to the docs, you need to allow outbound traffic on port 123 for NTP to work. I had the port closed, so the clock was drifting, and so the EC2's were becoming unresponsive to commands from the Elastic Beanstalk environment, taking forever to deploy (only to time out) failing to get logs, etc.

Thank you @Logan Pickup for the hint in your comment.

In the case of deployment, an alternative to shutting down the EC2 instances and waiting for Elastic Beanstalk to react, or messing about with minimum and maximum instances, is to simply perform a Rebuild environment on the target environment.

If a previous deployment failed due to timeout then the new version will still be registered against the environment, but due to the timeout it will not appear to be operational (in my experience the instance appears to still be running the old version).

Rebuilding the environment seems to reset things with the new version being used.

Obviously there's the downside with that of a period of downtime.

I think is the correct way to deal with this. I think the correct way to deal with this is to figure out the cause of the timeout by doing what this answer suggests.

chongzixin's answer is what needs to be done if you need this fixed ASAP before investigating the reason for a timeout.

However, if you do need to increase timeout, see the following:

Add configuration files to your source code in a folder named .ebextensions and deploy it in your application source bundle.

Example:

option_settings:
  "aws:elasticbeanstalk:command":
    Timeout: 2400

*"value" represents the length of time before timeout in seconds.

Reference: https://serverfault.com/a/747800/496353

"Restart App Server(s)" from the "Actions" menu in Elastic Beanstalk management dashboard followed by eb deploy fixes it for me.

Visual cue for the first instruction

After two days of checking random issues, I restarted both EC2 instances one after another to make sure there is no downtime. Site worked fine but after a while, website started throwing error 504.

When I checked the http server, nginx was off and "Out of HDD space" was thrown. "Increased the HDD size", elastic beanstalk created new instances and the issue was fixed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top