Skip to content

Commit

Permalink
Fixes #7189: issues with process management on physical hosting LXC c…
Browse files Browse the repository at this point in the history
…ontainers
  • Loading branch information
peckpeck committed Sep 21, 2015
1 parent 31c3a3a commit 2f667ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
26 changes: 11 additions & 15 deletions rudder-agent/SOURCES/check-rudder-agent
Expand Up @@ -39,10 +39,8 @@ CFENGINE_DB_EXT=lmdb
## If we are on AIX, use alternative commands and options
if [ "z${OS_FAMILY}" = "zAIX" ]; then
CP_A="cp -hpPr"
PS_OPTIONS="-ef"
else
CP_A="cp -a"
PS_OPTIONS="-efww"
fi

echo_n() {
Expand Down Expand Up @@ -70,26 +68,24 @@ clean_cf_lock_files() {
check_and_fix_cfengine_processes() {

# Detect the correct ps tool to use
# Supported tools are ps, vzps, and the rudder supplied vzps.py
PS=ps
VZPS=/bin/vzps
RUDDERPS=/opt/rudder/bin/vzps.py

# Detect if we are a VZ host
if [ -e "/proc/bc/0" ]; then
# Detect if vzps is present
if [ -e ${VZPS} ]; then
PS="${VZPS} -E 0"
else
PS="${RUDDERPS} -E 0"
ns=$(ps -h -o utsns --pid $$ 2>/dev/null)
if [ -e "/proc/bc/0" ]; then # we have openvz
if [ -e /bin/vzps ]; then # we have vzps
PS_COMAND="/bin/vzps -E 0"
else # use rudder provided vzps
PS_COMMAND="/opt/rudder/bin/vzps.py -E 0"
fi
elif [ -n "${ns}" ]; then # we have namespaces
PS_COMMAND="ps -h -e -O utsns | grep -E '^[[:space:]]*[[:digit:]]*[[:space:]]+${ns}'"
else # standard unix
PS_COMMAND="ps -ef"
fi

# If there are more than on cf-execd process, we must kill them
# A standard kill won't kill them, so the -9 is necessary to make sure they are stopped
# They will be restarted by the next check, if the disable file is not set
# List the cf-execd processes running (without the path, they can be run manually)
CF_EXECD_RUNNING=`${PS} ${PS_OPTIONS} | grep -E "cf-execd" | grep -v grep | cat`
CF_EXECD_RUNNING=`${PS_COMMAND} | grep -E "cf-execd" | grep -v grep | cat`
NB_CF_EXECD_RUNNING=`echo "${CF_EXECD_RUNNING}" | grep -v ^$ | wc -l`
if [ ${NB_CF_EXECD_RUNNING} -gt 1 ]; then
echo_n "WARNING: Too many instance of CFEngine cf-execd processes running. Killing them..."
Expand Down
17 changes: 15 additions & 2 deletions rudder-agent/SOURCES/rudder-agent.init 100644 → 100755
Expand Up @@ -46,7 +46,7 @@
# Author: Jonathan Clarke <jonathan.clarke@normation.com>
#====================================================================

# Source environment variables from /etc/profile
# Source environment variables from /etc/profile
. /etc/profile

# Array indexes
Expand All @@ -65,8 +65,21 @@ PROG_NAME=`basename $0 | sed 's/^[KS][0-9][0-9]//'` # For nice messages
OS=`uname -s` # To adapt message printing
MYUID=`id -u` # For UNIX compatibility => modify this command
MYGID=`id -g` # For UNIX compatibility => modify this command
PS_COMMAND="ps -efww" # This ensures full width for ps output but doesn't work on Solaris - use "ps -ef"
SYSLOG_FACILITY="local6"
# Detect the correct ps tool to use
ns=$(ps -h -o utsns --pid $$ 2>/dev/null)
if [ -e "/proc/bc/0" ]; then # we have openvz
if [ -e /bin/vzps ]; then # we have vzps
PS_COMAND="/bin/vzps -E 0"
else # use rudder provided vzps
PS_COMMAND="/opt/rudder/bin/vzps.py -E 0"
fi
elif [ -n "${ns}" ]; then # we have namespaces
PS_COMMAND="ps -h -e -O utsns | grep -E '^[[:space:]]*[[:digit:]]*[[:space:]]+${ns}'"
else # standard unix
PS_COMMAND="ps -ef"
fi


# CFEngine Community directory and files
CFENGINE_COMMUNITY_PATH="/usr/local/cfengine"
Expand Down

0 comments on commit 2f667ce

Please sign in to comment.