From 43f241f6981c8074bba3b03291fdd034c1888818 Mon Sep 17 00:00:00 2001 From: Jose Luis Franco Arza Date: Mon, 7 Aug 2017 10:44:01 +0200 Subject: [PATCH] Add validation task in docker services [Heat] Docker services are missing the pre-upgrade validation task in the upgrade_tasks section which verifies if the service is running before going on with the upgrade. Change-Id: I04c6e8c9c1cd0b427465fbab7df99823e7bcd02c Partial-Bug: #1704389 --- docker/services/heat-api-cfn.yaml | 35 +++++++++++++++--------- docker/services/heat-api.yaml | 45 +++++++++++++++++++------------ docker/services/heat-engine.yaml | 10 +++++++ 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/docker/services/heat-api-cfn.yaml b/docker/services/heat-api-cfn.yaml index 84bc0672e8..9f8adbc673 100644 --- a/docker/services/heat-api-cfn.yaml +++ b/docker/services/heat-api-cfn.yaml @@ -132,24 +132,35 @@ outputs: - /var/log/containers/httpd/heat-api-cfn upgrade_tasks: - name: Check if heat_api_cfn is deployed - command: systemctl is-enabled openstack-heat-api-cfn + command: systemctl is-enabled --quiet openstack-heat-api-cfn tags: common ignore_errors: True register: heat_api_cfn_enabled - - name: check for heat_api_cfn running under apache (post upgrade) - tags: step2 + - name: Check for heat_api_cfn running under apache + tags: common shell: "httpd -t -D DUMP_VHOSTS | grep -q heat_api_cfn_wsgi" - register: heat_api_cfn_apache - ignore_errors: true - changed_when: false - check_mode: no - - name: Stop heat_api_cfn service (running under httpd) - tags: step2 - service: name=httpd state=stopped - when: heat_api_cfn_apache.rc == 0 + ignore_errors: True + register: httpd_enabled + - name: "PreUpgrade step0,validation: Check service openstack-heat-api-cfn is running" + command: systemctl is-active --quiet openstack-heat-api-cfn + when: heat_api_cfn_enabled.rc == 0 and httpd_enabled.rc != 0 + tags: step0,validation - name: Stop and disable heat_api_cfn service (pre-upgrade not under httpd) tags: step2 service: name=openstack-heat-api-cfn state=stopped enabled=no - when: heat_api_cfn_enabled.rc == 0 + when: heat_api_cfn_enabled.rc == 0 and httpd_enabled.rc != 0 + - name: Check if httpd service is running + command: systemctl is-active --quiet httpd + tags: common + ignore_errors: True + register: httpd_running + - name: "PreUpgrade step0,validation: Check if heat_api_cfn_wsgi is running" + tags: step0,validation + shell: systemctl status 'httpd' | grep -q heat_api_cfn_wsgi + when: httpd_enabled.rc == 0 and httpd_running.rc == 0 + - name: Stop heat_api_cfn service (running under httpd) + tags: step2 + service: name=httpd state=stopped + when: httpd_enabled.rc == 0 and httpd_running.rc == 0 metadata_settings: get_attr: [HeatBase, role_data, metadata_settings] diff --git a/docker/services/heat-api.yaml b/docker/services/heat-api.yaml index dcba519f78..c63e398da2 100644 --- a/docker/services/heat-api.yaml +++ b/docker/services/heat-api.yaml @@ -160,30 +160,41 @@ outputs: - /var/log/containers/heat - /var/log/containers/httpd/heat-api upgrade_tasks: - - name: Check is heat_api is deployed - command: systemctl is-enabled openstack-heat-api + - name: Check if heat_api is deployed + command: systemctl is-enabled --quiet openstack-heat-api tags: common ignore_errors: True register: heat_api_enabled + - name: Check for heat_api running under apache + tags: common + shell: "httpd -t -D DUMP_VHOSTS | grep -q heat_api_wsgi" + ignore_errors: True + register: httpd_enabled + - name: "PreUpgrade step0,validation: Check service openstack-heat-api is running" + command: systemctl is-active --quiet openstack-heat-api + when: heat_api_enabled.rc == 0 and httpd_enabled.rc != 0 + tags: step0,validation + - name: Stop and disable heat_api service (pre-upgrade not under httpd) + tags: step2 + service: name=openstack-heat-api state=stopped enabled=no + when: heat_api_enabled.rc == 0 and httpd_enabled.rc != 0 + - name: Check if httpd is running + tags: common + command: systemctl is-active --quiet httpd + ignore_errors: True + register: httpd_running + - name: "PreUpgrade step0,validation: Check if heat_api_wsgi is running" + shell: systemctl status 'httpd' | grep -q heat_api_wsgi + tags: step0,validation + when: httpd_enabled.rc == 0 and httpd_running.rc == 0 + - name: Stop heat_api service (running under httpd) + tags: step2 + service: name=httpd state=stopped + when: httpd_enabled.rc == 0 and httpd_running.rc == 0 - name: remove old heat cron jobs tags: step2 file: path: /var/spool/cron/heat state: absent - - name: check for heat_api running under apache (post upgrade) - tags: step2 - shell: "httpd -t -D DUMP_VHOSTS | grep -q heat_api_wsgi" - register: heat_api_apache - ignore_errors: true - changed_when: false - check_mode: no - - name: Stop heat_api service (running under httpd) - tags: step2 - service: name=httpd state=stopped - when: heat_api_apache.rc == 0 - - name: Stop and disable heat_api service (pre-upgrade not under httpd) - tags: step2 - service: name=openstack-heat-api state=stopped enabled=no - when: heat_api_enabled.rc == 0 metadata_settings: get_attr: [HeatBase, role_data, metadata_settings] diff --git a/docker/services/heat-engine.yaml b/docker/services/heat-engine.yaml index 21ae24267b..4c8a12a56e 100644 --- a/docker/services/heat-engine.yaml +++ b/docker/services/heat-engine.yaml @@ -135,6 +135,16 @@ outputs: path: /var/log/containers/heat state: directory upgrade_tasks: + - name: Check if heat_engine is deployed + command: systemctl is-enabled --quiet openstack-heat-engine + tags: common + ignore_errors: True + register: heat_engine_enabled + - name: "PreUpgrade step0,validation: Check service openstack-heat-engine is running" + command: systemctl is-active --quiet openstack-heat-engine + when: heat_engine_enabled.rc == 0 + tags: step0,validation - name: Stop and disable heat_engine service tags: step2 + when: heat_engine_enabled.rc == 0 service: name=openstack-heat-engine state=stopped enabled=no