Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ovn-controller option external_ids:ovn-match-northd-version to improve upgrade process #4183

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions charts/kube-ovn/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ 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 -}}
{{- else if regexFind $versionRegex $imageVersion | semverCompare "< 1.11.0" -}}
21.06
{{- end -}}
{{- end -}}
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
Loading