Skip to content

Commit de47e56

Browse files
committed
Copy LSP.tag to LSP.tag_request if it is unset
OVN 26.03.1 contains a fix that clears tags when the tag_request is cleared. For years, neutron has set the tag directly without setting a request. This if fixed in the neutron code, but on upgrade, it is possible that ports with tags and no tag_request will have the tags cleared before neutron could restart to fix them. Due to upgrade races between ovndbcluster and northd, this hacks the fix into northd startup. Resolves: OSPRH-31613 Signed-off-by: Terry Wilson <twilson@redhat.com>
1 parent 12e4945 commit de47e56

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

internal/ovnnorthd/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
const (
3333
// ServiceCommand -
34-
ServiceCommand = "/usr/bin/ovn-northd"
34+
ServiceCommand = "/usr/local/bin/container-scripts/setup.sh"
3535
)
3636

3737
// StatefulSet func

templates/ovnnorthd/bin/setup.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -e
3+
4+
for arg in "$@"; do
5+
case $arg in
6+
--ovnnb-db=*) NB_DB="${arg#*=}" ;;
7+
--certificate=*) CERT="${arg#*=}" ;;
8+
--private-key=*) PKEY="${arg#*=}" ;;
9+
--ca-cert=*) CACERT="${arg#*=}" ;;
10+
esac
11+
done
12+
13+
if [ -n "$NB_DB" ]; then
14+
NBCTL="ovn-nbctl --no-leader-only"
15+
if [ -n "$CERT" ]; then
16+
NBCTL="$NBCTL --certificate=$CERT --private-key=$PKEY --ca-cert=$CACERT"
17+
fi
18+
19+
# NOTE(twilson) This will wait for the ovsdb connection before detaching
20+
export OVN_NB_DAEMON=$(${NBCTL} --pidfile --detach --db=$NB_DB)
21+
22+
# NOTE(twilson) ovn-nbctl will be connecting to the daemon successfully, so will wait forever
23+
# until the daemon responds. So even if there is a disconnect after initially connecting it waits.
24+
#
25+
# Due to OVN commit `171ed24dd northd: Clear stale LSP tags on tag_request removal.` and neutron's
26+
# historical practice of setting the tag directly instead of using tag_request, 26.03.1+ versions
27+
# of northd will clear all tags set by neutron prior to 18.0 FR6. For upgrades to FR6 and beyond
28+
# from an affected prior version (<= 18.0 FR6) this will fix the issue before northd starts.
29+
#
30+
# This is safe to remove when the minimum version from which upgrades are allowed is 18.0 FR7 or
31+
# later. Note that this setup script itself only exists to run this fix.
32+
for port in $(${NBCTL} --bare --columns _uuid find logical_switch_port tag!='[]' tag_request='[]'); do
33+
tag=$(${NBCTL} lsp-get-tag $port)
34+
echo "Fixing tag_request for $port tag=$tag"
35+
${NBCTL} set logical_switch_port $port tag_request=$tag
36+
done
37+
38+
kill $(cat $OVN_RUNDIR/ovn-nbctl.pid)
39+
unset OVN_NB_DAEMON
40+
fi
41+
42+
exec /usr/bin/ovn-northd "$@"

0 commit comments

Comments
 (0)