diff --git a/ansible/roles/ovn-db/defaults/main.yml b/ansible/roles/ovn-db/defaults/main.yml index a5d301ad5e..c6b314c6b0 100644 --- a/ansible/roles/ovn-db/defaults/main.yml +++ b/ansible/roles/ovn-db/defaults/main.yml @@ -94,3 +94,5 @@ ovn_sb_command: >- --db-sb-pidfile=/run/ovn/ovnsb_db.pid --db-sb-file=/var/lib/openvswitch/ovn-sb/ovnsb.db --ovn-sb-logfile=/var/log/kolla/openvswitch/ovn-sb-db.log +# Workaround: pause after restarting containers to allow for leader election. +ovn_leader_election_pause: 5 diff --git a/ansible/roles/ovn-db/tasks/bootstrap-db.yml b/ansible/roles/ovn-db/tasks/bootstrap-db.yml index 2763005a9b..deb4e0d5bb 100644 --- a/ansible/roles/ovn-db/tasks/bootstrap-db.yml +++ b/ansible/roles/ovn-db/tasks/bootstrap-db.yml @@ -1,4 +1,14 @@ --- +# NOTE(mgoddard): After OVN DB leader restarts there is a period before a new +# leader has been elected where the old leader is returned in the cluster +# status. This can result in a failure to apply the connection settings if a +# different leader is elected. Wait for a few seconds for the leader election +# to complete. +- name: Wait for leader election + pause: + seconds: "{{ ovn_leader_election_pause }}" + when: ovn_nb_db_cluster_exists | default(false) or ovn_sb_db_cluster_exists | default(false) + - name: Get OVN_Northbound cluster leader become: true command: "{{ kolla_container_engine }} exec ovn_nb_db ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound" diff --git a/releasenotes/notes/workaround-ovn-leader-election-f7f75e93e9300d96.yaml b/releasenotes/notes/workaround-ovn-leader-election-f7f75e93e9300d96.yaml new file mode 100644 index 0000000000..90a1fd5da7 --- /dev/null +++ b/releasenotes/notes/workaround-ovn-leader-election-f7f75e93e9300d96.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an issue where OVN northbound or southbound database deployment could + fail when a new leader is elected. `LP#2059124 + `__