I attempted to deploy my Rails app to AWS OpsWorks and get the following error:
[2016-01-01T08:39:36+00:00] ERROR: Running exception handlers
[2016-01-01T08:39:36+00:00] ERROR: Exception handlers complete
[2016-01-01T08:39:36+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2016-01-01T08:39:36+00:00] ERROR: deploy[/srv/www/myapp] (deploy::rails line 65) had an error: Chef::Exceptions::Exec: if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi returned 1, expected 0
[2016-01-01T08:39:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
OpsWorks doesn’t give the best logging from the AWS Console. All we know from this is that the deployment failed on the following line:
if [ -f Gemfile ]; then echo 'OpsWorks: Gemfile found - running migration with bundle exec' && /usr/local/bin/bundle exec /usr/local/bin/rake db:migrate; else echo 'OpsWorks: no Gemfile - running plain migrations' && /usr/local/bin/rake db:migrate; fi
This means that it failed during a migration, but several possible issues could have caused that call to fail. As John C. Bland suggests, the best option to SSH into the EC2 instance and get the stacktrace.
AWS Elastic Beanstalk simplifies application management, with server scaling out-of-the-box. Scaling is pretty idiot-proof. In fact, if you try to scale down to zero instances, you get the following:
MaxBatchSize: Invalid option value: '0' (Namespace: 'aws:autoscaling:updatepolicy:rollingupdate', OptionName: 'MaxBatchSize'): Value is less than minimum allowed value: 1
A few weeks ago, I was asked to scale an environment down to determine if there was any adverse effect in terminating it. Basically, we would scale down to zero and see if anyone missed it being alive. In order to do this, we had to go around Elastic Beanstalk and using the Auto Scaling Group:
In the AWS Console, go to Compute -> EC2
In EC2 Dashboard, go to AUTO SCALING -> Auto Scaling Groups
Use the Filter text box to find the auto scaling group for my environment. Typing in the environment name (e.g. stag-rails-app-s1) should work.
Docker has become very popular in the last few years. At work, we've been using it for over a year now. As we develop, images for our apps are becoming very large. This is becoming an issue because building, pulling and pushing these images are taking longer and longer. Furthermore, our deployment process has been intermittently failing when doing docker push to Docker Hub; this happens particularly often when upstream internet is slow. Our team tried a handful of different techniques to shrink our image sizes.
This week, I'll go over the different techniques to shrink Docker images. We'll look at the advantages and disadvantages. Depending on your engineering organization and architecture, some will worker better than others.