Browse Source

Merge "[TRAIN ONLY] Wait until DB is ready for neutron DB rename" into stable/train

changes/81/739481/5
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
6c7ccc9347
2 changed files with 49 additions and 14 deletions
  1. +38
    -0
      container_config_scripts/neutron_db_rename.sh
  2. +11
    -14
      deployment/database/mysql-container-puppet.yaml

+ 38
- 0
container_config_scripts/neutron_db_rename.sh View File

@@ -0,0 +1,38 @@
#!/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.

set -e
retries=0

if [ -d /var/lib/mysql/neutron ] ; then
# check whether the database is available and returning responses
until mysql -e "SELECT 1;" &>/dev/null; do
retries=$(( retries + 1 ))
# 12 retries = 12 x 10sec = 2 minutes
if [ $retries -ge 12 ]; then
echo "Database still not available. Terminating ..."
exit 1
else
echo "$retries: Waiting for database availability ..."
sleep 10
fi
done

mysql -e "CREATE DATABASE IF NOT EXISTS \`ovs_neutron\`;"
for table in `mysql -B -N -e "SHOW TABLES;" neutron`; do
mysql -e "RENAME TABLE \`neutron\`.\`$table\` to \`ovs_neutron\`.\`$table\`"
done
mysql -e "DROP DATABASE \`neutron\`;"
fi

+ 11
- 14
deployment/database/mysql-container-puppet.yaml View File

@@ -58,6 +58,9 @@ conditions:

resources:

ContainersCommon:
type: ../containers-common.yaml

MysqlBase:
type: ./mysql-base.yaml
properties:
@@ -119,6 +122,12 @@ outputs:
- path: /etc/pki/tls/private/mysql.key
owner: mysql:mysql
optional: true
container_config_scripts:
map_merge:
- {get_attr: [ContainersCommon, container_config_scripts]}
- neutron_db_rename.sh:
mode: "0755"
content: { get_file: ../../container_config_scripts/neutron_db_rename.sh }
docker_config:
# Kolla_bootstrap runs before permissions set by kolla_config
step_1:
@@ -207,25 +216,13 @@ outputs:
# required for bootstrap_host_exec
- /etc/puppet:/etc/puppet:ro
- /var/lib/config-data/puppet-generated/mysql/root:/root:rw #provides .my.cnf for puppet, changed on password update
- /var/lib/container-config-scripts/:/container-config-scripts/:ro
environment:
KOLLA_CONFIG_STRATEGY: COPY_ALWAYS
net: host
user: root
# Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
command:
- 'bash'
- '-ec'
-
list_join:
- "\n"
- - 'if [ -d /var/lib/mysql/neutron ] ; then'
- 'mysql -e "CREATE DATABASE IF NOT EXISTS \`ovs_neutron\`;"'
- 'for table in `mysql -B -N -e "SHOW TABLES;" neutron`'
- 'do'
- 'mysql -e "RENAME TABLE \`neutron\`.\`$table\` to \`ovs_neutron\`.\`$table\`"'
- 'done'
- 'mysql -e "DROP DATABASE \`neutron\`;"'
- 'fi'
- '/container-config-scripts/neutron_db_rename.sh'
step_3:
# sync credentials config on the running container if it was
# changed by the docker_puppet_task during step 2


Loading…
Cancel
Save