Skip to content

Commit 824d9ed

Browse files
committed
mariadb_copy: replace sleep workarounds with persistent pod retry pattern
Replace the temporary mariadb_client_timeout sleep and bgp wait pauses with a proper retry loop that polls the podified MariaDB via the already-running mariadb-copy-data pod, eliminating the race condition where commands were executed before the network was fully programmed. Also align pre_checks.bash with the docs by using oc rsh mariadb-copy-data instead of the ephemeral mariadb-client pod, and add a corresponding wait step to the docs procedure. Resolves: OSPRH-27386 Made-with: Cursor
1 parent ba2b031 commit 824d9ed

4 files changed

Lines changed: 30 additions & 15 deletions

File tree

docs_user/modules/proc_migrating-databases-to-mariadb-instances.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,22 @@ for CELL in $(echo $CELLS); do
223223
done
224224
----
225225

226+
. Wait for the `mariadb-copy-data` pod to reach the podified MariaDB:
227+
+
228+
----
229+
$ oc rsh mariadb-copy-data mysql -rsh "${PODIFIED_MARIADB_IP['super']}" \
230+
-uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'select 1;'
231+
----
232+
+
233+
[NOTE]
234+
====
235+
For BGP-enabled environments, this command might take a few moments to succeed while BGP routes are advertised and propagated through the network. The `mariadb-copy-data` pod needs to receive the route to the podified MariaDB IP address through BGP before it can establish a connection. If the command fails, wait a few seconds and retry. The connection should succeed once the BGP route advertisement is complete.
236+
237+
For IPv6 environments, this command might take a few moments to succeed while the network IPv6 stack completes its setup. If the command fails, wait a few seconds and retry.
238+
239+
For standard deployments, such as non-BGP deployments or IPv4 deployments, this command should succeed immediately.
240+
====
241+
226242
. Test the connection to the control plane upcall and cells databases:
227243
+
228244
----

tests/roles/common_defaults/defaults/main.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ octavia_adoption: true
228228
# dataplane_adoption and development_environment
229229
prelaunch_octavia_workload: false
230230

231-
# MariaDB client connection timeout in seconds
232-
# Related to OSPRH-18618
233-
mariadb_client_timeout: 0
234231
mariadbcheck: true
235232

236233
# Whether bgp is configured

tests/roles/mariadb_copy/tasks/main.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@
7373
retries: 25
7474
delay: "{{ mariadb_retry_delay }}"
7575

76-
# MariaDB client connection timeout in seconds
77-
# Related to OSPRH-18618
78-
- name: Add sleep time
79-
ansible.builtin.pause:
80-
seconds: "{{ mariadb_client_timeout }}"
81-
82-
- name: wait bgp
83-
when: bgp
84-
ansible.builtin.pause:
85-
seconds: 60
76+
- name: wait until podified MariaDB is reachable
77+
no_log: "{{ use_no_log }}"
78+
ansible.builtin.shell: |
79+
{{ oc_header }}
80+
{{ mariadb_copy_shell_vars_dst }}
81+
oc rsh mariadb-copy-data mysql -rsh "${PODIFIED_MARIADB_IP['super']}" \
82+
-uroot -p"${PODIFIED_DB_ROOT_PASSWORD['super']}" -e 'select 1;'
83+
register: _podified_db_check
84+
retries: 60
85+
delay: 3
86+
until: _podified_db_check.rc == 0
87+
changed_when: false
8688

8789
- name: check that the Galera database cluster(s) members are online and synced, for all cells
8890
no_log: "{{ use_no_log }}"

tests/roles/mariadb_copy/templates/pre_checks.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
# Test the connection to the control plane "upcall" and cells' databases
55
for CELL in $(echo "super $RENAMED_CELLS"); do
6-
oc run mariadb-client --image $MARIADB_IMAGE -i --rm --restart=Never -- \
7-
bash -c "sleep {{ mariadb_client_timeout }} && mysql -rsh \"${PODIFIED_MARIADB_IP[$CELL]}\" -uroot -p\"${PODIFIED_DB_ROOT_PASSWORD[$CELL]}\" -e 'SHOW databases;'"
6+
oc rsh mariadb-copy-data mysql -rsh "${PODIFIED_MARIADB_IP[$CELL]}" \
7+
-uroot -p"${PODIFIED_DB_ROOT_PASSWORD[$CELL]}" -e 'SHOW databases;'
88
done

0 commit comments

Comments
 (0)