diff --git a/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc b/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc index 7cd748150..81efd0b6f 100644 --- a/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc +++ b/docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc @@ -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 @@ -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 @@ -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 ---- @@ -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" @@ -342,16 +338,17 @@ $ 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" +# TODO align with tests $ for CELL in $(echo $CELLS); do set +u . ~/.source_cloud_exported_variables_$CELL 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 diff --git a/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc b/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc index aebdae413..a6df7f37c 100644 --- a/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc +++ b/docs_user/modules/proc_retrieving-topology-specific-service-configuration.adoc @@ -10,113 +10,55 @@ Before you migrate your databases to the {rhos_long} control plane, retrieve the .Prerequisites -* Define the following shell variables. Replace the example values with values that are correct for your environment: +. Define the following shell variables. Replace the example values with values that are correct for your environment: + ---- -ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] -CELLS="default cell1 cell2" <1> +$ PASSWORD_FILE="$HOME/overcloud-passwords.yaml" +$ NAMESPACE="openstack" ifeval::["{build}" != "downstream"] -CONTROLLER1_SSH="ssh -i ~/install_yamls/out/edpm/ansibleee-ssh-key-id_rsa root@192.168.122.100" -MARIADB_IMAGE=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified +$ MARIADB_IMAGE=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified endif::[] ifeval::["{build}" == "downstream"] -CONTROLLER1_SSH="ssh -i ** root@**" <1> -MARIADB_IMAGE=registry.redhat.io/rhosp-dev-preview/openstack-mariadb-rhel9:18.0 -endif::[] +$ MARIADB_IMAGE=registry.redhat.io/rhosp-dev-preview/openstack-mariadb-rhel9:18.0 endif::[] -ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] -MARIADB_CLIENT_ANNOTATIONS='--annotations=k8s.v1.cni.cncf.io/networks=internalapi' -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 -done - -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; }') -done - -declare -A SOURCE_MARIADB_IP <2> -SOURCE_MARIADB_IP[default]=** -SOURCE_MARIADB_IP[cell1]=** -SOURCE_MARIADB_IP[cell2]=** -# ... ----- -+ -<1> Complete `CONTROLLER1_SSH` settings with SSH connection details for any non-cell controller of the source {OpenStackPreviousInstaller} cloud. -<2> For each cell defined in `CELLS`, replace `SOURCE_MARIADB_IP[*]= ...`, and complete the records lists for the cell names and VIP addresses of MariaDB Galera clusters, include cells, of the source {OpenStackPreviousInstaller} cloud. - -To get the values for `SOURCE_MARIADB_IP`, query the puppet-generated configurations in a Controller and CellController node: -+ ----- -$ sudo grep -rI 'listen mysql' -A10 /var/lib/config-data/puppet-generated/ | grep bind ----- - -[NOTE] -The source cloud always uses the same password for cells' databases by design. -For that reason, we chose to use the same passwords file for all cells' stacks. -There is a split-stack topology, however, that allows using different passwords -files for each stack. - -.Procedure - -. Export the shell variables for the following outputs and test the connection to the {OpenStackShort} database: -+ ----- -$ unset PULL_OPENSTACK_CONFIGURATION_DATABASES -$ declare -xA PULL_OPENSTACK_CONFIGURATION_DATABASES -$ for CELL in $(echo $CELLS); do +$ declare -A TRIPLEO_PASSWORDS ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] - PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]=$(oc run mariadb-client-1-$CELL ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +$ CELLS="default cell1 cell2" +$ for CELL in $(echo $CELLS); do + TRIPLEO_PASSWORDS[$CELL]="$TRIPLEO_PASSWORD" +done endif::[] ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] - PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]=$(oc run mariadb-client-1-$CELL --overrides="$RUN_OVERRIDES" -n $OSPDO_NAMESPACE -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +$ CELLS="default" +$ for CELL in $(echo $CELLS); do + oc get secret tripleo-passwords -n $NAMESPACE -o json | jq -r '.data["tripleo-overcloud-passwords.yaml"]' | base64 -d >"$TRIPLEO_PASSWORDS[$CELL]" +done endif::[] - mysql -rsh "${SOURCE_MARIADB_IP[$CELL]}" -uroot -p"${SOURCE_DB_ROOT_PASSWORD[$CELL]}" -e 'SHOW databases;') +$ 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; }') done - -<-- FIXME: this is broken now --> ----- -ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] ----- -export CONTROLLER1_SSH="oc -n $OSPDO_NAMESPACE rsh -c openstackclient openstackclient ssh controller-0.ctlplane" ----- -* With OSPdO, the `mariadb-client` needs to run on the same {rhocp_long} node where the {OpenStackShort} Controller node is running. In addition, the `internalapi-static` network needs to be attached to the pod. ---- -export PASSWORD_FILE="tripleo-passwords.yaml" -export OSPDO_NAMESPACE="openstack" ----- -. Get the passwords file: + ----- -$ oc get secret tripleo-passwords -n $OSPDO_NAMESPACE -o json | jq -r '.data["tripleo-overcloud-passwords.yaml"]' | -base64 -d >"${PASSWORD_FILE}" ----- +ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] +* You can only have a single Nova compute cell deployed on the source cloud. . Get the name of the {OpenShiftShort} node where the {OpenStackShort} Controller virtual machine is running: + ---- $ export CONTROLLER_NODE=$(oc get vmi -ojson | jq -r '.items[0].status.nodeName') $ export SOURCE_OVN_OVSDB_IP=172.17.0.160 # get this from the source OVN DB - -$ export SOURCE_DB_ROOT_PASSWORD=$(grep <"${PASSWORD_FILE}" ' MysqlRootPassword:' | awk -F ': ' '{ print $2; }') || { - echo "Failed to get the source DB root password" - exit 1 -} ---- ++ + . Find the mysql service IP in the `ctlplane-export.yaml` section of the `tripleo-exports-default` ConfigMap: + ---- -$ cpexport=$(oc -n "${OSPDO_NAMESPACE}" get cm tripleo-exports-default -o json | jq -r '.data["ctlplane-export.yaml"]') -$ export SOURCE_MARIADB_IP=$(echo "$cpexport" | sed -e '0,/ MysqlInternal/d' | sed -n '0,/host_nobrackets/s/^.*host_nobrackets\:\s*\(.*\)$/\1/p') -+ -$ export MARIADB_IMAGE='quay.io/podified-antelope-centos9/openstack-mariadb:current-podified' -+ +$ cpexport=$(oc -n "${NAMESPACE}" get cm tripleo-exports-default -o json | jq -r '.data["ctlplane-export.yaml"]') +$ declare -A SOURCE_MARIADB_IP +$ for CELL in $(echo $CELLS); do + SOURCE_MARIADB_IP[$CELL]=$(echo "$cpexport" | sed -e '0,/ MysqlInternal/d' | sed -n '0,/host_nobrackets/s/^.*host_nobrackets\:\s*\(.*\)$/\1/p') +done $ RUN_OVERRIDES='{ "apiVersion": "v1", "metadata": { @@ -139,20 +81,79 @@ $ RUN_OVERRIDES='{ } }' ---- ++ +* With OSPdO, the `mariadb-client` needs to run on the same {rhocp_long} node where the {OpenStackShort} Controller node is running. In addition, the `internalapi-static` network needs to be attached to the pod. +endif::[] + +. Define the following shell variables. Replace the example values with values that are correct for your environment: ++ +---- +ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] +$ MARIADB_CLIENT_ANNOTATIONS='--annotations=k8s.v1.cni.cncf.io/networks=internalapi' +$ MARIADB_RUN_OVERRIDES="$MARIADB_CLIENT_ANNOTATIONS" + +ifeval::["{build}" != "downstream"] +$ CONTROLLER1_SSH="ssh -i ~/install_yamls/out/edpm/ansibleee-ssh-key-id_rsa root@192.168.122.100" +endif::[] +ifeval::["{build}" == "downstream"] +$ CONTROLLER1_SSH="ssh -i ** root@**" +endif::[] +endif::[] +ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] +$ MARIADB_CLIENT_ANNOTATIONS="-n $NAMESPACE" +$ MARIADB_RUN_OVERRIDES="--overrides=${RUN_OVERRIDES} $MARIADB_CLIENT_ANNOTATIONS" + +$ CONTROLLER1_SSH="oc -n $NAMESPACE rsh -c openstackclient openstackclient ssh controller-0.ctlplane" +$ oc get secret tripleo-passwords -n $NAMESPACE -o json | jq -r '.data["tripleo-overcloud-passwords.yaml"]' | +base64 -d >"${PASSWORD_FILE}" +endif::[] + +$ declare -A SOURCE_MARIADB_IP +$ SOURCE_MARIADB_IP[default]=** +ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] +$ SOURCE_MARIADB_IP[cell1]=** +$ SOURCE_MARIADB_IP[cell2]=** +# ... +endif::[] +---- ++ +* Complete `CONTROLLER1_SSH` settings with SSH connection details for any non-cell controller of the source {OpenStackPreviousInstaller} cloud. +* For each cell defined in `CELLS`, replace `SOURCE_MARIADB_IP[*]= ...`, and complete the records lists for the cell names and VIP addresses of MariaDB Galera clusters, include cells, of the source {OpenStackPreviousInstaller} cloud. +* To get the values for `SOURCE_MARIADB_IP`, query the puppet-generated configurations in a Controller +ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] +and CellController +endif::[] +node: ++ +---- +$ sudo grep -rI 'listen mysql' -A10 /var/lib/config-data/puppet-generated/ | grep bind +---- ++ + +[NOTE] +The source cloud always uses the same password for cells' databases by design. +For that reason, we chose to use the same passwords file for all cells' stacks. +There is a split-stack topology, however, that allows using different passwords +files for each stack. + .Procedure . Export the shell variables for the following outputs and test the connection to the {OpenStackShort} database: + ---- -$ export PULL_OPENSTACK_CONFIGURATION_DATABASES="$(oc run mariadb-client -q --image "${MARIADB_IMAGE}" \ - -i --rm --restart=Never {pod_annotations} -- mysql -rsh "$SOURCE_MARIADB_IP" -uroot -p"$SOURCE_DB_ROOT_PASSWORD" -e 'SHOW databases;')" +$ unset PULL_OPENSTACK_CONFIGURATION_DATABASES +$ declare -xA PULL_OPENSTACK_CONFIGURATION_DATABASES +$ for CELL in $(echo $CELLS); do + PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]=$(oc run mariadb-client-1-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ + mysql -rsh "${SOURCE_MARIADB_IP[$CELL]}" -uroot -p"${SOURCE_DB_ROOT_PASSWORD[$CELL]}" -e 'SHOW databases;') +done ---- -endif::[] + [NOTE] -<-- /end FIXME: this is broken now --> The `nova`, `nova_api`, and `nova_cell0` databases are inlcuded in the same database host for the main overcloud Heat stack. +ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] Additional cells use the `nova` database of their local Galera clusters. +endif::[] . Run `mysqlcheck` on the {OpenStackShort} database to check for inaccuracies: + @@ -160,12 +161,7 @@ Additional cells use the `nova` database of their local Galera clusters. $ unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK $ declare -xA PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK $ run_mysqlcheck() { -ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] - PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK=$(oc run mariadb-client-2-$1 ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ -endif::[] -ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] - PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK=$(oc run mariadb-client-2-$1 --overrides="$RUN_OVERRIDES" -n $OSPDO_NAMESPACE -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ -endif::[] + PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK=$(oc run mariadb-client-2-$1 ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysqlcheck --all-databases -h ${SOURCE_MARIADB_IP[$CELL]} -u root -p"${SOURCE_DB_ROOT_PASSWORD[$CELL]}" | grep -v OK) } $ for CELL in $(echo $CELLS); do @@ -174,7 +170,7 @@ done $ if [ "$PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK" != "" ]; then # Try mysql_upgrade to fix mysqlcheck failure for CELL in $(echo $CELLS); do - MYSQL_UPGRADE=$(oc run mariadb-client-3 ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ + MYSQL_UPGRADE=$(oc run mariadb-client-3 ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql_upgrade -v -h ${SOURCE_MARIADB_IP[$CELL]} -u root -p"${SOURCE_DB_ROOT_PASSWORD[$CELL]}") # rerun mysqlcheck to check if problem is resolved run_mysqlcheck @@ -186,12 +182,7 @@ fi . Get the {compute_service_first_ref} cell mappings: + ---- -ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] -export PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS=$(oc run mariadb-client-1 ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ -endif::[] -ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] -export PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS=$(oc run mariadb-client-1 --overrides="$RUN_OVERRIDES" -n $OSPDO_NAMESPACE -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ -endif::[] +export PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS=$(oc run mariadb-client-1 ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql -rsh "${SOURCE_MARIADB_IP['default]}" -uroot -p"${SOURCE_DB_ROOT_PASSWORD['default']}" nova_api -e \ 'select uuid,name,transport_url,database_connection,disabled from cell_mappings;') ---- @@ -203,15 +194,12 @@ endif::[] $ unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES $ declare -xA PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES $ for CELL in $(echo $CELLS); do -ifeval::["{OpenStackPreviousInstaller}" != "director_operator"] - PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$CELL]=$(oc run mariadb-client-4-$CELL ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ -endif::[] -ifeval::["{OpenStackPreviousInstaller}" == "director_operator"] - PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$CELL]=$(oc run mariadb-client-4-$CELL --overrides="$RUN_OVERRIDES" -n $OSPDO_NAMESPACE -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ + PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$CELL]=$(oc run mariadb-client-4-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql -rsh "${SOURCE_MARIADB_IP[$CELL]}" -uroot -p"${SOURCE_DB_ROOT_PASSWORD[$CELL]}" -e \ "select host from nova.services where services.binary='nova-compute';") done ---- ++ . Get the list of the mapped {compute_service} cells: + @@ -235,23 +223,24 @@ $ declare -xA PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK $ declare -xA PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES $ for CELL in $(echo $CELLS); do cat > ~/.source_cloud_exported_variables_$CELL << EOF -PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]="$(oc run mariadb-client-5-$CELL ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +PULL_OPENSTACK_CONFIGURATION_DATABASES[$CELL]="$(oc run mariadb-client-5-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql -rsh ${SOURCE_MARIADB_IP[$CELL]} -uroot -p${SOURCE_DB_ROOT_PASSWORD[$CELL]} -e 'SHOW databases;')" -PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK[$CELL]="$(oc run mariadb-client-6-$CELL ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK[$CELL]="$(oc run mariadb-client-6-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysqlcheck --all-databases -h ${SOURCE_MARIADB_IP[$CELL]} -u root -p${SOURCE_DB_ROOT_PASSWORD[$CELL]} | grep -v OK)" -PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$CELL]="$(oc run mariadb-client-7-$CELL ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$CELL]="$(oc run mariadb-client-7-$CELL ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql -rsh ${SOURCE_MARIADB_IP[$CELL]} -uroot -p${SOURCE_DB_ROOT_PASSWORD[$CELL]} -e \ "select host from nova.services where services.binary='nova-compute';")" EOF done $ cat >> ~/.source_cloud_exported_variables_default << EOF -PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS="$(oc run mariadb-client-2 ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ +PULL_OPENSTACK_CONFIGURATION_NOVADB_MAPPED_CELLS="$(oc run mariadb-client-2 ${MARIADB_RUN_OVERRIDES} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \ mysql -rsh ${SOURCE_MARIADB_IP['default']} -uroot -p${SOURCE_DB_ROOT_PASSWORD['default']} -e \ 'select uuid,name,transport_url,database_connection,disabled from nova_api.cell_mappings;' || echo None)" PULL_OPENSTACK_CONFIGURATION_NOVAMANAGE_CELL_MAPPINGS="$($CONTROLLER1_SSH sudo podman exec -it nova_conductor nova-manage cell_v2 list_cells)" EOF $ chmod 0600 ~/.source_cloud_exported_variables* ---- ++ <1> If `neutron-sriov-nic-agent` agents are running in your {OpenStackShort} deployment, get the configuration to use for the data plane adoption [NOTE] diff --git a/tests/roles/common_defaults/defaults/main.yaml b/tests/roles/common_defaults/defaults/main.yaml index 44699d2b0..a1fcb518a 100644 --- a/tests/roles/common_defaults/defaults/main.yaml +++ b/tests/roles/common_defaults/defaults/main.yaml @@ -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') }}" @@ -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 @@ -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; }') @@ -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 diff --git a/tests/roles/get_services_configuration/tasks/main.yaml b/tests/roles/get_services_configuration/tasks/main.yaml index 718638bd6..1704ff0ba 100644 --- a/tests/roles/get_services_configuration/tasks/main.yaml +++ b/tests/roles/get_services_configuration/tasks/main.yaml @@ -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 diff --git a/tests/roles/mariadb_copy/tasks/env_vars_src_ospdo.yaml b/tests/roles/mariadb_copy/tasks/env_vars_src_ospdo.yaml index 6ba631dbd..fb83565fd 100644 --- a/tests/roles/mariadb_copy/tasks/env_vars_src_ospdo.yaml +++ b/tests/roles/mariadb_copy/tasks/env_vars_src_ospdo.yaml @@ -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: diff --git a/tests/roles/mariadb_copy/templates/post_checks.bash b/tests/roles/mariadb_copy/templates/post_checks.bash index ce0991a98..3ef48f73e 100755 --- a/tests/roles/mariadb_copy/templates/post_checks.bash +++ b/tests/roles/mariadb_copy/templates/post_checks.bash @@ -6,7 +6,7 @@ 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 @@ -14,7 +14,7 @@ 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 \ @@ -28,19 +28,25 @@ 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 +# ensure the registered Compute service names have not changed +for CELL in $(echo $RENAMED_CELLS); do + unset PULL_OPENSTACK_CONFIGURATION_DATABASES + unset PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK + unset PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES + declare -A PULL_OPENSTACK_CONFIGURATION_DATABASES + declare -A PULL_OPENSTACK_CONFIGURATION_MYSQLCHECK_NOK + declare -A PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES + RCELL=$CELL + [ "$CELL" = "$DEFAULT_CELL_NAME" ] && RCELL=default set +u - . ~/.source_cloud_exported_variables_$CELL + . ~/.source_cloud_exported_variables_$RCELL set -u - RCELL=$CELL - [ "$CELL" = "default" ] && RCELL=$DEFAULT_CELL_NAME # ensure nova cells' db are extracted to separate db servers and renamed from nova to nova_cell - 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;") - diff -Z <(echo $novadb_svc_records) <(echo ${PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[$RCELL]}) && echo "OK" || echo "CHECK FAILED" + 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 "x$novadb_svc_records") <(echo "x${PULL_OPENSTACK_CONFIGURATION_NOVA_COMPUTE_HOSTNAMES[@]}") && echo "OK" || echo "CHECK FAILED" done diff --git a/tests/roles/mariadb_copy/templates/pre_checks.bash b/tests/roles/mariadb_copy/templates/pre_checks.bash index 2f7e089bc..83989701f 100755 --- a/tests/roles/mariadb_copy/templates/pre_checks.bash +++ b/tests/roles/mariadb_copy/templates/pre_checks.bash @@ -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 diff --git a/tests/roles/mariadb_copy/templates/restore_dbs.bash b/tests/roles/mariadb_copy/templates/restore_dbs.bash index da189ca25..49ac8cb22 100755 --- a/tests/roles/mariadb_copy/templates/restore_dbs.bash +++ b/tests/roles/mariadb_copy/templates/restore_dbs.bash @@ -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"