Skip to content

Commit 51e3e5a

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 6004088 commit 51e3e5a

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
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-5
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,20 @@ function is_clustered {
139139

140140
function set_nb_version_compatibility() {
141141
if [ -n "$OVN_VERSION_COMPATIBILITY" ]; then
142-
if ! ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options | grep -q version_compatibility=; then
143-
echo "setting ovn NB_Global option version_compatibility to ${OVN_VERSION_COMPATIBILITY}"
144-
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
142+
alias _nbctl="ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS"
143+
if ! _nbctl get NB_Global . external-ids | grep -w 'ovn-match-northd-version="true"'; then
144+
# Do not set version_compatibility. Use ovn-controller external-ids:ovn-match-northd-version=true instead.
145145
return
146146
fi
147-
value=`ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
147+
148+
if ! _nbctl get NB_Global . options | grep -q version_compatibility=; then
149+
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
150+
return
151+
fi
152+
value=`_nbctl get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
148153
echo "ovn nb global option version_compatibility is set to $value"
149154
if [ "$value" != "_$OVN_VERSION_COMPATIBILITY" ]; then
150-
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
155+
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
151156
fi
152157
fi
153158
}

dist/images/upgrade-ovs.sh

+10-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ function gen_conn_str {
3232
echo "$x"
3333
}
3434

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

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

0 commit comments

Comments
 (0)