Here is my explanation:
1. According to ovn docs https://docs.ovn.org/en/latest/intro/install/ovn-upgrades.html
"The only step required after upgrading the packages is to restart ovn-northd, which automatically restarts the databases and upgrades the database schema, as well.
if you’re using a Linux distribution with systemd:
$ sudo systemctl restart ovn-northd
which is not true in Ubuntu case
```
ExecStart=/usr/share/ovn/scripts/ovn-ctl start_northd --ovn-manage-ovsdb=no --no-monitor $OVN_CTL_OPTS
```
ovn-manage-ovsdb=no, so it will not restart the DBs.
2. DB restarts by ovn-ovsdb-server-nb.service and ovn-ovsdb-server-sb.service
run_nb_ovsdb and run_sb_ovsdb options in ovn-ctl
```
ExecStart=/usr/share/ovn/scripts/ovn-ctl run_nb_ovsdb $OVN_CTL_OPTS
```
This is the code that is responsible for the upgrade https://github.com/ovn-org/ovn/blob/5c2d311b8b7b4d5c3a619de72be6a433aa4c44db/utilities/ovn-ctl#L293
```
if test X$detach = Xno && test $mode = cluster && test -z "$cluster_remote_addr" ; then
```
First two checks are true.
Third check means upgrade_cluster (L313) will run on leader node, i.e --db-nb-cluster-remote-addr= and --db-sb-cluster-remote-addr= is not set.
Here is my explanation: /docs.ovn. org/en/ latest/ intro/install/ ovn-upgrades. html
1. According to ovn docs https:/
"The only step required after upgrading the packages is to restart ovn-northd, which automatically restarts the databases and upgrades the database schema, as well.
if you’re using a Linux distribution with systemd:
$ sudo systemctl restart ovn-northd
which is not true in Ubuntu case /usr/share/ ovn/scripts/ ovn-ctl start_northd --ovn-manage- ovsdb=no --no-monitor $OVN_CTL_OPTS ovsdb=no, so it will not restart the DBs.
```
ExecStart=
```
ovn-manage-
2. DB restarts by ovn-ovsdb- server- nb.service and ovn-ovsdb- server- sb.service /usr/share/ ovn/scripts/ ovn-ctl run_nb_ovsdb $OVN_CTL_OPTS
run_nb_ovsdb and run_sb_ovsdb options in ovn-ctl
```
ExecStart=
```
3. This commit fixed Cluster OVN database upgrade https:/ /github. com/ovn- org/ovn/ commit/ 67e2f386cc838d0 b0f9b4b5da7fe61 1e1113b70c /bugs.launchpad .net/ubuntu/ +source/ ovn/+bug/ 1907081
in this bug https:/
This is the code that is responsible for the upgrade /github. com/ovn- org/ovn/ blob/5c2d311b8b 7b4d5c3a619de72 be6a433aa4c44db /utilities/ ovn-ctl# L293 remote_ addr" ; then cluster- remote- addr= and --db-sb- cluster- remote- addr= is not set.
https:/
```
if test X$detach = Xno && test $mode = cluster && test -z "$cluster_
```
First two checks are true.
Third check means upgrade_cluster (L313) will run on leader node, i.e --db-nb-
4. During rolling upgrades of controller nodes, the leader will likely move. /github. com/openstack/ openstack- ansible- os_neutron/ blob/stable/ 2023.1/ templates/ ovn-northd- opts.j2 /github. com/openstack/ openstack- ansible- os_neutron/ blob/stable/ 2023.1/ tasks/providers /ovn_cluster_ setup.yml# L105 cluster- remote- addr and --db-sb- cluster- remote- addr set to the some value that was leader node at that time.
OVS_CTL_OPTS generated from this template
https:/
but only when new node joins the cluster https:/
so after upgrade all 3 nodes will have --db-nb-
What we need is --db-nb- cluster- remote- addr= not set on leader node, so during ovn-central restart on leader node upgrade_cluster will run.