High Availability for Compute Instances
Configure High Availability for Compute Instances
Abstract
Chapter 1. Overview
This guide describes how to implement Instance High Availability (Instance HA). Instance HA allows Red Hat OpenStack Platform to automatically evacuate and re-spawn instances on a different Compute node when their host Compute node fails.
The evacuation process that is triggered by Instance HA is similar to what users can do manually, as described in Evacuate Instances.
Instance HA works on shared storage or local storage environments, which means that evacuated instances maintain the same network configuration (static IP, floating IP, and so on) and the same characteristics inside the new host, even if they are spawned from scratch.
Instance HA is managed by the following resource agents:
| Agent name | Name inside cluster | Role |
|---|---|---|
|
|
| Marks a Compute node for evacuation when the node becomes unavailable. |
|
|
| Evacuates instances from failed nodes. This agent runs on one of the Controller nodes. |
|
|
| Releases a fenced node and enables the node to run instances again. |
This guide describe how to use the Ansible automation framework to enable Instance HA. For more information about Ansible, see Ansible Documentation.
For a high-level description of how Instance HA detects and evacuates instances from failed hosts, see Chapter 2, How Instance HA Works.
Chapter 2. How Instance HA Works
OpenStack uses Instance HA to automate the process of evacuating instances from a Compute node when that node fails. The following procedure describes the sequence of events that are triggered when a Compute node fails.
-
At the time of failure, the
IPMIagent performs first-layer fencing and physically resets the node to ensure that it is powered off. Evacuating instances from online Compute nodes might result in data corruption or in multiple identical instances running on the overcloud. When the node is powered off, it is considered fenced. After the physical IPMI fencing, the
fence-novaagent performs second-layer fencing and marks the fenced node with the“evacuate=yes”cluster per-node attribute. To do this, the agent runs the following command:$ attrd_updater -n evacuate -A name="evacuate" host="FAILEDHOST" value="yes"Where FAILEDHOST is the hostname of the failed Compute node.
NoteBy default, all instances are to be evacuated, but it is also possible to tag images or flavors for evacuation.
To tag an image:
$ openstack image set --tag evacuable ID-OF-THE-IMAGETo tag a flavor:
$ nova flavor-key ID-OF-THE-FLAVOR set evacuable=true-
The
nova-evacuateagent continually runs in the background, periodically checking the cluster for nodes with the“evacuate=yes”attribute. Whennova-evacuatedetects that the fenced node contains this attribute, the agent starts evacuating the node using the process described in Evacuate Instances. -
While the failed node is booting up from the IPMI reset, the
nova-computeprocess on that node will start automatically. Because the node was fenced earlier, it will not be able to run any new instance until Pacemaker unfences it. -
When Pacemaker sees that the Compute node is online again, it tries to start the
compute-unfence-triggerresource on the node, reverting the force-down API call and setting the node as enabled again.
Chapter 3. Environment Prerequisites and Limitations
When Instance HA is enabled, you cannot perform overcloud upgrade or scale-up operations. Any attempts to do this will fail. This limitation applies to minor and major upgrades. Before upgrading or scaling your overcloud, you must disable Instance HA first. For instructions, see Chapter 6, Disabling Instance HA.
To enable Instance HA, your Red Hat OpenStack Platform overcloud must meet the following requirements:
- The environment is deployed by Red Hat OpenStack Platform director. See Director Installation and Usage for details.
- Fencing is already manually enabled on the control plane.
The following package versions are installed on all nodes:
-
fence-agents-4.0.11-86.el7.x86_64(or later) -
pacemaker-1.1.18-11.el7.x86_64(or later) -
resource-agents-3.9.5-124.el7.x86_64(or later)
-
- The environment can tolerate a full outage of the Compute and the Control planes.
- Shared storage is enabled in the environment for ephemeral and block storage. See Section 3.1, “Considerations for Shared Storage” for considerations.
The Message Broker (AMQP) recognizes the hostname of each Compute node as valid. To check the hostname of a Compute node, run the following command:
heat-admin@compute-n $ sudo crudini --get /etc/nova/nova.conf DEFAULT host-
Each Compute node can reach the endpoint that is set in the
$OS_AUTH_URLenvironment variable. The
$OS_AUTH_URLenvironment variable must be set to one of the following destinations:- The authentication services of the overcloud (which requires access to the external network), or
- The internal authentication URL
Chapter 4. Deploying Instance HA
The following sections describe how to use the Ansible automation framework to enable Instance HA. For more information about Ansible, see Ansible Documentation.
4.1. Creating the Required Ansible Configuration Files
Before you enable Instance HA through Ansible, you need to create an inventory file and an SSH arguments file. These files pass the Ansible variables that you will need to prepare the undercloud for Instance HA, as described in Section 4.2, “Preparing the Undercloud”.
Inventory File
The inventory file lists the different target hosts for the ansible playbooks. It is divided into two sections:
List of all nodes by name, along with the hostname, username, and private key file that Ansible should use for each playbook command. For example:
overcloud-controller-0 ansible_host=overcloud-controller-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa
-
List of headings that represent node types, where each type lists the nodes that belong to it. The node types are
compute,undercloud,overcloud, orcontroller.
The following procedure describes how to set up the inventory file.
Generate a complete inventory of all nodes in the undercloud and the overcloud with the following command:
stack@director $ tripleo-ansible-inventory --listThis command generates a detailed and updated inventory in JSON format. For more information, see Running Ansible Automation.
Create the inventory file with the name hosts in /home/stack/. The following example shows the required format to use when creating the file:
undercloud ansible_host=undercloud ansible_user=stack ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-compute-1 ansible_host=overcloud-compute-1 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-compute-0 ansible_host=overcloud-compute-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-2 ansible_host=overcloud-controller-2 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-1 ansible_host=overcloud-controller-1 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-0 ansible_host=overcloud-controller-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa [compute] overcloud-compute-1 overcloud-compute-0 [undercloud] undercloud [overcloud] overcloud-compute-1 overcloud-compute-0 overcloud-controller-2 overcloud-controller-1 overcloud-controller-0 [controller] overcloud-controller-2 overcloud-controller-1 overcloud-controller-0
SSH Arguments File
The SSH arguments file passes the necessary credentials and authentication settings that are needed by Ansible to run the playbooks on each target host.
Create the SSH arguments file from /home/stack with the following commands:
stack@director $ cat /home/stack/.ssh/id_rsa.pub >> /home/stack/.ssh/authorized_keys stack@director $ echo -e "Host undercloud\n Hostname 127.0.0.1\n IdentityFile /home/stack/.ssh/id_rsa\n User stack\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n" > ssh.config.ansible stack@director $ source /home/stack/stackrc stack@director $ openstack server list -c Name -c Networks | awk /ctlplane/ {print $2, $4} | sed s/ctlplane=//g | while read node; do node_name=$(echo $node | cut -f 1 -d " "); node_ip=$(echo $node | cut -f 2 -d " "); echo -e "Host $node_name\n Hostname $node_ip\n IdentityFile /home/stack/.ssh/id_rsa\n User heat-admin\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n"; done >> ssh.config.ansible
These commands create an SSH arguments file named ssh.config.ansible, which contains host-specific connection options for each overcloud node. For example:
Host overcloud-controller-0
Hostname 192.168.24.11
IdentityFile /home/stack/.ssh/id_rsa
User heat-admin
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null4.2. Preparing the Undercloud
After you create the inventory file and SSH arguments file, as described in Section 4.1, “Creating the Required Ansible Configuration Files”, you can prepare the undercloud for Instance HA.
-
Log in to the undercloud as the
stackuser. Clone the upstream
tripleo-ha-utilsgit repository.stack@director $ git clone git://github.com/openstack/tripleo-ha-utilsThis repository contains the playbooks, roles, and other utilities necessary to enable and test Instance HA with Ansible.
Create the /home/stack/ansible.cfg file with the following content:
[defaults] roles_path = /home/stack/tripleo-ha-utils/roles
Export the ansible.cfg file, the inventory file, and the SSH arguments file to the following environment variables:
stack@director $ export ANSIBLE_CONFIG="/home/stack/ansible.cfg" stack@director $ export ANSIBLE_INVENTORY="/home/stack/hosts" stack@director $ export ANSIBLE_SSH_ARGS="-F /home/stack/ssh.config.ansible"
- Make sure that the node definition template of the overcloud is located in /home/stack/. By default, the template file is named instackenv.json. For more information about the node definition template, see Registering Nodes for the Overcloud.
4.3. Enabling Instance HA
After you prepare the undercloud you can run the Ansible playbooks that you downloaded and extracted, as described in Section 4.2, “Preparing the Undercloud”. These playbooks allow you to enable Instance HA with or without configuring STONITH for the Controller and Compute nodes. For more information about STONITH, see Fencing the Controller Nodes.
- Enabling Instance HA with STONITH
To enable Instance HA and configure STONITH for both Controller and Compute nodes, run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12"By default, the playbook installs the
instance-hasolution with shared storage enabled. If your overcloud does not use shared storage, run the command with theinstance_ha_shared_storage=falseoption:stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e instance_ha_shared_storage=falseNoteSee Section 3.1, “Considerations for Shared Storage” for more information about shared storage in Instance HA.
- Enabling Instance HA without STONITH
To enable Instance HA without configuring STONITH for the Controller and Compute nodes, run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e stonith_devices="none"- Enabling Instance HA with STONITH only on the Compute nodes
To enable Instance HA and configure STONITH only on the Compute nodes (for example, if STONITH is already configured on the Controller nodes), run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e stonith_devices="computes"
Chapter 5. Testing Evacuation with Instance HA
The following procedure involves deliberately crashing a Compute node. Doing this forces the automated evacuation of instances through Instance HA.
Boot one or more instances on the overcloud before crashing the Compute node that hosts the instances to test.
stack@director $ . overcloudrc stack@director $ nova boot --image cirros --flavor 2 test-failover stack@director $ nova list --fields name,status,host
Log in to the Compute node that hosts the instances, using the
compute-nformat.stack@director $ . stackrc stack@director $ ssh -l heat-admin compute-n heat-admin@compute-n $
Crash the Compute node.
heat-admin@compute-n $ echo c > /proc/sysrq-triggerWait a few minutes and then verify that these instances re-spawned on another Compute nodes.
stack@director $ nova list --fields name,status,host stack@director $ nova service-list
Chapter 6. Disabling Instance HA
When Instance HA is enabled, upgrade or scale-up operations are not possible. Any attempts to do this will fail. This limitation applies to minor and major upgrades. Before upgrading or scaling your overcloud, you must disable Instance HA first.
To disable Instance HA, run the following command as the stack user on the undercloud:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \
-e release="rhos-12" -e instance_ha_action="uninstall"
If you used the stonith_devices option when you enabled Instance HA, you need to specify this option when you disable Instance HA. For example, if your Instance HA configuration excludes STONITH devices, use the following command syntax:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \
-e release="rhos-12" -e instance_ha_action="uninstall" -e stonith_devices="none"Appendix A. Step-by-Step Ansible Playbook for Configuring Instance HA
The Ansible-based solution that is described in this guide provides an automated and supported way to configure Instance HA. For reference, this appendix describes the steps that are automated by the playbook.
Create an authentication key on the director node to use with the
pacemaker-remoteservice.stack@director # dd if=/dev/urandom of=~/authkey bs=4096 count=1Copy the authentication key to the Compute and Controller nodes:
stack@director # scp authkey heat-admin@node-n:~/ stack@director # ssh heat-admin@node-n:~/ heat-admin@node-n $ sudo mkdir -p --mode=0750 /etc/pacemaker heat-admin@node-n $ sudo chgrp haclient /etc/pacemaker heat-admin@node-n $ sudo mv authkey /etc/pacemaker/ heat-admin@node-n $ sudo chown root:haclient /etc/pacemaker/authkey
On each Compute node, enable the
pacemaker-remoteservice and configure the firewall.heat-admin@compute-n $ sudo systemctl enable pacemaker_remote heat-admin@compute-n $ sudo systemctl start pacemaker_remote heat-admin@compute-n $ sudo iptables -I INPUT 11 -p tcp --dport 3121 -j ACCEPT ; /sbin/service iptables save
Confirm that the required versions of the
pacemaker(1.1.18-11.el7.x86_64) andresource-agents(3.9.5-124.el7.x86_64) packages are installed on the Controller and Compute nodes.heat-admin@controller-n $ sudo rpm -qa | egrep '(pacemaker|resource-agents)'Create a
NovaEvacuateactive/passive resource with the overcloudrc.v3 file, which provides theauth_url,username,tenantandpasswordvalues.stack@director # scp overcloudrc.v3 heat-admin@controller-1:~/ heat-admin@controller-1 $ . ~/overcloudrc.v3 heat-admin@controller-1 $ sudo pcs resource create nova-evacuate ocf:openstack:NovaEvacuate auth_url=$OS_AUTH_URL username=$OS_USERNAME password=$OS_PASSWORD tenant_name=$OS_TENANT_NAME project_domain=$OS_PROJECT_DOMAIN_NAME user_domain=$OS_USER_DOMAIN_NAME
NoteIf you are not using shared storage, include the
no_shared_storage=1option. See Section 3.1, “Considerations for Shared Storage” for more information.ImportantAs mentioned in Chapter 3, Environment Prerequisites and Limitations, the
$OS_AUTH_URLdestination must be the accessible to each Compute node. This environment variable should be set to either the overcloud’s authentication service or the internal authentication URL.Make sure that
nova-evacuateruns only on non-Compute nodes.heat-admin@controller-1 $ pcs constraint location nova-evacuate rule resource-discovery=never score=-INFINITY osprole eq computeConfirm that
nova-evacuateis started after the floating IP resources, OpenStack Image Service (glance), OpenStack Networking (neutron), and Compute (nova) services.heat-admin@controller-1 $ for i in $(sudo pcs status | grep IP | awk '{ print $1 }\'); do sudo pcs constraint order start $i then nova-evacuate ; doneCreate a list of the current controllers from the
cibadmindata.heat-admin@controller-1 $ controllers=$(sudo cibadmin -Q -o nodes | grep uname | sed s/.\*uname..// | awk -F\" '{print $1}') heat-admin@controller-1 $ echo $controllers
Use the list you created in the previous step to tag these nodes as controllers with the
osprole=controllerproperty.heat-admin@controller-1 $ for controller in ${controllers}; do sudo pcs property set --node ${controller} osprole=controller ; done heat-admin@controller-1 $ sudo pcs property
The newly assigned roles should appear in the
Node attributessection.Create a list of STONITH devices that are already present in the environment.
heat-admin@controller-1 $ STONITHdevs=$(sudo pcs stonith | awk '{print $1}') heat-admin@controller-1 $ echo $stonithdevs
Tag the control plane services to make sure they only run on listed Controller nodes and skip any listed STONITH devices.
heat-admin@controller-1 $ for i in $(sudo cibadmin -Q --xpath //primitive --node-path | tr ' ' '\n' | awk -F "id='" '{print $2}' | awk -F "'" '{print $1}' | uniq); do found=0 if [ -n "$stonithdevs" ]; then for x in $stonithdevs; do if [ $x = $i ]; then found=1 fi done fi if [ $found = 0 ]; then sudo pcs constraint location $i rule resource-discovery=exclusive score=0 osprole eq controller fi doneSet the
requiresproperty tofencingas the default for all resources. This operation is required to enable theunfencemechanism.heat-admin@controller-1 $ sudo pcs resource defaults requires=fencingCreate a separate
fence-novaSTONITH device.heat-admin@controller-1 $ . overcloudrc.v3 heat-admin@controller-1 $ sudo pcs stonith create fence-nova fence_compute \ auth-url=$OS_AUTH_URL \ login=$OS_USERNAME \ passwd=$OS_PASSWORD \ tenant-name=$OS_TENANT_NAME \ domain=localdomain record-only=1 \ meta provides=unfencing \ --force
Note-
This command assumes that you are using the default cloud domain name localdomain. If you are using a custom cloud domain name, set it as the value of the
domain=parameter. -
If you are not using shared storage, include the
no_shared_storage=1option. See Section 3.1, “Considerations for Shared Storage” for more information.
-
This command assumes that you are using the default cloud domain name localdomain. If you are using a custom cloud domain name, set it as the value of the
Create a pacemaker constraint for
fence-novato restrict the service to Controller nodes and setresource-discoverytonever.heat-admin@controller-1 $ pcs constraint location fence-nova rule resource-discovery=never score=0 osprole eq controllerAdd a STONITH device on each Compute nodes. This command should be run separately on each Compute node.
heat-admin@controller-1 $ sudo pcs stonith create ipmilan-overcloud-compute-N fence_ipmilan pcmk_host_list=overcloud-compute-N ipaddr=IPADDR login=IPMILANUSER passwd=IPMILANPW lanplus=1 cipher=1 op monitor interval=60s;
Where:
-
N. Identifying number of each compute node. For example,
ipmilan-overcloud-compute-1,ipmilan-overcloud-compute-2, and so on. - IPADDR. IP address of the IPMI interface.
- IPMILANUSER. User name of the IPMI device.
- IPMILANPW. Password of the IPMI device.
-
N. Identifying number of each compute node. For example,
Make sure that the Compute nodes can recover after fencing.
heat-admin@controller-1 $ sudo pcs property set cluster-recheck-interval=1minCreate a pacemaker remote resource for each Compute node and set
osproletocompute.heat-admin@controller-1 $ sudo pcs resource create overcloud-compute-n ocf:pacemaker:remote reconnect_interval=240 op monitor interval=20" heat-admin@controller-1 $ sudo pcs property set --node overcloud-compute-n osprole=compute"
Create Compute node resources and set the STONITH
level 1to include the physical fence device of the nodes and thefence-novaservice. Run this command separately on each Compute node.heat-admin@controller-1 $ sudo pcs resource create overcloud-compute-N ocf:pacemaker:remote reconnect_interval=60 op monitor interval=20 heat-admin@controller-1 $ sudo pcs property set --node overcloud-compute-N osprole=compute heat-admin@controller-1 $ sudo pcs stonith level add 1 overcloud-compute-N ipmilan-overcloud-compute-N,fence-nova heat-admin@controller-1 $ sudo pcs stonith
Replace
Nwith the identifying number of each Compute node, for example,overcloud-compute-1,overcloud-compute-2, and so on. Use these identifying numbers to match each Compute node with the STONITH devices that you created earlier, for example, matchovercloud-compute-1withipmilan-overcloud-compute-1.After you complete this procedure, allow some time for the environment to settle and then cleanup any failed resources.
heat-admin@controller-1 $ sleep 60 heat-admin@controller-1 $ sudo pcs resource cleanup heat-admin@controller-1 $ sudo pcs status heat-admin@controller-1 $ sudo pcs property set stonith-enabled=true
