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 12, 2024
1 parent f21c9c3 commit bdcee03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 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
14 changes: 10 additions & 4 deletions dist/images/start-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,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
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
13 changes: 9 additions & 4 deletions dist/images/upgrade-ovs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ 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/"$//'`
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
Expand Down Expand Up @@ -78,4 +82,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 bdcee03

Please sign in to comment.