diff --git a/releasenotes/notes/add-undercloud-service-check-fe0ac64b9608f2da.yaml b/releasenotes/notes/add-undercloud-service-check-fe0ac64b9608f2da.yaml new file mode 100644 index 000000000..3a97d5b26 --- /dev/null +++ b/releasenotes/notes/add-undercloud-service-check-fe0ac64b9608f2da.yaml @@ -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. diff --git a/tripleo_validations/inventory.py b/tripleo_validations/inventory.py index af54e9c50..1c8afcc99 100644 --- a/tripleo_validations/inventory.py +++ b/tripleo_validations/inventory.py @@ -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: diff --git a/tripleo_validations/tests/test_inventory.py b/tripleo_validations/tests/test_inventory.py index 8763eb788..2d0d61c22 100644 --- a/tripleo_validations/tests/test_inventory.py +++ b/tripleo_validations/tests/test_inventory.py @@ -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]) diff --git a/validations/undercloud-service-status.yaml b/validations/undercloud-service-status.yaml new file mode 100644 index 000000000..cb9ca7bc0 --- /dev/null +++ b/validations/undercloud-service-status.yaml @@ -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 }}"