Skip to content

Commit

Permalink
Fix OSPDo specifics for single vs multi cellls
Browse files Browse the repository at this point in the history
Declare RUN_OVERRIDES before it is used.

Use env vars instead of docs generation conditions to reuse the same
code in tests:
* Add MARIADB_RUN_OVERRIDES to cover all overrides and client annotations
* Add missing definitions for rhoso/ospd namespace specific vars
* Use env TRIPLEO_PASSWORDS for all cases as OSPDo still deploys
  tripleo
* Define and use NAMESPACE (default openstack) instead of
  RHOSO18_NAMESPACE or OSPDO_NAMESPACE. Remove unused rhoso18 ns value
  (only in these guide).

Signed-off-by: Bohdan Dobrelia <[email protected]>
  • Loading branch information
bogdando committed Dec 6, 2024
1 parent 110d926 commit cdff544
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
Migrate your databases from the original {rhos_prev_long} ({OpenStackShort}) deployment to the MariaDB instances in the {rhocp_long} cluster.

//[NOTE]
//This example scenario describes a simple single-cell setup. Real
//multi-stack topology recommended for production use results in different
//cells DBs layout, and should be using different naming schemes (not covered
//here this time). kgilliga: I hid the same note in the Compute adoption procedure. Will likely reinstate this after multi-cell is released.
//TOD(bogdando): For OSPDo, this example scenario describes a simple single-cell setup.
//TODO(kgilliga): I hid the same note in the Compute adoption procedure. Will likely reinstate this after multi-cell is released.

.Prerequisites

Expand All @@ -32,6 +30,8 @@ CELLS="default cell1 cell2"
DEFAULT_CELL_NAME="cell3"
RENAMED_CELLS="cell1 cell2 $DEFAULT_CELL_NAME"
NAMESPACE="openstack"
# The CHARACTER_SET and collation should match the source DB
# if the do not then it will break foreign key relationships
# for any tables that are created in the future as part of db sync
Expand Down Expand Up @@ -224,7 +224,7 @@ $ test -z "$PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK" || [ "x$PULL_OPENSTACK
+
----
for CELL in $(echo "super $RENAMED_CELLS"); do
oc run mariadb-client --image $MARIADB_IMAGE -i --rm --restart=Never -- \
oc run mariadb-client -n $NAMESPACE --image $MARIADB_IMAGE -i --rm --restart=Never -- \
mysql -rsh "${PODIFIED_MARIADB_IP[$CELL]}" -uroot -p"${PODIFIED_DB_ROOT_PASSWORD[$CELL]}" -e 'SHOW databases;'
done
----
Expand Down Expand Up @@ -258,12 +258,8 @@ Gnocchi is no longer used as a metric store as well
$ for CELL in $(echo $CELLS); do
RCELL=$CELL
[ "$CELL" = "default" ] && RCELL=$DEFAULT_CELL_NAME
ifeval::["{OpenStackPreviousInstaller}" != "director_operator"]
oc rsh mariadb-copy-data << EOF
endif::[]
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
oc rsh -n $OSPDO_NAMESPACE mariadb-copy-data << EOF
endif::[]
oc rsh -n $NAMESPACE mariadb-copy-data << EOF
declare -A db_name_map
db_name_map['nova']="nova_$RCELL"
Expand Down Expand Up @@ -348,10 +344,10 @@ $ for CELL in $(echo $CELLS); do
set -u
RCELL=$CELL
[ "$CELL" = "default" ] && RCELL=$DEFAULT_CELL_NAME
c1dbs=$(oc exec openstack-$RCELL-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} -e 'SHOW databases;')
c1dbs=$(oc exec openstack-$RCELL-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} -e 'SHOW databases;')
echo $c1dbs | grep -Eq "\bnova_${RCELL}\b" && echo "OK" || echo "CHECK FAILED"
novadb_svc_records=$(oc exec openstack-$RCELL-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} \
novadb_svc_records=$(oc exec openstack-$RCELL-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} \
nova_$RCELL -e "select host from services where services.binary='nova-compute' order by host asc;")
diff -Z <(echo $novadb_svc_records) <(echo ${PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$RCELL]}) && echo "OK" || echo "CHECK FAILED"
done
Expand Down

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions tests/roles/common_defaults/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use_no_log: false
# Whether the adopted node will host compute services
compute_adoption: true

# Whether adopting OSPDo or Director based TripleO deployment
deploy_ctlplane_ospdo: false

# The names of cells on the target cloud
renamed_cells: "{{ [default_cell_name] + cells | difference('default') }}"

Expand All @@ -31,6 +34,7 @@ cells_env: |
# Headers for DB client CLI image
mariadb_image_env: |
STORAGE_CLASS={{ storage_class_name }}
MARIADB_IMAGE=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified
# Header for the source databases initial clusters members health check
Expand Down Expand Up @@ -58,23 +62,30 @@ mariadb_passwords_env: |-
done
# Header for the source database access
# TODO: Env vars for OSPDo case are also configured in env_vars_src_ospdo.yaml. Move them here, eventually?
# OSPDo RUN_OVERRIDES definition exists only in docs (missing in code?).
# NOTE: in a split-stack source cloud, each stack passwords should come from a stack-specific passwords file,
# but different passwords are not supported in a multi-cell deployment
mariadb_copy_shell_vars_src: |-
{{ shell_header }}
PASSWORD_FILE="$HOME/overcloud-passwords.yaml"
NAMESPACE={{ deploy_ctlplane_ospdo | bool | ternary(rhoso_namespace, org_namespace) }}
{{ mariadb_image_env }}
{{ cells_env }}
MARIADB_CLIENT_ANNOTATIONS='--annotations=k8s.v1.cni.cncf.io/networks=internalapi'
STORAGE_CLASS={{ storage_class_name }}
declare -A TRIPLEO_PASSWORDS
for CELL in $(echo $CELLS); do
if [ "$CELL" = "default" ]; then
TRIPLEO_PASSWORDS[default]="$HOME/overcloud-passwords.yaml"
else
# in a split-stack source cloud, it should take a stack-specific passwords file instead
TRIPLEO_PASSWORDS[$CELL]="$HOME/overcloud-passwords.yaml"
fi
TRIPLEO_PASSWORDS[$CELL]="$TRIPLEO_PASSWORD"
done
RUN_OVERRIDES=' '
MARIADB_CLIENT_ANNOTATIONS={{ deploy_ctlplane_ospdo | bool | ternary("-n $NAMESPACE", "--annotations=k8s.v1.cni.cncf.io/networks=internalapi") }}
MARIADB_RUN_OVERRIDES={{ deploy_ctlplane_ospdo | bool | ternary("--overrides=${RUN_OVERRIDES} $MARIADB_CLIENT_ANNOTATIONS", "$MARIADB_CLIENT_ANNOTATIONS") }}
{{ pull_openstack_configuration_ssh_shell_vars }}
declare -A SOURCE_DB_ROOT_PASSWORD
for CELL in $(echo $CELLS); do
SOURCE_DB_ROOT_PASSWORD[$CELL]=$(cat ${TRIPLEO_PASSWORDS[$CELL]} | grep ' MysqlRootPassword:' | awk -F ': ' '{ print $2; }')
Expand All @@ -92,6 +103,8 @@ mariadb_copy_shell_vars_dst: |
{{ mariadb_image_env }}
{{ cells_env }}
NAMESPACE={{ deploy_ctlplane_ospdo | bool | ternary(rhoso_namespace, org_namespace) }}
# The CHARACTER_SET and collation should match the source DB
# if the do not then it will break foreign key relationships
# for any tables that are created in the future as part of db sync
Expand Down
1 change: 0 additions & 1 deletion tests/roles/get_services_configuration/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
ansible.builtin.shell: |
{{ oc_header }}
{{ mariadb_copy_shell_vars_src }}
{{ pull_openstack_configuration_ssh_shell_vars }}
unset PULL_OPENSTACK_CONFIGURATION_DATABASES
unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK
unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES
Expand Down
1 change: 1 addition & 0 deletions tests/roles/mariadb_copy/tasks/env_vars_src_ospdo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
oc get secret -n {{ org_namespace }} tripleo-passwords -o jsonpath='{.data.*}'| base64 -d |grep MysqlRootPassword|sed 's/.*: //g'
register: source_db_root_pass

# FIXME: OSPDo RUN_OVERRIDES definition exists only in docs (missing in code?).
- name: set src MariaDB copy shell vars
no_log: "{{ use_no_log }}"
ansible.builtin.set_fact:
Expand Down
36 changes: 23 additions & 13 deletions tests/roles/mariadb_copy/templates/post_checks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ set +u
. ~/.source_cloud_exported_variables_default
set -u

dbs=$(oc exec openstack-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'SHOW databases;')
dbs=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'SHOW databases;')
echo $dbs | grep -Eq '\bkeystone\b' && echo "OK" || echo "CHECK FAILED"

# ensure neutron db is renamed from ovs_neutron
echo $dbs | grep -Eq '\bneutron\b'
echo "${PULL_OPENSTACK_CONFIGURATION_DATABASES[@]}" | grep -Eq '\bovs_neutron\b' && echo "OK" || echo "CHECK FAILED"

# ensure default cell is renamed to $DEFAULT_CELL_NAME, and the cell UUIDs retained intact
novadb_mapped_cells=$(oc exec openstack-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" \
novadb_mapped_cells=$(oc exec openstack-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" \
nova_api -e 'select uuid,name,transport_url,database_connection,disabled from cell_mappings;')
uuidf='\S{8,}-\S{4,}-\S{4,}-\S{4,}-\S{12,}'
left_behind=$(comm -23 \
Expand All @@ -28,19 +28,29 @@ default=$(grep -E ' default$' <<<$left_behind)
test $(grep -Ec ' \S+$' <<<$changed) -eq 1 && echo "OK" || echo "CHECK FAILED"
grep -qE " $(awk '{print $1}' <<<$default) ${DEFAULT_CELL_NAME}$" <<<$changed && echo "OK" || echo "CHECK FAILED"

# ensure the registered Compute service name has not changed
for CELL in $(echo $CELLS); do
set +u
. ~/.source_cloud_exported_variables_$CELL
set -u
RCELL=$CELL
[ "$CELL" = "default" ] && RCELL=$DEFAULT_CELL_NAME
# ensure the registered Compute service names have not changed
c1dbs=$(oc exec openstack-$DEFAULT_CELL_NAME-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$DEFAULT_CELL_NAME]} -e 'SHOW databases;')
echo $c1dbs | grep -Eq "\bnova_${DEFAULT_CELL_NAME}\b" && echo "OK" || echo "CHECK FAILED"

novadb_svc_records=$(oc exec openstack-$DEFAULT_CELL_NAME-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$DEFAULT_CELL_NAME]} \
nova_$DEFAULT_CELL_NAME -e "select host from services where services.binary='nova-compute' order by host asc;")
diff -Z <(echo $novadb_svc_records) <(echo ${PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$DEFAULT_CELL_NAME]}) && echo "OK" || echo "CHECK FAILED"

for CELL in $(echo $RENAMED_CELLS); do
if [ "$CELL" = "$DEFAULT_CELL_NAME" ]; then
RCELL=default
else
RCELL=$CELL
set +u
. ~/.source_cloud_exported_variables_$CELL
set -u
fi
# ensure nova cells' db are extracted to separate db servers and renamed from nova to nova_cell<X>
c1dbs=$(oc exec openstack-$RCELL-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} -e 'SHOW databases;')
echo $c1dbs | grep -Eq "\bnova_${RCELL}\b" && echo "OK" || echo "CHECK FAILED"
c1dbs=$(oc exec openstack-$CELL-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$CELL]} -e 'SHOW databases;')
echo $c1dbs | grep -Eq "\bnova_${CELL}\b" && echo "OK" || echo "CHECK FAILED"

# ensure the registered Compute service name has not changed
novadb_svc_records=$(oc exec openstack-$RCELL-galera-0 -n {{ rhoso_namespace }} -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$RCELL]} \
nova_$RCELL -e "select host from services where services.binary='nova-compute' order by host asc;")
novadb_svc_records=$(oc exec openstack-$CELL-galera-0 -n $NAMESPACE -c galera -- mysql -rs -uroot -p${PODIFIED_DB_ROOT_PASSWORD[$CELL]} \
nova_$CELL -e "select host from services where services.binary='nova-compute' order by host asc;")
diff -Z <(echo $novadb_svc_records) <(echo ${PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$RCELL]}) && echo "OK" || echo "CHECK FAILED"
done
2 changes: 1 addition & 1 deletion tests/roles/mariadb_copy/templates/pre_checks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

# Test the connection to the control plane "upcall" and cells' databases
for CELL in $(echo "super $RENAMED_CELLS"); do
oc run mariadb-client -n {{ rhoso_namespace }} --image $MARIADB_IMAGE -i --rm --restart=Never -- \
oc run mariadb-client -n $NAMESPACE --image $MARIADB_IMAGE -i --rm --restart=Never -- \
mysql -rsh "${PODIFIED_MARIADB_IP[$CELL]}" -uroot -p"${PODIFIED_DB_ROOT_PASSWORD[$CELL]}" -e 'SHOW databases;'
done
2 changes: 1 addition & 1 deletion tests/roles/mariadb_copy/templates/restore_dbs.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
for CELL in $(echo $CELLS); do
RCELL=$CELL
[ "$CELL" = "default" ] && RCELL=$DEFAULT_CELL_NAME
oc rsh -n {{ rhoso_namespace }} mariadb-copy-data << EOF
oc rsh -n $NAMESPACE mariadb-copy-data << EOF
# db schemas to rename on import
declare -A db_name_map
db_name_map['nova']="nova_$RCELL"
Expand Down

0 comments on commit cdff544

Please sign in to comment.