@@ -45,18 +45,12 @@ pidfile_is_running () {
test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid"
} >/dev/null 2>&1
-stop_xx_ovsdb() {
- if pidfile_is_running $1; then
- ovn-appctl -t $OVN_RUNDIR/$2 exit
- fi
-}
-
stop_nb_ovsdb() {
- stop_xx_ovsdb $DB_NB_PID ovnnb_db.ctl
+ OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnnb_db $DB_NB_PID $OVN_RUNDIR/ovnnb_db.ctl
}
stop_sb_ovsdb() {
- stop_xx_ovsdb $DB_SB_PID ovnsb_db.ctl
+ OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnsb_db $DB_SB_PID $OVN_RUNDIR/ovnsb_db.ctl
}
stop_ovsdb () {
@@ -65,11 +59,11 @@ stop_ovsdb () {
}
stop_ic_nb_ovsdb() {
- stop_xx_ovsdb $DB_IC_NB_PID ovn_ic_nb_db.ctl
+ OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_nb_db $DB_IC_NB_PID $OVN_RUNDIR/ovn_ic_nb_db.ctl
}
stop_ic_sb_ovsdb() {
- stop_xx_ovsdb $DB_IC_SB_PID ovn_ic_sb_db.ctl
+ OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_sb_db $DB_IC_SB_PID $OVN_RUNDIR/ovn_ic_sb_db.ctl
}
stop_ic_ovsdb () {
@@ -590,7 +584,7 @@ stop_ic () {
}
stop_controller () {
- OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller "$@"
+ OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller "" "" "$@"
}
stop_controller_vtep () {
@@ -137,10 +137,22 @@ start_ovn_daemon () {
}
stop_ovn_daemon () {
- if test -e "$ovn_rundir/$1.pid"; then
- if pid=`cat "$ovn_rundir/$1.pid"`; then
+ local pid_file=$2
+ local ctl_file=$3
+ local other_args=$4
+
+ if [ -z "$pid_file" ]; then
+ pid_file="$ovn_rundir/$1.pid"
+ fi
+
+ if test -e "$pid_file"; then
+ if pid=`cat "$pid_file"`; then
+ if [ -z "$ctl_file" ]; then
+ ctl_file="$ovn_rundir/$1.$pid.ctl"
+ fi
+
if pid_exists "$pid" >/dev/null 2>&1; then :; else
- rm -f $ovn_rundir/$1.$pid.ctl $ovn_rundir/$1.$pid
+ rm -f $ctl_file $pid_file
return 0
fi
@@ -148,7 +160,7 @@ stop_ovn_daemon () {
actions="TERM .1 .25 .65 1 1 1 1 \
KILL 1 1 1 2 10 15 30 \
FAIL"
- version=`ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl version \
+ version=`ovs-appctl -T 1 -t $ctl_file version \
| awk 'NR==1{print $NF}'`
# Use `ovs-appctl exit` only if the running daemon version
@@ -169,7 +181,7 @@ stop_ovn_daemon () {
# But, does the file exist? We may have had a daemon
# segfault with `ovs-appctl exit`. Check one more time
# before deciding that the daemon is dead.
- [ -e "$ovn_rundir/$1.pid" ] && sleep 2 && pid=`cat "$ovn_rundir/$1.pid"` 2>/dev/null
+ [ -e "$pid_file" ] && sleep 2 && pid=`cat "$pid_file"` 2>/dev/null
if pid_exists "$pid" >/dev/null 2>&1; then :; else
return 0
fi
@@ -177,7 +189,7 @@ stop_ovn_daemon () {
case $action in
EXIT)
action "Exiting $1 ($pid)" \
- ${bindir}/ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl exit $2
+ ${bindir}/ovs-appctl -T 1 -t $ctl_file exit $other_args
# The above command could have resulted in delayed
# daemon segfault. And if a monitor is running, it
# would restart the daemon giving it a new pid.
Wait for the databases to actually exit before returning to the caller of ovn-ctl. In containerized use-cases the container runtime often kills the container when the process calling ovn-ctl exits, which may not give the DBs time to clean up after themselves. Reported-at: https://bugzilla.redhat.com/1944239 Signed-off-by: Dan Williams <dcbw@redhat.com> --- utilities/ovn-ctl | 16 +++++----------- utilities/ovn-lib.in | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 17 deletions(-)