From 1ccb5dd0fe5ce760f3fa684a6779570a9c6ef2d3 Mon Sep 17 00:00:00 2001
From: Jose Luis Franco Arza <jfrancoa@redhat.com>
Date: Fri, 14 Jul 2017 09:50:58 +0200
Subject: Add validation task in docker services

Docker services are missing the pre-upgrade validation task
in the upgrade_tasks section which verifies if the service
is running before stopping it.

Change-Id: Ia8c25827d0d6f34e0345c3946dfd6839a7116e04
Partial-Bug: #1704389
---
 docker/services/mistral-executor.yaml | 12 ++++++++++++
 docker/services/neutron-api.yaml      | 10 ++++++++++
 docker/services/neutron-dhcp.yaml     | 10 ++++++++++
 docker/services/neutron-metadata.yaml | 10 ++++++++++
 4 files changed, 42 insertions(+)

(limited to 'docker')

diff --git a/docker/services/mistral-executor.yaml b/docker/services/mistral-executor.yaml
index 9ae07213..e3c5cda6 100644
--- a/docker/services/mistral-executor.yaml
+++ b/docker/services/mistral-executor.yaml
@@ -116,6 +116,18 @@ outputs:
             path: /var/log/containers/mistral
             state: directory
       upgrade_tasks:
+        - name: Check if mistral executor is deployed
+          command: systemctl is-enabled openstack-mistral-executor
+          tags: common
+          ignore_errors: True
+          register: mistral_executor_enabled
+        - name: "PreUpgrade step0,validation: Check if openstack-mistral-executor is running"
+          shell: >
+            /usr/bin/systemctl show 'openstack-mistral-executor' --property ActiveState |
+            grep '\bactive\b'
+          when: mistral_executor_enabled.rc == 0
+          tags: step0,validation
         - name: Stop and disable mistral_executor service
           tags: step2
+          when: mistral_executor_enabled.rc == 0
           service: name=openstack-mistral-executor state=stopped enabled=no
diff --git a/docker/services/neutron-api.yaml b/docker/services/neutron-api.yaml
index a2e5e174..72aee696 100644
--- a/docker/services/neutron-api.yaml
+++ b/docker/services/neutron-api.yaml
@@ -170,8 +170,18 @@ outputs:
             path: /var/log/containers/neutron
             state: directory
       upgrade_tasks:
+        - name: Check if neutron_server is deployed
+          command: systemctl is-enabled neutron-server
+          tags: common
+          ignore_errors: True
+          register: neutron_server_enabled
+        - name: "PreUpgrade step0,validation: Check service neutron-server is running"
+          shell: /usr/bin/systemctl show 'neutron-server' --property ActiveState | grep '\bactive\b'
+          when: neutron_server_enabled.rc == 0
+          tags: step0,validation
         - name: Stop and disable neutron_api service
           tags: step2
+          when: neutron_server_enabled.rc == 0
           service: name=neutron-server state=stopped enabled=no
       metadata_settings:
         get_attr: [NeutronBase, role_data, metadata_settings]
diff --git a/docker/services/neutron-dhcp.yaml b/docker/services/neutron-dhcp.yaml
index 93401b95..238a2da6 100644
--- a/docker/services/neutron-dhcp.yaml
+++ b/docker/services/neutron-dhcp.yaml
@@ -113,6 +113,16 @@ outputs:
             path: /var/log/containers/neutron
             state: directory
       upgrade_tasks:
+        - name: Check if neutron_dhcp_agent is deployed
+          command: systemctl is-enabled neutron-dhcp-agent
+          tags: common
+          ignore_errors: True
+          register: neutron_dhcp_agent_enabled
+        - name: "PreUpgrade step0,validation: Check service neutron-dhcp-agent is running"
+          shell: /usr/bin/systemctl show 'neutron-dhcp-agent' --property ActiveState | grep '\bactive\b'
+          when: neutron_dhcp_agent_enabled.rc == 0
+          tags: step0,validation
         - name: Stop and disable neutron_dhcp service
           tags: step2
+          when: neutron_dhcp_agent_enabled.rc == 0
           service: name=neutron-dhcp-agent state=stopped enabled=no
diff --git a/docker/services/neutron-metadata.yaml b/docker/services/neutron-metadata.yaml
index d03ea9a6..dc7ceaf1 100644
--- a/docker/services/neutron-metadata.yaml
+++ b/docker/services/neutron-metadata.yaml
@@ -109,6 +109,16 @@ outputs:
             path: /var/log/containers/neutron
             state: directory
       upgrade_tasks:
+        - name: Check if neutron_metadata_agent is deployed
+          command: systemctl is-enabled neutron-metadata-agent
+          tags: common
+          ignore_errors: True
+          register: neutron_metadata_agent_enabled
+        - name: "PreUpgrade step0,validation: Check service neutron-metadata-agent is running"
+          shell: /usr/bin/systemctl show 'neutron-metadata-agent' --property ActiveState | grep '\bactive\b'
+          when: neutron_metadata_agent_enabled.rc == 0
+          tags: step0,validation
         - name: Stop and disable neutron_metadata service
           tags: step2
+          when: neutron_metadata_agent_enabled.rc == 0
           service: name=neutron-metadata-agent state=stopped enabled=no
-- 
cgit 1.2.3-korg