Skip to content

Commit bdcee03

Browse files
committed
use ovn-controller option external_ids:ovn-match-northd-version to improve upgrade process
Signed-off-by: zhangzujian <[email protected]>
1 parent f21c9c3 commit bdcee03

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

charts/kube-ovn/templates/_helpers.tpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ Number of master nodes
6363
{{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}}
6464
{{- $versionRegex := `^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)` -}}
6565
{{- if and (ne $newChartVersion $chartVersion) (regexMatch $versionRegex $imageVersion) -}}
66-
{{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.13.0" -}}
67-
24.03
68-
{{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}}
66+
{{- if and (regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0") (regexFind $versionRegex $imageVersion | semverCompare "<= 1.12.17") -}}
6967
22.12
70-
{{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.11.0" -}}
68+
{{- else if and (regexFind $versionRegex $imageVersion | semverCompare ">= 1.11.0") (regexFind $versionRegex $imageVersion | semverCompare "<= 1.11.18") -}}
7169
22.03
7270
{{- else -}}
7371
21.06

dist/images/start-db.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,20 @@ function is_clustered {
138138

139139
function set_nb_version_compatibility() {
140140
if [ -n "$OVN_VERSION_COMPATIBILITY" ]; then
141-
if ! ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options | grep -q version_compatibility=; then
142-
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
141+
alias _nbctl="ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS"
142+
if ! _nbctl get NB_Global . external-ids | grep -w 'ovn-match-northd-version="true"'; then
143+
# Do not set version_compatibility. Use ovn-controller external-ids:ovn-match-northd-version=true instead.
143144
return
144145
fi
145-
value=`ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
146+
147+
if ! _nbctl get NB_Global . options | grep -q version_compatibility=; then
148+
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
149+
return
150+
fi
151+
value=`_nbctl get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
146152
echo "ovn nb global option version_compatibility is set to $value"
147153
if [ "$value" != "_$OVN_VERSION_COMPATIBILITY" ]; then
148-
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
154+
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
149155
fi
150156
fi
151157
}

dist/images/upgrade-ovs.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ function gen_conn_str {
3434
echo "$x"
3535
}
3636

37-
nb_addr="$(gen_conn_str 6641)"
37+
alias _nbctl="ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS"
38+
if ! _nbctl get NB_Global . external-ids | grep -w 'ovn-match-northd-version="true"'; then
39+
exit
40+
fi
41+
3842
while true; do
39-
if [ x`ovn-nbctl --db=$nb_addr $SSL_OPTIONS get NB_Global . options | grep -o 'version_compatibility='` != "x" ]; then
40-
value=`ovn-nbctl --db=$nb_addr $SSL_OPTIONS get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
43+
if [ x`_nbctl get NB_Global . options | grep -o 'version_compatibility='` != "x" ]; then
44+
value=`_nbctl get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
4145
echo "ovn NB_Global option version_compatibility is set to $value"
4246
if [ "$value" = "$OVN_VERSION_COMPATIBILITY" -o "$value" = "_$OVN_VERSION_COMPATIBILITY" ]; then
4347
break
@@ -78,4 +82,5 @@ else
7882
kubectl -n $POD_NAMESPACE rollout status ds/ovs-ovn
7983
fi
8084

81-
ovn-nbctl --db=$nb_addr $SSL_OPTIONS set NB_Global . options:version_compatibility=_$OVN_VERSION_COMPATIBILITY
85+
_nbctl set NB_Global . external-ids:ovn-match-northd-version=true
86+
_nbctl remove NB_Global . options version_compatibility

0 commit comments

Comments
 (0)