When you launch an instance with RightScale Self Service, and the Chef cookbook execution fails, the instance goes into “stranded” mode. By default RightScale Self Service terminates the stranded instances, so there is no way to remote into them and read log files to find the cause of the problem.
To keep stranded instances running in RightScale
- Find the booting instance in Cloud Management and click the instance name,
- Click the lock icon on the top of the screen
RightScale Self Service cannot terminate locked instances. To terminate the instance after the troubleshooting process, unlock the instance and terminate the instance by hand.
When you need to upgrade an application on an AWS EC2 instance with minimum downtime, there are many options.
Upgrade an EC2 instance
- Stop the application, so users don’t make more changes,
- Create a backup of the database (snapshot of the RDS instance),
- Create a backup of the server (backup image of the EC2 instance),
- Upgrade the application on the server,
- Start the application,
- Test the new version of the application.
In case the upgrade fails, or the post-upgrade test fails
- Stop the application,
- If you use RightScale to launch servers:
- stop the RightLink service on the failed server to prevent RightScale auto terminating the restored server
(When RightScale finds a new identical server instance, it automatically shuts it down to avoid multiple instances with the same identifier.)
- Terminate the failed server
- Stop the failed server,
- Restore the database from the pre-upgrade backup with a new name,
- Restore the server instance from the pre-upgrade backup,
- Start the restored server,
- Change the database address in the application’s config file to point to the restored database,
- Start the application,
- Test the restored version of the application.
To make the backup image of the AWS EC2 instance
- Open the AWS console and navigate to EC2, Running instances
- Find the server instance you want to backup
- Right-click the row of the instance and select Image, Create Image
- Name the image and click the Create Image button
- Save the image Id from the popup
There are certain functions in RightScale scripts (RightScripts) that you cannot test without launching a new instance. To test your script:
- Edit the Head revision of the RightScale script and save it,
- Attach the Head revision of the RightScale script to the Head revision of the RightScale Server Template,
- In your Self Service CAT file reference revision 0 (zero) of the Server Template (Head revision),
( “server_template_revision” => “0”, )
- Upload the Self Service CAT file to Self Service, but do not publish it,
- Launch a server instance from Self Service using the RightScale Self-Service Designer page, not the Catalog.
If the script has some errors, modify the Head revision of the RightScale script and launch a new server instance using the RightScale Self-Service Designer page.
When the script works perfectly:
- Commit the RightScale script, creating a new RightScale script revision,
- Attach the committed revision of the RightScale script to the Server Template’s Head revision,
- Commit the Server Template, creating a new Server Template revision,
- Publish the new revision of the Server Template,
- Reference the new revision of the Server Template in your Self Service CAT file.
When you use RightScale to launch servers in the cloud, you want to use the same base image to test your Chef cookbooks in Test Kitchen.
Packer by Hashicorp is a utility to create custom server images based on cloud images. You supply the image ID and other configuration parameters to create a new custom image.
To find the AMI ID of the base image of the RightScale Server Template
- Open the RightScale user interface in your browser,
- Select the RightScale account where the server template was created,
- In RightScale Cloud Management select Design / ServerTemplates,
- Select the server template,
- Select Images,
- Select the MultiCloud image,
- Select Clouds,
- Select the image in the region you are working in,
- The Resource UID is the AMI ID of the image.