Skip to content

Commit 9505890

Browse files
stuggiclaude
authored andcommitted
(multiple) Move Neutron-OVN sync before EDPM deployment
Run neutron-ovn-db-sync-util after the control plane is ready (Step 10) instead of after the EDPM deployment. This ensures OVN databases are populated before ovn-controller on dataplane nodes reconnects, preventing data plane outage from stale or empty databases. Matches the reordering in dev-docs backup-restore user-guide.md. Also fixes the selector for the node-agent pods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent 3c09abf commit 9505890

3 files changed

Lines changed: 72 additions & 69 deletions

File tree

roles/cifmw_backup_restore/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ actions: **backup**, **restore**, and **cleanup**.
99
(via CSI snapshots) and cluster resources.
1010
- **restore** — performs an ordered Velero restore sequence (PVCs,
1111
foundation, infrastructure, control plane, Galera, optional OVN file restore,
12-
full control plane resume, dataplane, EDPM), then Neutron–OVN verification and
13-
sync (**log** mode, then **repair**, matching the backup-restore user guide Step 12).
12+
full control plane resume, Neutron–OVN sync, dataplane, EDPM), with
13+
Neutron–OVN verification and sync (**log** mode, then **repair**) run before
14+
the EDPM deployment to prevent data plane outage (matching user guide Step 10).
1415
- **cleanup** — tears down dataplane and control-plane resources so the
1516
namespace is ready for a fresh restore.
1617

@@ -27,7 +28,7 @@ OpenShift cluster.
2728
* `cifmw_backup_restore_namespace`: (String) Target OpenStack namespace. Defaults to `openstack`.
2829
* `cifmw_backup_restore_oadp_namespace`: (String) Namespace where Velero/OADP is running. Defaults to `openshift-adp`.
2930
* `cifmw_backup_restore_auto_ack`: (Boolean) Skip interactive pause prompts when `true`. Defaults to `false`.
30-
* `cifmw_backup_restore_ovn_db`: (Boolean) When `true` (default), the **backup** path labels OVN NB/SB PVCs and runs `ovsdb-client` backup before the OADP PVC backup, and the **restore** path runs OVN NB/SB file restore after Galera (when timestamped files exist on the PVC) before resuming the full control plane. Set to `false` to skip both; post-EDPM `neutron-ovn-db-sync` still runs when OVN files were not backed up.
31+
* `cifmw_backup_restore_ovn_db`: (Boolean) When `true` (default), the **backup** path labels OVN NB/SB PVCs and runs `ovsdb-client` backup before the OADP PVC backup, and the **restore** path runs OVN NB/SB file restore after Galera (when timestamped files exist on the PVC) before resuming the full control plane. Set to `false` to skip both; `neutron-ovn-db-sync` still runs (before EDPM) when OVN files were not backed up.
3132
* `cifmw_backup_restore_ovn_db_ready_timeout`: (String) Timeout for `oc wait` on OVN database pods during OVN backup/restore. Defaults to `5m`.
3233

3334
### Backup
@@ -51,7 +52,7 @@ OpenShift cluster.
5152
* `cifmw_backup_restore_restore_content`: (String) Content flag passed to `restore_galera` (`--content`). Defaults to `data`.
5253
* `cifmw_backup_restore_edpm_deploy_timeout`: (String) Timeout for `oc wait` on the post-restore EDPM deployment. Defaults to `40m`.
5354
* `cifmw_backup_restore_pin_pvcs`: (Boolean) Enable PVC-to-node pinning during restore for WaitForFirstConsumer storage classes. Defaults to `false`.
54-
* Post-EDPM **Neutron–OVN** steps follow [user guide Step 12](https://github.com/openstack-k8s-operators/dev-docs/blob/main/backup-restore/user-guide.md#step-12-verify-and-sync-neutron-to-ovn): run `neutron-ovn-db-sync-util` in `log` mode first (`neutron-dist.conf`, `neutron.conf`, `neutron.conf.d`). **Repair** runs if `cifmw_backup_restore_ovn_db` is `false` (no OVN NB/SB file backup was taken), or if log-mode stdout/stderr contains a `WARNING` line—Neutron reports drift that way while still exiting 0. If OVN file backup/restore was enabled and log output has no `WARNING` lines, repair is skipped as redundant.
55+
* **Neutron–OVN** sync runs after the control plane is ready but before EDPM deployment, following [user guide Step 10](https://github.com/openstack-k8s-operators/dev-docs/blob/main/backup-restore/user-guide.md#step-10-verify-and-sync-neutron-to-ovn): `neutron-ovn-db-sync-util` runs in `log` mode first (`neutron-dist.conf`, `neutron.conf`, `neutron.conf.d`). **Repair** runs if `cifmw_backup_restore_ovn_db` is `false` (no OVN NB/SB file backup was taken), or if log-mode stdout/stderr contains a `WARNING` line—Neutron reports drift that way while still exiting 0. If OVN file backup/restore was enabled and log output has no `WARNING` lines, repair is skipped as redundant.
5556

5657
### End-to-end orchestration (e2e.yml)
5758

roles/cifmw_backup_restore/tasks/restore.yml

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
# Restores an OpenStack control plane from OADP backups using ordered
2020
# Velero Restore CRs, Galera restore, optional OVN NB/SB file restore,
21-
# then staged ControlPlane resume, dataplane, EDPM, and Neutron–OVN sync.
21+
# then staged ControlPlane resume, Neutron–OVN sync, dataplane, and EDPM.
2222

2323
- name: Validate backup_timestamp parameter
2424
ansible.builtin.fail:
@@ -535,7 +535,69 @@
535535
when: cifmw_backup_restore_baremetal | bool
536536

537537
# ========================================
538-
# Step 10: Restore DataPlane (Order 60)
538+
# Step 10: Verify and sync Neutron to OVN
539+
# ========================================
540+
# Run after neutron is ready but before EDPM deployment so that
541+
# ovn-controller on dataplane nodes reconnects to populated OVN DBs,
542+
# preventing data plane outage from stale/empty databases.
543+
# Log mode does not change exit code for drift (Neutron logs drift as WARNING lines).
544+
# Repair runs if OVN file backup was skipped, or if log output contains WARNING drift.
545+
# Ref: https://github.com/openstack-k8s-operators/dev-docs/blob/main/backup-restore/user-guide.md#step-10-verify-and-sync-neutron-to-ovn
546+
- name: Verify Neutron vs OVN (neutron-ovn-db-sync-util log mode)
547+
ansible.builtin.shell: |
548+
set -o pipefail
549+
oc exec -n {{ cifmw_backup_restore_namespace }} -c neutron-api deploy/neutron -- \
550+
neutron-ovn-db-sync-util \
551+
--config-file /usr/share/neutron/neutron-dist.conf \
552+
--config-file /etc/neutron/neutron.conf \
553+
--config-dir /etc/neutron/neutron.conf.d \
554+
--ovn-neutron_sync_mode=log \
555+
--debug
556+
register: _neutron_ovn_sync_log
557+
changed_when: false
558+
559+
- name: Decide whether Neutron–OVN repair sync is required
560+
ansible.builtin.set_fact:
561+
_neutron_ovn_needs_repair: >-
562+
{{
563+
(not (cifmw_backup_restore_ovn_db | bool))
564+
or (
565+
(cifmw_backup_restore_ovn_db | bool)
566+
and (
567+
((_neutron_ovn_sync_log.stdout | default('')) ~ (_neutron_ovn_sync_log.stderr | default('')))
568+
| regex_search('(?i)\bWARNING\b') is not none
569+
)
570+
)
571+
}}
572+
573+
- name: Report Neutron–OVN repair decision
574+
ansible.builtin.debug:
575+
msg: >-
576+
neutron-ovn-db-sync repair:
577+
{{ 'running' if _neutron_ovn_needs_repair | bool else 'skipped' }}.
578+
{% if not (cifmw_backup_restore_ovn_db | bool) %}
579+
Reason: cifmw_backup_restore_ovn_db is false (no OVN NB/SB file backup; OVN must be repopulated from Neutron).
580+
{% elif _neutron_ovn_needs_repair | bool %}
581+
Reason: log-mode output contained WARNING lines (Neutron-reported drift vs OVN).
582+
{% else %}
583+
Reason: OVN file backup/restore was used and log-mode output had no WARNING lines.
584+
{% endif %}
585+
586+
- name: Sync Neutron state to OVN database (repair mode)
587+
ansible.builtin.shell: |
588+
set -o pipefail
589+
oc exec -n {{ cifmw_backup_restore_namespace }} -c neutron-api deploy/neutron -- \
590+
neutron-ovn-db-sync-util \
591+
--config-file /usr/share/neutron/neutron-dist.conf \
592+
--config-file /etc/neutron/neutron.conf \
593+
--config-dir /etc/neutron/neutron.conf.d \
594+
--ovn-neutron_sync_mode=repair \
595+
--debug
596+
when: _neutron_ovn_needs_repair | bool
597+
changed_when: true
598+
599+
# ========================================
600+
# Step 11: Restore DataPlane (Order 60)
539601
# ========================================
540602
- name: Render dataplane restore
541603
ansible.builtin.template:
@@ -555,10 +617,10 @@
555617
ansible.builtin.include_tasks: wait_for_restore.yml
556618
vars:
557619
_restore_name: "openstack-restore-60-dataplane-{{ _restore_suffix }}"
558-
_step_name: "Step 10 (DataPlane restore)"
620+
_step_name: "Step 11 (DataPlane restore)"
559621

560622
# ========================================
561-
# Step 11: EDPM Deployment
623+
# Step 12: EDPM Deployment
562624
# ========================================
563625
- name: Get DataPlaneNodeSet names
564626
ansible.builtin.shell: |
@@ -602,66 +664,6 @@
602664
--timeout={{ cifmw_backup_restore_edpm_deploy_timeout }}
603665
when: _nodeset_names.stdout != ""
604666

605-
# ========================================
606-
# Step 12: Verify and sync Neutron to OVN (user-guide backup-restore Step 12)
607-
# ========================================
608-
# Run after EDPM so compute ovn-controller agents reconnect to the SB DB first.
609-
# Log mode does not change exit code for drift (Neutron logs drift as WARNING lines).
610-
# Repair runs if OVN file backup was skipped, or if log output contains WARNING drift.
611-
# Ref: https://github.com/openstack-k8s-operators/dev-docs/blob/main/backup-restore/user-guide.md#step-12-verify-and-sync-neutron-to-ovn
612-
- name: Verify Neutron vs OVN (neutron-ovn-db-sync-util log mode)
613-
ansible.builtin.shell: |
614-
set -o pipefail
615-
oc exec -n {{ cifmw_backup_restore_namespace }} -c neutron-api deploy/neutron -- \
616-
neutron-ovn-db-sync-util \
617-
--config-file /usr/share/neutron/neutron-dist.conf \
618-
--config-file /etc/neutron/neutron.conf \
619-
--config-dir /etc/neutron/neutron.conf.d \
620-
--ovn-neutron_sync_mode=log \
621-
--debug
622-
register: _neutron_ovn_sync_log
623-
changed_when: false
624-
625-
- name: Decide whether Neutron–OVN repair sync is required
626-
ansible.builtin.set_fact:
627-
_neutron_ovn_needs_repair: >-
628-
{{
629-
(not (cifmw_backup_restore_ovn_db | bool))
630-
or (
631-
(cifmw_backup_restore_ovn_db | bool)
632-
and (
633-
((_neutron_ovn_sync_log.stdout | default('')) ~ (_neutron_ovn_sync_log.stderr | default('')))
634-
| regex_search('(?i)\bWARNING\b') is not none
635-
)
636-
)
637-
}}
638-
639-
- name: Report Neutron–OVN repair decision
640-
ansible.builtin.debug:
641-
msg: >-
642-
neutron-ovn-db-sync repair:
643-
{{ 'running' if _neutron_ovn_needs_repair | bool else 'skipped' }}.
644-
{% if not (cifmw_backup_restore_ovn_db | bool) %}
645-
Reason: cifmw_backup_restore_ovn_db is false (no OVN NB/SB file backup; OVN must be repopulated from Neutron).
646-
{% elif _neutron_ovn_needs_repair | bool %}
647-
Reason: log-mode output contained WARNING lines (Neutron-reported drift vs OVN).
648-
{% else %}
649-
Reason: OVN file backup/restore was used and log-mode output had no WARNING lines.
650-
{% endif %}
651-
652-
- name: Sync Neutron state to OVN database (repair mode)
653-
ansible.builtin.shell: |
654-
set -o pipefail
655-
oc exec -n {{ cifmw_backup_restore_namespace }} -c neutron-api deploy/neutron -- \
656-
neutron-ovn-db-sync-util \
657-
--config-file /usr/share/neutron/neutron-dist.conf \
658-
--config-file /etc/neutron/neutron.conf \
659-
--config-dir /etc/neutron/neutron.conf.d \
660-
--ovn-neutron_sync_mode=repair \
661-
--debug
662-
when: _neutron_ovn_needs_repair | bool
663-
changed_when: true
664-
665667
# ========================================
666668
# Cleanup and Summary
667669
# ========================================

roles/openshift_adp/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
kind: Pod
177177
namespace: "{{ cifmw_openshift_adp_namespace }}"
178178
label_selectors:
179-
- app.kubernetes.io/name=node-agent
179+
- role=node-agent
180180
wait: true
181181
wait_timeout: 300
182182
wait_condition:

0 commit comments

Comments
 (0)