Message ID | 1466534961-7967-1-git-send-email-diproiettod@vmware.com |
---|---|
State | Superseded |
Headers | show |
Guru made some suggestions offline, so I've sent a v2 here: http://openvswitch.org/pipermail/dev/2016-June/073313.html On 21/06/2016 11:49, "Daniele Di Proietto" <diproiettod@vmware.com> wrote: >Commit 9b5422a98f81("ovs-lib: Try to call exit before killing.") >introduced a problem where internal interfaces are destroyed and >recreated, losing their IP address. > >Commit 9aad5a5a96ba("ovs-vswitchd: Preserve datapath ports across >graceful shutdown.") fixed the problem by changing ovs-vswitchd >to preserve the ports on `ovs-appctl exit`. Unfortunately, this fix is >not enough during upgrade from <= 2.5.0, where an old ovs-vswitchd is >running (without the fix) and a new ovs-lib script is performing the >restart. > >The problem seem to affect both RHEL and ubuntu > >This commit fixes the upgrade by looking at the running ovs-vswitchd >version and avoid using `ovs-appctl exit` for old (before 2.5.90) >versions. > >Suggested-by: Gurucharan Shetty <guru@ovn.org> >Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> >--- > utilities/ovs-lib.in | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) > >diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in >index 773efb3..ec8b82a 100644 >--- a/utilities/ovs-lib.in >+++ b/utilities/ovs-lib.in >@@ -202,10 +202,30 @@ start_daemon () { > stop_daemon () { > if test -e "$rundir/$1.pid"; then > if pid=`cat "$rundir/$1.pid"`; then >- for action in EXIT .1 .25 .65 1 \ >- TERM .1 .25 .65 1 1 1 1 \ >- KILL 1 1 1 2 10 15 30 \ >- FAIL; do >+ >+ actions="TERM .1 .25 .65 1 1 1 1 \ >+ KILL 1 1 1 2 10 15 30 \ >+ FAIL" >+ graceful="EXIT .1 .25 .65 1" >+ if [ "$1" = "ovs-vswitchd" ]; then >+ version=`ovs-appctl -T 1 -t $rundir/$1.$pid.ctl version` >+ version_num=`echo $version | cut -d ' ' -f 4` >+ version_maj=`echo $version_num | cut -d '.' -f 1` >+ version_min=`echo $version_num | cut -d '.' -f 2` >+ version_rev=`echo $version_num | cut -d '.' -f 3` >+ >+ # Use `ovs-appctl exit` for ovs-vswitchd only if version >+ # is >= 2.5.90. On previous versions it's not safe, because >+ # internal ports might lose their IP address. >+ if [ "$version_maj" -gt 2 \ >+ -o "$version_min" -gt 5 \ >+ -o "$version_rev" -ge 90 ]; then >+ actions="$graceful $actions" >+ fi >+ else >+ actions="$graceful $actions" >+ fi >+ for action in $actions; do > if pid_exists "$pid" >/dev/null 2>&1; then :; else > return 0 > fi >-- >2.8.1 >
diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in index 773efb3..ec8b82a 100644 --- a/utilities/ovs-lib.in +++ b/utilities/ovs-lib.in @@ -202,10 +202,30 @@ start_daemon () { stop_daemon () { if test -e "$rundir/$1.pid"; then if pid=`cat "$rundir/$1.pid"`; then - for action in EXIT .1 .25 .65 1 \ - TERM .1 .25 .65 1 1 1 1 \ - KILL 1 1 1 2 10 15 30 \ - FAIL; do + + actions="TERM .1 .25 .65 1 1 1 1 \ + KILL 1 1 1 2 10 15 30 \ + FAIL" + graceful="EXIT .1 .25 .65 1" + if [ "$1" = "ovs-vswitchd" ]; then + version=`ovs-appctl -T 1 -t $rundir/$1.$pid.ctl version` + version_num=`echo $version | cut -d ' ' -f 4` + version_maj=`echo $version_num | cut -d '.' -f 1` + version_min=`echo $version_num | cut -d '.' -f 2` + version_rev=`echo $version_num | cut -d '.' -f 3` + + # Use `ovs-appctl exit` for ovs-vswitchd only if version + # is >= 2.5.90. On previous versions it's not safe, because + # internal ports might lose their IP address. + if [ "$version_maj" -gt 2 \ + -o "$version_min" -gt 5 \ + -o "$version_rev" -ge 90 ]; then + actions="$graceful $actions" + fi + else + actions="$graceful $actions" + fi + for action in $actions; do if pid_exists "$pid" >/dev/null 2>&1; then :; else return 0 fi
Commit 9b5422a98f81("ovs-lib: Try to call exit before killing.") introduced a problem where internal interfaces are destroyed and recreated, losing their IP address. Commit 9aad5a5a96ba("ovs-vswitchd: Preserve datapath ports across graceful shutdown.") fixed the problem by changing ovs-vswitchd to preserve the ports on `ovs-appctl exit`. Unfortunately, this fix is not enough during upgrade from <= 2.5.0, where an old ovs-vswitchd is running (without the fix) and a new ovs-lib script is performing the restart. The problem seem to affect both RHEL and ubuntu This commit fixes the upgrade by looking at the running ovs-vswitchd version and avoid using `ovs-appctl exit` for old (before 2.5.90) versions. Suggested-by: Gurucharan Shetty <guru@ovn.org> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> --- utilities/ovs-lib.in | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)