Skip to content

Commit 00d1714

Browse files
committed
[WIP][ovn] switch backup/restore procedure
With backup/restore uuids for the records are being changed and that's result into geneve tunnels to be disabled with the compute nodes and thus centralized SNAT traffic is impacted when ovn_controller are started post adoption on the networker nodes. So switch to use full db files for restoration after converting the DBs to standalone. With this also cleaned the helper pod and other resources. Resolves: #OSPRH-29914 Signed-off-by: Yatin Karel <ykarel@redhat.com>
1 parent 7c98be1 commit 00d1714

7 files changed

Lines changed: 80 additions & 179 deletions

File tree

tests/roles/control_plane_rollback/tasks/main.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
158158
oc delete --ignore-not-found=true --wait=false pod mariadb-copy-data
159159
oc delete --ignore-not-found=true --wait=false pvc mariadb-data
160-
oc delete --ignore-not-found=true --wait=false pod ovn-copy-data
161160
oc delete --ignore-not-found=true secret osp-secret
162161
163162
- name: verify that the source control plane is responding

tests/roles/ovn_adoption/defaults/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ ovs_db_patch: |
2020
template:
2121
ovnDBCluster:
2222
ovndbcluster-nb:
23-
replicas: 3
23+
replicas: 1
2424
dbType: NB
2525
storageRequest: 10G
2626
networkAttachment: internalapi
2727
ovndbcluster-sb:
28-
replicas: 3
28+
replicas: 1
2929
dbType: SB
3030
storageRequest: 10G
3131
networkAttachment: internalapi
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
- name: delete adoption helper pod and pvc
2-
ansible.builtin.shell: |
3-
{{ shell_header }}
4-
{{ oc_header }}
5-
oc delete --ignore-not-found=true pod ovn-copy-data
6-
oc delete --ignore-not-found=true certificate ovn-data-cert
7-
oc delete --ignore-not-found=true secret ovn-data-cert
8-
{% if storage_reclaim_policy.lower() == "delete" %}oc delete pvc --ignore-not-found=true ovn-data{% endif %}
1+
---
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
# Cluster-to-standalone conversion for OVN database adoption
3+
4+
- name: convert OVN databases to standalone and fetch to ansible controller
5+
no_log: "{{ use_no_log }}"
6+
ansible.builtin.shell: |
7+
{{ shell_header }}
8+
{{ ovn_copy_shell_vars }}
9+
10+
# Create working directory on controller
11+
$CONTROLLER1_SSH sudo mkdir -p /tmp/ovn_standalone_conversion
12+
13+
# Convert cluster databases to standalone on the controller
14+
$CONTROLLER1_SSH sudo ovsdb-tool cluster-to-standalone /tmp/ovn_standalone_conversion/ovnnb_db.db /var/lib/openvswitch/ovn/ovnnb_db.db
15+
$CONTROLLER1_SSH sudo ovsdb-tool cluster-to-standalone /tmp/ovn_standalone_conversion/ovnsb_db.db /var/lib/openvswitch/ovn/ovnsb_db.db
16+
17+
# Set permissions for copying
18+
$CONTROLLER1_SSH sudo chmod 644 /tmp/ovn_standalone_conversion/ovn*.db
19+
20+
# Create local temp directory
21+
mkdir -p /tmp/ovn_adoption_dbs
22+
23+
# Use scp like other parts of the codebase
24+
CONTROLLER1_SCP=$(echo "$CONTROLLER1_SSH" | sed 's/^ssh/scp/')
25+
26+
echo "Copying NB database to ansible controller..."
27+
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnnb_db.db /tmp/ovn_adoption_dbs/
28+
29+
echo "Copying SB database to ansible controller..."
30+
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnsb_db.db /tmp/ovn_adoption_dbs/
31+
32+
# Cleanup on controller
33+
$CONTROLLER1_SSH sudo rm -rf /tmp/ovn_standalone_conversion
34+
35+
echo "Successfully converted and copied databases to ansible controller"
36+
37+
- name: copy standalone databases to OVN database pods
38+
ansible.builtin.shell: |
39+
{{ shell_header }}
40+
{{ oc_header }}
41+
42+
echo "Copying standalone databases directly to OVN database pods..."
43+
44+
# Copy NB database to the NB pod
45+
oc cp /tmp/ovn_adoption_dbs/ovnnb_db.db ovsdbserver-nb-0:/etc/ovn/ovnnb_db.db
46+
47+
# Copy SB database to the SB pod
48+
oc cp /tmp/ovn_adoption_dbs/ovnsb_db.db ovsdbserver-sb-0:/etc/ovn/ovnsb_db.db
49+
50+
echo "Database files copied successfully to pods"
51+
52+
- name: restart OVN database pods to load standalone databases
53+
ansible.builtin.shell: |
54+
{{ shell_header }}
55+
{{ oc_header }}
56+
57+
echo "Restarting OVN database pods to load standalone databases..."
58+
59+
# Restart NB database pod
60+
oc delete pod -l service=ovsdbserver-nb
61+
oc wait --for=condition=Ready pod -l service=ovsdbserver-nb --timeout=180s
62+
63+
# Restart SB database pod
64+
oc delete pod -l service=ovsdbserver-sb
65+
oc wait --for=condition=Ready pod -l service=ovsdbserver-sb --timeout=180s
66+
67+
echo "OVN database pods restarted successfully"
68+
69+
- name: cleanup temporary files
70+
ansible.builtin.shell: |
71+
# Remove temporary files from ansible controller
72+
rm -f /tmp/ovn_adoption_dbs/ovn*.db
73+
rmdir /tmp/ovn_adoption_dbs 2>/dev/null || true
74+
75+
echo "Temporary files cleaned up"

tests/roles/ovn_adoption/tasks/main.yaml

Lines changed: 2 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -61,94 +61,6 @@
6161
CONTROLLER3_SSH="{{ controller3_ssh }}"
6262
when: not ospdo_src| bool
6363

64-
- name: start an adoption helper pod
65-
vars:
66-
internalapi_default_nad: >-
67-
{% if not (bgp | bool) -%}
68-
'[{"name":"internalapi","namespace":"openstack"}]'
69-
{% else -%}
70-
'[{"name":"internalapi","namespace":"openstack","default-route":["{{ internalapi_prefix | default('172.17.0') }}.1"]}]'
71-
{% endif -%}
72-
ansible.builtin.shell: |-
73-
{{ shell_header }}
74-
{{ oc_header }}
75-
{{ ovn_copy_shell_vars }}
76-
77-
oc apply -f - <<EOF
78-
---
79-
apiVersion: cert-manager.io/v1
80-
kind: Certificate
81-
metadata:
82-
name: ovn-data-cert
83-
spec:
84-
commonName: ovn-data-cert
85-
secretName: ovn-data-cert
86-
issuerRef:
87-
name: rootca-internal
88-
---
89-
apiVersion: v1
90-
kind: PersistentVolumeClaim
91-
metadata:
92-
name: ovn-data
93-
labels:
94-
app: adoption
95-
spec:
96-
storageClassName: $STORAGE_CLASS
97-
accessModes:
98-
- ReadWriteOnce
99-
resources:
100-
requests:
101-
storage: 10Gi
102-
---
103-
apiVersion: v1
104-
kind: Pod
105-
metadata:
106-
name: ovn-copy-data
107-
annotations:
108-
openshift.io/scc: anyuid
109-
k8s.v1.cni.cncf.io/networks: {{ copy_pods_custom_networks | default(internalapi_default_nad) }}
110-
labels:
111-
app: adoption
112-
spec:
113-
{{ copy_pods_custom_spec|default('') }}
114-
containers:
115-
- image: $OVSDB_IMAGE
116-
command: [ "sh", "-c", "sleep infinity"]
117-
name: adoption
118-
volumeMounts:
119-
- mountPath: /backup
120-
name: ovn-data
121-
- mountPath: /etc/pki/tls/misc
122-
name: ovn-data-cert
123-
readOnly: true
124-
securityContext:
125-
allowPrivilegeEscalation: false
126-
capabilities:
127-
drop: ALL
128-
runAsNonRoot: true
129-
seccompProfile:
130-
type: RuntimeDefault
131-
volumes:
132-
- name: ovn-data
133-
persistentVolumeClaim:
134-
claimName: ovn-data
135-
- name: ovn-data-cert
136-
secret:
137-
secretName: ovn-data-cert
138-
EOF
139-
changed_when: true
140-
notify: delete adoption helper pod and pvc
141-
142-
- name: wait for the pod to come up
143-
ansible.builtin.shell: |
144-
{{ shell_header }}
145-
{{ oc_header }}
146-
oc wait --for condition=Ready pod/ovn-copy-data --timeout=30s
147-
register: ovn_data_pod_result
148-
until: ovn_data_pod_result is success
149-
retries: 2
150-
delay: "{{ ovn_retry_delay }}"
151-
15264
- name: stop northd service
15365
no_log: "{{ use_no_log }}"
15466
ansible.builtin.shell: |
@@ -203,73 +115,8 @@
203115
ansible.builtin.pause:
204116
seconds: 60
205117

206-
- name: dump OVN databases using tcp connection
207-
no_log: "{{ use_no_log }}"
208-
ansible.builtin.shell: |
209-
{{ shell_header }}
210-
{{ oc_header }}
211-
{{ ovn_copy_shell_vars }}
212-
213-
oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db"
214-
oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db"
215-
when: enable_tlse|bool is false
216-
217-
- name: dump OVN databases using ssl connection
218-
no_log: "{{ use_no_log }}"
219-
ansible.builtin.shell: |
220-
{{ shell_header }}
221-
{{ oc_header }}
222-
{{ ovn_copy_shell_vars }}
223-
224-
oc exec ovn-copy-data -- bash -c "ovsdb-client backup --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db"
225-
oc exec ovn-copy-data -- bash -c "ovsdb-client backup --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db"
226-
when: enable_tlse|bool
227-
228-
- name: upgrade OVN databases to the latest schema from podified ovsdb-servers
229-
no_log: "{{ use_no_log }}"
230-
ansible.builtin.shell: |
231-
{{ shell_header }}
232-
{{ oc_header }}
233-
{{ ovn_copy_shell_vars }}
234-
235-
oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema"
236-
oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema"
237-
when: enable_tlse|bool is false
238-
239-
- name: upgrade OVN databases to the latest schema from podified ovsdb-servers (tls)
240-
no_log: "{{ use_no_log }}"
241-
ansible.builtin.shell: |
242-
{{ shell_header }}
243-
{{ oc_header }}
244-
{{ ovn_copy_shell_vars }}
245-
246-
oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key \
247-
--certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema"
248-
oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key \
249-
--certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema"
250-
when: enable_tlse|bool
251-
252-
- name: restore OVN database backup to podified ovsdb-servers - {{ item }}
253-
vars:
254-
ovn_db_ip: "{{ 'PODIFIED_OVSDB_NB_IP' if item == 'nb' else 'PODIFIED_OVSDB_SB_IP' }}"
255-
ovn_db_port: "{{ '6641' if item == 'nb' else '6642' }}"
256-
ovn_db_file: "ovs-{{ item }}.db"
257-
tls_opts: "{{ '--ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt' if enable_tlse | bool else '' }}"
258-
proto: "{{ 'ssl' if enable_tlse | bool else 'tcp' }}"
259-
no_log: "{{ use_no_log }}"
260-
ansible.builtin.shell: |
261-
{{ shell_header }}
262-
{{ oc_header }}
263-
{{ ovn_copy_shell_vars }}
264-
265-
oc exec ovn-copy-data -- bash -c "ovsdb-client -v restore {{ tls_opts }} {{ proto }}:${{ ovn_db_ip }}:{{ ovn_db_port }} < /backup/{{ ovn_db_file }}"
266-
register: podified_ovn_db_restore
267-
until: podified_ovn_db_restore is success
268-
retries: 5
269-
delay: "{{ ovn_retry_delay }}"
270-
loop:
271-
- nb
272-
- sb
118+
- name: migrate OVN databases using cluster-to-standalone conversion
119+
ansible.builtin.include_tasks: cluster_to_standalone.yaml
273120

274121
- name: deploy podified OVN northd service to keep databases in sync
275122
ansible.builtin.shell: |

tests/roles/ovn_adoption/tasks/ovn_ospdo_src_vars.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,3 @@
3333
CONTROLLER1_SSH="{{ controller1_ssh }}"
3434
CONTROLLER2_SSH="echo ospdo src env, skipping on controller-1 "
3535
CONTROLLER3_SSH="echo ospdo src env ,skipping on controller-2 "
36-
37-
- name: create ovn-data-cert secret
38-
ansible.builtin.shell: |
39-
oc apply -f - <<EOF
40-
---
41-
apiVersion: v1
42-
kind: Secret
43-
metadata:
44-
name: ovn-data-cert
45-
namespace: {{ director_namespace }}
46-
type: Opaque
47-
EOF

tests/roles/pcp_cleanup/tasks/main.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# Delete Adoption helper pods
1919
oc delete --ignore-not-found=true --wait=false pod mariadb-copy-data
2020
oc delete --ignore-not-found=true --wait=false pvc mariadb-data
21-
oc delete --ignore-not-found=true --wait=false pod ovn-copy-data
2221
2322
# Delete secrets
2423
for secret in $(oc get secrets -o name); do

0 commit comments

Comments
 (0)