Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospdo db migration docs #715

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

pinikomarov
Copy link
Contributor

add db migration mysql client setup diffs

Related patches :
#708

Jira: https://issues.redhat.com/browse/OSPRH-6618

@pinikomarov pinikomarov marked this pull request as ready for review November 14, 2024 12:21
@@ -6,6 +6,18 @@ ifdef::context[:parent-context: {context}]

= Migrating databases to the control plane

// Set OSPdO different values to be used in same commands
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pinikomarov Is this text a prerequisite that OSPdO customers need to do before migrating databases to the control plane?
And why is this text hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a comment just to explain the ifeval conditionals below it can be dropped, unless needed as an logic explanation

@@ -16,9 +28,9 @@ include::../modules/proc_configuring-a-ceph-backend.adoc[leveloffset=+1]

include::../modules/proc_stopping-openstack-services.adoc[leveloffset=+1]

include::../modules/proc_migrating-databases-to-mariadb-instances.adoc[leveloffset=+1]
include::../modules/proc_migrating-databases-to-mariadb-instances.adoc[@, leveloffset=+1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this symbol for?
Same question on the link below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an error on my part I thought it was needed, so the vars pass to the included files, I'll remove that

@@ -126,6 +126,9 @@ endif::[]
ifeval::["{build}" == "downstream"]
$(cat <path_to_SSH_key> | base64 | sed \'s/^/ /')
endif::[]
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
$(oc exec -n ${OSPDO_NAMESPACE} -t openstackclient openstackclient -- cat /home/cloud-admin/.ssh/id_rsa | base64 | sed 's/^/ /')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$(oc exec -n ${OSPDO_NAMESPACE} -t openstackclient openstackclient -- cat /home/cloud-admin/.ssh/id_rsa | base64 | sed 's/^/ /')
$(oc exec -n $<ospdo_namespace> -t openstackclient openstackclient -- cat /home/cloud-admin/.ssh/id_rsa | base64 | sed 's/^/ /')

Customers will need to replace <ospdo_namespace> with their own namespace, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right

$ oc rsh mariadb-copy-data << EOF
$ oc rsh -n {pod_ns} mariadb-copy-data << EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is oc rsh -n {pod_ns} mariadb-copy-data << EOF supposed to be specific to OSPdO only? Shouldn't oc rsh mariadb-copy-data << EOF still remain for non-OSPdO deployments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the usage of -n namespace should not cause any difference in regular adoptions, since that's the default namespace users can use or omit that.
I'm adding and making the namespace a variables here to make as little changes as possible to the docs, so that when using ospdo it's explicit where we're running actions on.

Comment on lines 36 to 40
+
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
get the ocp master holding the osp controller:
oc get vmi -n ${ospdo_namespace} -o jsonpath='{.items[0].metadata.labels.kubevirt\.io/nodeName}'
endif::[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
get the ocp master holding the osp controller:
oc get vmi -n ${ospdo_namespace} -o jsonpath='{.items[0].metadata.labels.kubevirt\.io/nodeName}'
endif::[]
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
. Get the {OpenShiftShort} master node that contains the {OpenStackShort} Controller:
+
----
$ oc get vmi -n $<ospdo_namespace> -o jsonpath='{.items[0].metadata.labels.kubevirt\.io/nodeName}'
----
+
* Replace `<ospdo_namespace>` with your OSPdO namespace.
endif::[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -44,7 +48,7 @@ apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: ovn-data-cert
namespace: openstack
namespace: {pod_ns}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pod_ns = pod namespace?
Is this an OSPdO-specific change, or one that applies to a typical deployment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the use of namespace is to be explcit in our actions , so that in ospdo adoption it's clear where (rhoso or ospdo) we're running the pods and commands against.
In regular adoption it can be used and it would make either no change from the default namespace used by rhoso, or explicitly define that the user is running in the rhoso namespace, so that param only adds specificity not error if used, as in rhoso the default namespace is used anyway whether the user specifies it or not

k8s.v1.cni.cncf.io/networks: internalapi
endif::[]
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
'[{"name": "internalapi-static", "namespace": ${OSPDO_NAMESPACE}, "ips": ["<internalapi-static-ips>"]}]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'[{"name": "internalapi-static", "namespace": ${OSPDO_NAMESPACE}, "ips": ["<internalapi-static-ips>"]}]'
'[{"name": "internalapi-static", "namespace": $<ospdo_namespace>, "ips": ["<internalapi-static-ips>"]}]'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -69,10 +74,19 @@ metadata:
name: ovn-copy-data
annotations:
openshift.io/scc: anyuid
ifeval::["{OpenStackPreviousInstaller}" != "director_operator"]
k8s.v1.cni.cncf.io/networks: internalapi
Copy link
Contributor

@klgill klgill Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 78 only applies to OSPdO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, meaning that line:
'[{"name": "internalapi-static", "namespace": ${OSPDO_NAMESPACE}, "ips": [""]}]'
is only used when run in an OSPdO adoption scenario and is specific to access resources in ospdo env.

@@ -103,7 +117,7 @@ EOF
. Wait for the pod to be ready:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. Wait for the pod to be ready:
ifeval::["{OpenStackPreviousInstaller}" == "director_operator"]
+
* Replace `<ocp_node_holding_controller>` with the {OpenStackShort} node that contains the Controller.
endif::[]
. Wait for the pod to be ready:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -103,7 +117,7 @@ EOF
. Wait for the pod to be ready:
+
----
$ oc wait --for=condition=Ready pod/ovn-copy-data --timeout=30s
$ oc wait --for=condition=Ready -n{pod_ns} pod/ovn-copy-data --timeout=30s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc wait --for=condition=Ready -n{pod_ns} pod/ovn-copy-data --timeout=30s
$ oc wait --for=condition=Ready -n {pod_ns} pod/ovn-copy-data --timeout=30s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 210 to 211
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
$ oc exec -n $<rhoso_namespace> ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
$ oc exec -n $<rhoso_namespace> ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

$ oc exec ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
$ oc exec ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
$ oc exec -n ${RHOSO_NAMESPACE} ovn-copy-data -- bash -c "ovsdb-client restore tcp:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
----

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+
* Replace `<rhoso_namespace>` with the namespace of your {rhos_acro} deployment.

Comment on lines 12 to 14
// Set OSPdO different values to be used in same commands
// When there is an OSPdO source env, some commands run on RHOSO namespace
// and some on the OSPdO namespace with some added, different parameteres
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this text hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an explanation about the logic below it , It can be removed

@@ -42,26 +52,98 @@ $ sudo grep -rI 'listen mysql' -A10 /var/lib/config-data/puppet-generated/ | gre
. 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 ${MARIADB_CLIENT_ANNOTATIONS} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
export PULL_OPENSTACK_CONFIGURATION_DATABASES=$(oc run mariadb-client {pod_annotations} -q --image ${MARIADB_IMAGE} -i --rm --restart=Never -- \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{pod_annotations} applies to all deployments, not just OSPdO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to ospdo deployments , as the ifeval above states. the rhoso deployents should have this text(literal): ${MARIADB_CLIENT_ANNOTATIONS}

CONTROLLER1_SSH="oc -n $OSPDO_NAMESPACE rsh -c openstackclient openstackclient ssh controller-0.ctlplane"
export CONTROLLER1_SSH
----
* With OSPdO, the mariadb-client needs to run on the same OCP node where the OSP Controller is running. In addition, the internalapi-static network needs to be attached to the pod.
Copy link
Contributor

@klgill klgill Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* With OSPdO, the mariadb-client needs to run on the same OCP node where the OSP Controller is running. In addition, the internalapi-static network needs to be attached to the pod.
* 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 72 to 75
. 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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. 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}"
. 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}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 76 to 89
----
. Get the name of the OCP node where the OSP Controller VM is running
----
CONTROLLER_NODE=$(oc get vmi -ojson | jq -r '.items[0].status.nodeName')
export CONTROLLER_NODE
SOURCE_OVN_OVSDB_IP=172.17.0.160 # TODO - get this from the source OVN DB
export SOURCE_OVN_OVSDB_IP

SOURCE_DB_ROOT_PASSWORD=$(grep <"${PASSWORD_FILE}" ' MysqlRootPassword:' | awk -F ': ' '{ print $2; }') || {
echo "Failed to get the source DB root password"
exit 1
}
export SOURCE_DB_ROOT_PASSWORD
----
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
----
. Get the name of the OCP node where the OSP Controller VM is running
----
CONTROLLER_NODE=$(oc get vmi -ojson | jq -r '.items[0].status.nodeName')
export CONTROLLER_NODE
SOURCE_OVN_OVSDB_IP=172.17.0.160 # TODO - get this from the source OVN DB
export SOURCE_OVN_OVSDB_IP
SOURCE_DB_ROOT_PASSWORD=$(grep <"${PASSWORD_FILE}" ' MysqlRootPassword:' | awk -F ': ' '{ print $2; }') || {
echo "Failed to get the source DB root password"
exit 1
}
export SOURCE_DB_ROOT_PASSWORD
----
----
. Get the name of the {OpenShiftShort} node where the {OpenStackShort} Controller virtual machine is running:
+
----
$ CONTROLLER_NODE=$(oc get vmi -ojson | jq -r '.items[0].status.nodeName')
export CONTROLLER_NODE
SOURCE_OVN_OVSDB_IP=172.17.0.160 # TODO - get this from the source OVN DB
export SOURCE_OVN_OVSDB_IP
SOURCE_DB_ROOT_PASSWORD=$(grep <"${PASSWORD_FILE}" ' MysqlRootPassword:' | awk -F ': ' '{ print $2; }') || {
echo "Failed to get the source DB root password"
exit 1
}
export SOURCE_DB_ROOT_PASSWORD
----

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 90 to 92
. In OSPdO, the mysql service iP can be found in the tripleo-exports-default ConfigMap, section ctlplane-export.yaml
----
cpexport=$(oc -n "${OSPDO_NAMESPACE}" get cm tripleo-exports-default -o json | jq -r '.data["ctlplane-export.yaml"]')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. In OSPdO, the mysql service iP can be found in the tripleo-exports-default ConfigMap, section ctlplane-export.yaml
----
cpexport=$(oc -n "${OSPDO_NAMESPACE}" get cm tripleo-exports-default -o json | jq -r '.data["ctlplane-export.yaml"]')
. 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"]')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

. Export the shell variables for the following outputs and test the connection to the {OpenStackShort} database:
+
----
PULL_OPENSTACK_CONFIGURATION_DATABASES="$(oc run mariadb-client -q --image "${MARIADB_IMAGE}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the "$" precede "PULL_OPENSTACK_CONFIGURATION_DATABASES..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor

@klgill klgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added suggestions, and there are some questions that need to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants