From 18d85dbf7fe9c6133ebcd7779e237cf5b19e50b7 Mon Sep 17 00:00:00 2001 From: Hyunsun Moon Date: Wed, 4 Apr 2018 18:41:25 +0900 Subject: [PATCH] openvswitch: use pidfile option Make appctl to search pidfile for exit command as pid 1 is not always the target process in some cases. For example, pid 1 is "pause" when pid namespace sharing is enabled in your k8s cluster. Change-Id: I90e202245a9522fe53bea7e1f047061a0a280834 --- openvswitch/templates/bin/_openvswitch-db-server.sh.tpl | 5 ++++- openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openvswitch/templates/bin/_openvswitch-db-server.sh.tpl b/openvswitch/templates/bin/_openvswitch-db-server.sh.tpl index fc3365e6b4..cec29ec45b 100644 --- a/openvswitch/templates/bin/_openvswitch-db-server.sh.tpl +++ b/openvswitch/templates/bin/_openvswitch-db-server.sh.tpl @@ -22,6 +22,7 @@ COMMAND="${@:-start}" OVS_DB=/run/openvswitch/conf.db OVS_SOCKET=/run/openvswitch/db.sock OVS_SCHEMA=/usr/share/openvswitch/vswitch.ovsschema +OVS_PID=/run/openvswitch/ovsdb-server.pid function start () { mkdir -p "$(dirname ${OVS_DB})" @@ -38,11 +39,13 @@ function start () { -vconsole:emer \ -vconsole:err \ -vconsole:info \ + --pidfile=${OVS_PID} \ --remote=punix:${OVS_SOCKET} } function stop () { - ovs-appctl -T1 -t /run/openvswitch/ovsdb-server.1.ctl exit + PID=$(cat $OVS_PID) + ovs-appctl -T1 -t /run/openvswitch/ovsdb-server.${PID}.ctl exit } $COMMAND diff --git a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl index 30a7db79b7..36fe51fdc8 100644 --- a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl +++ b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl @@ -20,6 +20,7 @@ set -ex COMMAND="${@:-start}" OVS_SOCKET=/run/openvswitch/db.sock +OVS_PID=/run/openvswitch/ovs-vswitchd.pid function start () { t=0 @@ -63,11 +64,13 @@ function start () { -vconsole:emer \ -vconsole:err \ -vconsole:info \ + --pidfile=${OVS_PID} \ --mlockall } function stop () { - ovs-appctl -T1 -t /run/openvswitch/ovs-vswitchd.1.ctl exit + PID=$(cat $OVS_PID) + ovs-appctl -T1 -t /run/openvswitch/ovs-vswitchd.${PID}.ctl exit } $COMMAND