Skip to content

Commit

Permalink
use ovn-controller option external_ids:ovn-match-northd-version to im…
Browse files Browse the repository at this point in the history
…prove upgrade process

Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Jul 31, 2024
1 parent df2d066 commit 2b8b98e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 2 additions & 4 deletions charts/kube-ovn/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ Number of master nodes
{{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}}
{{- $versionRegex := `^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)` -}}
{{- if and (ne $newChartVersion $chartVersion) (regexMatch $versionRegex $imageVersion) -}}
{{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.13.0" -}}
24.03
{{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}}
{{- if and (regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0") (regexFind $versionRegex $imageVersion | semverCompare "<= 1.12.17") -}}
22.12
{{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.11.0" -}}
{{- else if and (regexFind $versionRegex $imageVersion | semverCompare ">= 1.11.0") (regexFind $versionRegex $imageVersion | semverCompare "<= 1.11.18") -}}
22.03
{{- else -}}
21.06
Expand Down
15 changes: 10 additions & 5 deletions dist/images/start-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,20 @@ function is_clustered {

function set_nb_version_compatibility() {
if [ -n "$OVN_VERSION_COMPATIBILITY" ]; then
if ! ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options | grep -q version_compatibility=; then
echo "setting ovn NB_Global option version_compatibility to ${OVN_VERSION_COMPATIBILITY}"
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
alias _nbctl="ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS"
if ! _nbctl get NB_Global . external-ids | grep -w 'ovn-match-northd-version="true"'; then
# Do not set version_compatibility. Use ovn-controller external-ids:ovn-match-northd-version=true instead.
return
fi
value=`ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`

if ! _nbctl get NB_Global . options | grep -q version_compatibility=; then
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
return
fi
value=`_nbctl get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
echo "ovn nb global option version_compatibility is set to $value"
if [ "$value" != "_$OVN_VERSION_COMPATIBILITY" ]; then
ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
_nbctl set NB_Global . options:version_compatibility=${OVN_VERSION_COMPATIBILITY}
fi
fi
}
Expand Down
15 changes: 10 additions & 5 deletions dist/images/upgrade-ovs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ function gen_conn_str {
echo "$x"
}

nb_addr="$(gen_conn_str 6641)"
alias _nbctl="ovn-nbctl --db=$(gen_conn_str 6641) $SSL_OPTIONS"
if ! _nbctl get NB_Global . external-ids | grep -w 'ovn-match-northd-version="true"'; then
exit
fi

while true; do
if [ x`ovn-nbctl --db=$nb_addr $SSL_OPTIONS get NB_Global . options | grep -o 'version_compatibility='` != "x" ]; then
value=`ovn-nbctl --db=$nb_addr $SSL_OPTIONS get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
echo "ovn NB_Global option version_compatibility is already set to $value"
if [ x`_nbctl get NB_Global . options | grep -o 'version_compatibility='` != "x" ]; then
value=`_nbctl get NB_Global . options:version_compatibility | sed -e 's/^"//' -e 's/"$//'`
echo "ovn NB_Global option version_compatibility is set to $value"
if [ "$value" = "$OVN_VERSION_COMPATIBILITY" -o "$value" = "_$OVN_VERSION_COMPATIBILITY" ]; then
break
fi
Expand Down Expand Up @@ -76,4 +80,5 @@ else
kubectl -n $POD_NAMESPACE rollout status ds/ovs-ovn
fi

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

0 comments on commit 2b8b98e

Please sign in to comment.