Validate undercloud service status before update/upgrade

Run basic sanity check on the undercloud services state.
Intended for use before invoking a stack update, esp. a minor
update or major upgrade.

Adds a static list of undercloud services to the inventory
for use by other undercloud tasks as a first iteration

Change-Id: I50ecb16f924fc5afa327b842d3b2e1427e1351eb
This commit is contained in:
marios 2017-05-05 14:30:31 +03:00
parent 2a2f44c1b3
commit 7eabab7bfd
4 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
features:
- Adds simple undercloud service list (static) to the inventory
and uses that for pre-upgrade/update check that services are OK.

View File

@ -83,6 +83,21 @@ class TripleoInventory(object):
except Exception:
return {}
UNDERCLOUD_SERVICES = [
'openstack-nova-compute', 'openstack-nova-api',
'openstack-heat-engine', 'openstack-heat-api',
'openstack-ironic-conductor', 'openstack-ironic-api',
'openstack-swift-container', 'openstack-swift-object',
'openstack-zaqar', 'openstack-glance-api', 'openstack-mistral-engine',
'openstack-mistral-api.service', 'openstack-glance-api']
def get_undercloud_service_list(self):
"""Return list of undercloud services - currently static
Replace this when we have a better way - e.g. heat deploys undercloud
"""
return self.UNDERCLOUD_SERVICES
def list(self):
ret = {
'undercloud': {
@ -109,6 +124,10 @@ class TripleoInventory(object):
ret['undercloud']['vars']['overcloud_admin_password'] = \
admin_password
endpoint_map = self.stack_outputs.get('EndpointMap')
ret['undercloud']['vars']['undercloud_service_list'] = \
self.get_undercloud_service_list()
if endpoint_map:
horizon_endpoint = endpoint_map.get('HorizonPublic', {}).get('uri')
if horizon_endpoint:

View File

@ -166,7 +166,21 @@ class TestInventory(base.TestCase):
'overcloud_keystone_url': 'xyz://keystone',
'overcloud_admin_password': 'theadminpw',
'plan': 'overcloud',
'undercloud_swift_url': 'anendpoint'}}}
'undercloud_swift_url': 'anendpoint',
'undercloud_service_list': [
'openstack-nova-compute',
'openstack-nova-api',
'openstack-heat-engine',
'openstack-heat-api',
'openstack-ironic-conductor',
'openstack-ironic-api',
'openstack-swift-container',
'openstack-swift-object',
'openstack-zaqar',
'openstack-glance-api',
'openstack-mistral-engine',
'openstack-mistral-api.service',
'openstack-glance-api'], }}}
inv_list = self.inventory.list()
for k in expected:
self.assertEqual(expected[k], inv_list[k])

View File

@ -0,0 +1,21 @@
---
- hosts: undercloud
vars:
metadata:
name: Verify undercloud services state before running update or upgrade
description: >
Check undercloud status before running a stack update - especially minor update and major upgrade.
groups:
- pre-update
- pre-upgrade
tasks:
- name: Check Services are running
command: "/usr/bin/systemctl show {{ item }} --property ActiveState"
become: true
with_items: "{{ undercloud_service_list }}"
register: "check_services"
ignore_errors: true
- name: Fail if services were not running
fail: msg="One of the undercloud services was not active. Please check {{ item.item }} first and then confirm the status of undercloud services in general before attempting to update or upgrade the environment."
failed_when: "{{ item.stdout != 'ActiveState=active' }}"
with_items: "{{ check_services.results }}"