From ea7c886e22e18a79fda64f159ff524bd587a277e Mon Sep 17 00:00:00 2001 From: Goutham Pacha Ravi Date: Tue, 23 Jun 2020 11:46:30 -0700 Subject: [PATCH] [Q->T] Add FFU steps for manila These steps were added for other overcloud services in [1] and [2]. [1] https://review.opendev.org/713482/ [2] https://review.opendev.org/720490/ Depends-On: I6a98140b7df8d3460ff8ec54f8b7a0d5abbef515 Depends-On: I1229d3a0cd2f08dabdcd3b47d9823f6a939cfbdb Resolves: rhbz#1849098 Closes-bug: #1884818 Change-Id: I0162e7dec09242a8d3981d1796f4cc6d911c7c4a Signed-off-by: Goutham Pacha Ravi --- .../manila_ffu_db_sync.sh | 34 +++++++++ .../manila/manila-api-container-puppet.yaml | 70 +++++++++++++++---- environments/lifecycle/upgrade-converge.yaml | 1 + 3 files changed, 91 insertions(+), 14 deletions(-) create mode 100755 container_config_scripts/manila_ffu_db_sync.sh diff --git a/container_config_scripts/manila_ffu_db_sync.sh b/container_config_scripts/manila_ffu_db_sync.sh new file mode 100755 index 0000000000..fe6068a6f2 --- /dev/null +++ b/container_config_scripts/manila_ffu_db_sync.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2020 Red Hat Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# manila-manage db sync is idempotent, as long as the code contains the version +# that the database is at. However, this helper script is to ensure that the +# command is always idempotent, and when the database is at a higher version +# than the version in the code, we'll just bail out rather than hard exiting. +set -e + +DB_VERSION=$( sudo -u manila manila-manage db version ) +REPO_VERSIONS=$( grep -h -r -Po "(?<=^revision \=).*" /usr/lib/python3.6/site-packages/manila/db/migrations/alembic/versions/ | tr -d \'\" | uniq ) +REPO_MAX=$( for v in $REPO_VERSIONS; do grep -r -q -e "^down_revision.*$v" /usr/lib/python3.6/site-packages/manila/db/migrations/alembic/versions/ || echo $v; done ) + +if [[ $DB_VERSION == $REPO_MAX ]]; then + echo "Manila DB is already up to date: $DB_VERSION" +elif [[ $REPO_VERSIONS == *"$DB_VERSION"* ]]; then + # Package provides a newer version, we must upgrade + sudo -u manila manila-manage db sync + echo "Manila DB is upgraded to: $REPO_MAX" +else + echo "Manila DB version: $DB_VERSION is higher than the maximum provided by the package $REPO_MAX. Nothing to do" +fi diff --git a/deployment/manila/manila-api-container-puppet.yaml b/deployment/manila/manila-api-container-puppet.yaml index 82e407c3e1..1e99d48a27 100644 --- a/deployment/manila/manila-api-container-puppet.yaml +++ b/deployment/manila/manila-api-container-puppet.yaml @@ -4,6 +4,10 @@ description: > OpenStack containerized Manila API service parameters: + ContainerManilaApiImageStein: + description: image + type: string + default: '' ContainerManilaApiImage: description: image type: string @@ -36,6 +40,12 @@ parameters: default: {} description: Parameters specific to the role type: json + DeployIdentifier: + default: '' + type: string + description: > + Setting this to a unique value will re-run any deployment tasks which + perform configuration on a Heat stack-update. EnableInternalTLS: type: boolean default: false @@ -57,6 +67,7 @@ parameters: conditions: + fast_forward_upgrade: {not: {equals: [{get_param: ContainerManilaApiImageStein},'']}} internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]} manila_workers_zero: {equals : [{get_param: ManilaWorkers}, 0]} @@ -197,6 +208,12 @@ outputs: - path: /var/log/manila owner: manila:manila recurse: true + container_config_scripts: + map_merge: + - {get_attr: [ContainersCommon, container_config_scripts]} + - manila_ffu_db_sync.sh: + mode: "0755" + content: { get_file: ../../container_config_scripts/manila_ffu_db_sync.sh } docker_config: step_2: manila_init_logs: @@ -208,20 +225,45 @@ outputs: - /var/log/containers/httpd/manila-api:/var/log/httpd:z command: ['/bin/bash', '-c', 'chown -R manila:manila /var/log/manila'] step_3: - manila_api_db_sync: - user: root - image: *manila_api_image - net: host - detach: false - volumes: - list_concat: - - {get_attr: [ContainersCommon, volumes]} - - - - /var/lib/config-data/manila/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro - - /var/lib/config-data/manila/etc/manila/:/etc/manila/:ro - - /var/log/containers/manila:/var/log/manila:z - - /var/log/containers/httpd/manila-api:/var/log/httpd:z - command: "/usr/bin/bootstrap_host_exec manila_api su manila -s /bin/bash -c '/usr/bin/manila-manage db sync'" + map_merge: + - manila_api_db_sync: + start_order: 1 + user: root + image: *manila_api_image + net: host + detach: false + volumes: &manila_volumes + list_concat: + - {get_attr: [ContainersCommon, volumes]} + - + - /var/lib/config-data/manila/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro + - /var/lib/config-data/manila/etc/manila/:/etc/manila/:ro + - /var/log/containers/manila:/var/log/manila:z + - /var/log/containers/httpd/manila-api:/var/log/httpd:z + command: "/usr/bin/bootstrap_host_exec manila_api su manila -s /bin/bash -c '/usr/bin/manila-manage db sync'" + environment: + TRIPLEO_DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} + - if: + - fast_forward_upgrade + - manila_api_db_sync_stein: + start_order: 0 + image: &manila_api_image_stein {get_param: ContainerManilaApiImageStein} + net: host + privileged: false + detach: false + user: root + volumes: + list_concat: + - *manila_volumes + - + - /var/lib/container-config-scripts/:/container-config-scripts/:ro + command: + - '/usr/bin/bootstrap_host_exec' + - 'manila_api' + - '/container-config-scripts/manila_ffu_db_sync.sh' + environment: + TRIPLEO_DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} + - {} step_4: manila_api: image: *manila_api_image diff --git a/environments/lifecycle/upgrade-converge.yaml b/environments/lifecycle/upgrade-converge.yaml index a1d88c0ecd..c4b6975f13 100644 --- a/environments/lifecycle/upgrade-converge.yaml +++ b/environments/lifecycle/upgrade-converge.yaml @@ -14,6 +14,7 @@ parameter_defaults: ContainerIronicApiImageStein: '' ContainerIronicInspectorImageStein: '' ContainerKeystoneImageStein: '' + ContainerManilaApiImageStein: '' ContainerMistralApiImageStein: '' ContainerNeutronApiImageStein: '' ContainerNovaApiImageStein: ''