Fixing linters errors E010, E011, E020, E041,E043, E003, E001,E042
Listed below are the errors which were fixed as well as the actions taken to fix them: E010: do not on the same line as for --> let do and for in the same line E011: then not on the same line as if or elif --> let then and if or elif in the same line E020: Function declaration not in format ^function name {$ --> fix the format to suit ^function name {$ E041: Usage of $[ for arithmetic is deprecated for $(( --> fix from $[ to $(( E043: arithmetic compound has inconsistent return semantics --> do not use +=, ++, -=, --; use value=value+? instead. E001: check that lines do not end with trailing whitespace --> delete trailing whitespace E003: ensure all indents are a multiple of 4 spaces --> add/delete spaces E042: local declaration hides errors --> let declaration and assignment in two lines. Listed below are test cases done which run one controller and one compute in KVMs Test-Install ---- success Related: https://review.openstack.org/#/c/600663/ https://review.openstack.org/#/c/601221/ Story: 2003360 Task: 26213 Change-Id: I3ece37db3a326ea58bd344f43beefcbbbd4f0ad4 Signed-off-by: SidneyAn <ran1.an@intel.com>
This commit is contained in:
parent
081cbf0240
commit
47ac546217
@ -21,25 +21,22 @@ LOG_PRIORITY=info
|
||||
TMPLOG=/tmp/${WHOAMI}.log
|
||||
|
||||
# LOG() - generates log and puts in temporary file
|
||||
function LOG()
|
||||
{
|
||||
logger -t "${0##*/}[$$]" -p ${LOG_FACILITY}.${LOG_PRIORITY} "$@"
|
||||
echo "${0##*/}[$$]" "$@" >> ${TMPLOG}
|
||||
function LOG {
|
||||
logger -t "${0##*/}[$$]" -p ${LOG_FACILITY}.${LOG_PRIORITY} "$@"
|
||||
echo "${0##*/}[$$]" "$@" >> ${TMPLOG}
|
||||
}
|
||||
function INFO()
|
||||
{
|
||||
MSG="INFO"
|
||||
LOG "${MSG} $@"
|
||||
function INFO {
|
||||
MSG="INFO"
|
||||
LOG "${MSG} $@"
|
||||
}
|
||||
function ERROR()
|
||||
{
|
||||
MSG="ERROR"
|
||||
LOG "${MSG} $@"
|
||||
function ERROR {
|
||||
MSG="ERROR"
|
||||
LOG "${MSG} $@"
|
||||
}
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
ERROR "Interface name and cpulist are required"
|
||||
exit 1
|
||||
ERROR "Interface name and cpulist are required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
interface=$1
|
||||
@ -47,7 +44,7 @@ cpulist=$2
|
||||
|
||||
# Find PCI device matching interface, keep last matching device name
|
||||
dev=$(find /sys/devices -name "${interface}" | \
|
||||
perl -ne 'print $1 if /([[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]])\/[[:alpha:]]/;')
|
||||
perl -ne 'print $1 if /([[:xdigit:]]{4}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\.[[:xdigit:]])\/[[:alpha:]]/;')
|
||||
|
||||
# Obtain all IRQs for this device
|
||||
irq=$(cat /sys/bus/pci/devices/${dev}/irq 2>/dev/null)
|
||||
@ -56,7 +53,7 @@ msi_irqs=$(ls /sys/bus/pci/devices/${dev}/msi_irqs 2>/dev/null | xargs)
|
||||
INFO $LINENO "affine ${interface} (dev:${dev} irq:${irq} msi_irqs:${msi_irqs}) with cpus (${cpulist})"
|
||||
|
||||
for i in $(echo "${irq} ${msi_irqs}"); do echo $i; done | \
|
||||
xargs --no-run-if-empty -i{} \
|
||||
/bin/bash -c "[[ -e /proc/irq/{} ]] && echo ${cpulist} > /proc/irq/{}/smp_affinity_list" 2>/dev/null
|
||||
xargs --no-run-if-empty -i{} \
|
||||
/bin/bash -c "[[ -e /proc/irq/{} ]] && echo ${cpulist} > /proc/irq/{}/smp_affinity_list" 2>/dev/null
|
||||
|
||||
exit 0
|
||||
|
@ -26,8 +26,7 @@ LOG_DEBUG=1
|
||||
################################################################################
|
||||
# Affine all running tasks to the CPULIST provided in the first parameter.
|
||||
################################################################################
|
||||
function affine_tasks
|
||||
{
|
||||
function affine_tasks {
|
||||
local CPULIST=$1
|
||||
local PIDLIST
|
||||
local RET=0
|
||||
@ -40,11 +39,11 @@ function affine_tasks
|
||||
RET=$?
|
||||
if [ $RET -ne 0 ]; then
|
||||
log_error "Some tasks failed to be affined to all cores."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get number of logical cpus
|
||||
N_CPUS=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
|
||||
awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
|
||||
|
||||
# Calculate platform cores cpumap
|
||||
PLATFORM_COREMASK=$(cpulist_to_cpumap ${CPULIST} ${N_CPUS})
|
||||
@ -66,30 +65,26 @@ function affine_tasks
|
||||
/bin/bash -c "[[ -e /proc/irq/${i} ]] && echo ${CPULIST} > /proc/irq/${i}/smp_affinity_list" 2>/dev/null
|
||||
done
|
||||
if [[ "$subfunction" == *"compute,lowlatency" ]]; then
|
||||
# Affine work queues to platform cores
|
||||
echo ${PLATFORM_COREMASK} > /sys/devices/virtual/workqueue/cpumask
|
||||
echo ${PLATFORM_COREMASK} > /sys/bus/workqueue/devices/writeback/cpumask
|
||||
# Affine work queues to platform cores
|
||||
echo ${PLATFORM_COREMASK} > /sys/devices/virtual/workqueue/cpumask
|
||||
echo ${PLATFORM_COREMASK} > /sys/bus/workqueue/devices/writeback/cpumask
|
||||
|
||||
# On low latency compute reassign the per cpu threads rcuc, ksoftirq,
|
||||
# ktimersoftd to FIFO along with the specified priority
|
||||
PIDLIST=$( ps -e -p 2 |grep rcuc | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
chrt -p -f 4 ${PID} 2>/dev/null
|
||||
done
|
||||
# On low latency compute reassign the per cpu threads rcuc, ksoftirq,
|
||||
# ktimersoftd to FIFO along with the specified priority
|
||||
PIDLIST=$( ps -e -p 2 |grep rcuc | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 4 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
PIDLIST=$( ps -e -p 2 |grep ksoftirq | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
chrt -p -f 2 ${PID} 2>/dev/null
|
||||
done
|
||||
PIDLIST=$( ps -e -p 2 |grep ksoftirq | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 2 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
PIDLIST=$( ps -e -p 2 |grep ktimersoftd | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
chrt -p -f 3 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
PIDLIST=$( ps -e -p 2 |grep ktimersoftd | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 3 ${PID} 2>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -98,8 +93,7 @@ function affine_tasks
|
||||
################################################################################
|
||||
# Start Action
|
||||
################################################################################
|
||||
function start
|
||||
{
|
||||
function start {
|
||||
local RET=0
|
||||
|
||||
echo -n "Starting ${scriptname}: "
|
||||
@ -129,8 +123,7 @@ function start
|
||||
################################################################################
|
||||
# Stop Action - don't do anything
|
||||
################################################################################
|
||||
function stop
|
||||
{
|
||||
function stop {
|
||||
local RET=0
|
||||
echo -n "Stopping ${scriptname}: "
|
||||
print_status ${RET}
|
||||
@ -140,7 +133,7 @@ function stop
|
||||
################################################################################
|
||||
# Restart Action
|
||||
################################################################################
|
||||
function restart() {
|
||||
function restart {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
@ -11,20 +11,17 @@ source /etc/platform/platform.conf
|
||||
################################################################################
|
||||
# Utility function to expand a sequence of numbers (e.g., 0-7,16-23)
|
||||
################################################################################
|
||||
function expand_sequence
|
||||
{
|
||||
function expand_sequence {
|
||||
SEQUENCE=(${1//,/ })
|
||||
DELIMITER=${2:-","}
|
||||
|
||||
LIST=
|
||||
for entry in ${SEQUENCE[@]}
|
||||
do
|
||||
for entry in ${SEQUENCE[@]}; do
|
||||
range=(${entry/-/ })
|
||||
a=${range[0]}
|
||||
b=${range[1]:-${range[0]}}
|
||||
|
||||
for i in $(seq $a $b)
|
||||
do
|
||||
for i in $(seq $a $b); do
|
||||
LIST="${LIST}${DELIMITER}${i}"
|
||||
done
|
||||
done
|
||||
@ -34,11 +31,10 @@ function expand_sequence
|
||||
################################################################################
|
||||
# Append a string to comma separated list string
|
||||
################################################################################
|
||||
function append_list() {
|
||||
function append_list {
|
||||
local PUSH=$1
|
||||
local LIST=$2
|
||||
if [ -z "${LIST}" ]
|
||||
then
|
||||
if [ -z "${LIST}" ]; then
|
||||
LIST=${PUSH}
|
||||
else
|
||||
LIST="${LIST},${PUSH}"
|
||||
@ -50,13 +46,12 @@ function append_list() {
|
||||
################################################################################
|
||||
# Condense a sequence of numbers to a list of ranges (e.g, 7-12,15-16)
|
||||
################################################################################
|
||||
function condense_sequence() {
|
||||
function condense_sequence {
|
||||
local arr=( $(printf '%s\n' "$@" | sort -n) )
|
||||
local first
|
||||
local last
|
||||
local cpulist=""
|
||||
for ((i=0; i < ${#arr[@]}; i++))
|
||||
do
|
||||
for ((i=0; i < ${#arr[@]}; i++)); do
|
||||
num=${arr[$i]}
|
||||
if [[ -z $first ]]; then
|
||||
first=$num
|
||||
@ -89,19 +84,16 @@ function condense_sequence() {
|
||||
# number but without the leading "0x" characters.
|
||||
#
|
||||
################################################################################
|
||||
function cpulist_to_cpumap
|
||||
{
|
||||
function cpulist_to_cpumap {
|
||||
local CPULIST=$1
|
||||
local NR_CPUS=$2
|
||||
local CPUMAP=0
|
||||
local CPUID=0
|
||||
if [ -z "${NR_CPUS}" ] || [ ${NR_CPUS} -eq 0 ]
|
||||
then
|
||||
if [ -z "${NR_CPUS}" ] || [ ${NR_CPUS} -eq 0 ]; then
|
||||
echo 0
|
||||
return 0
|
||||
fi
|
||||
for CPUID in $(expand_sequence $CPULIST " ")
|
||||
do
|
||||
for CPUID in $(expand_sequence $CPULIST " "); do
|
||||
if [ "${CPUID}" -lt "${NR_CPUS}" ]; then
|
||||
CPUMAP=$(echo "${CPUMAP} + (2^${CPUID})" | bc -l)
|
||||
fi
|
||||
@ -117,9 +109,9 @@ function cpulist_to_cpumap
|
||||
# characters.
|
||||
#
|
||||
################################################################################
|
||||
function cpumap_to_cpulist
|
||||
{
|
||||
local CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
function cpumap_to_cpulist {
|
||||
local CPUMAP
|
||||
CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
local NR_CPUS=$2
|
||||
local list=()
|
||||
local cpulist=""
|
||||
@ -131,8 +123,7 @@ function cpumap_to_cpulist
|
||||
## if (CPUMAP % (2**(CPUID+1)) > ((2**(CPUID)) - 1))
|
||||
##
|
||||
ISSET=$(echo "scale=0; (${CPUMAP} % 2^(${i}+1)) > (2^${i})-1" | bc -l)
|
||||
if [ "${ISSET}" -ne 0 ]
|
||||
then
|
||||
if [ "${ISSET}" -ne 0 ]; then
|
||||
list+=($i)
|
||||
fi
|
||||
done
|
||||
@ -146,20 +137,19 @@ function cpumap_to_cpulist
|
||||
# returned as a hexidecimal value but without the leading "0x" characters
|
||||
#
|
||||
################################################################################
|
||||
function invert_cpumap
|
||||
{
|
||||
local CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
function invert_cpumap {
|
||||
local CPUMAP
|
||||
CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
local NR_CPUS=$2
|
||||
local INVERSE_CPUMAP=0
|
||||
|
||||
for CPUID in $(seq 0 $((NR_CPUS - 1)));
|
||||
do
|
||||
for CPUID in $(seq 0 $((NR_CPUS - 1))); do
|
||||
## See comment in previous function
|
||||
ISSET=$(echo "scale=0; (${CPUMAP} % 2^(${CPUID}+1)) > (2^${CPUID})-1" | bc -l)
|
||||
if [ "${ISSET}" -eq 1 ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
INVERSE_CPUMAP=$(echo "${INVERSE_CPUMAP} + (2^${CPUID})" | bc -l)
|
||||
done
|
||||
|
||||
@ -171,11 +161,11 @@ function invert_cpumap
|
||||
# Builds the complement representation of a CPULIST
|
||||
#
|
||||
################################################################################
|
||||
function invert_cpulist
|
||||
{
|
||||
function invert_cpulist {
|
||||
local CPULIST=$1
|
||||
local NR_CPUS=$2
|
||||
local CPUMAP=$(cpulist_to_cpumap ${CPULIST} ${NR_CPUS})
|
||||
local CPUMAP
|
||||
CPUMAP=$(cpulist_to_cpumap ${CPULIST} ${NR_CPUS})
|
||||
cpumap_to_cpulist $(invert_cpumap ${CPUMAP} ${NR_CPUS}) ${NR_CPUS}
|
||||
return 0
|
||||
}
|
||||
@ -188,17 +178,17 @@ function invert_cpulist
|
||||
# 1 - item is not contained in list
|
||||
#
|
||||
################################################################################
|
||||
function in_list() {
|
||||
function in_list {
|
||||
local item="$1"
|
||||
local list="$2"
|
||||
|
||||
# expand list format 0-3,8-11 to a full sequence {0..3} {8..11}
|
||||
local exp_list=$(echo ${list} | \
|
||||
local exp_list
|
||||
exp_list=$(echo ${list} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
|
||||
local e
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
[[ "$e" == "$item" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
@ -212,7 +202,7 @@ function in_list() {
|
||||
# 1 - no sublist items contained in list
|
||||
#
|
||||
################################################################################
|
||||
function any_in_list() {
|
||||
function any_in_list {
|
||||
local sublist="$1"
|
||||
local list="$2"
|
||||
local e
|
||||
@ -222,8 +212,7 @@ function any_in_list() {
|
||||
exp_list=$(echo ${list} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
declare -A a_list
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
a_list[$e]=1
|
||||
done
|
||||
|
||||
@ -231,16 +220,13 @@ function any_in_list() {
|
||||
exp_list=$(echo ${sublist} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
declare -A a_sublist
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
a_sublist[$e]=1
|
||||
done
|
||||
|
||||
# Check if any element of sublist is in list
|
||||
for e in "${!a_sublist[@]}"
|
||||
do
|
||||
if [[ "${a_list[$e]}" == 1 ]]
|
||||
then
|
||||
for e in "${!a_sublist[@]}"; do
|
||||
if [[ "${a_list[$e]}" == 1 ]]; then
|
||||
return 0 # matches
|
||||
fi
|
||||
done
|
||||
@ -250,7 +236,7 @@ function any_in_list() {
|
||||
################################################################################
|
||||
# Return list of CPUs reserved for platform
|
||||
################################################################################
|
||||
function get_platform_cpu_list() {
|
||||
function get_platform_cpu_list {
|
||||
## Define platform cpulist based on engineering a number of cores and
|
||||
## whether this is a combo or not, and include SMT siblings.
|
||||
if [[ $subfunction = *compute* ]]; then
|
||||
@ -266,16 +252,17 @@ function get_platform_cpu_list() {
|
||||
local PLATFORM_START=0
|
||||
local PLATFORM_CORES=1
|
||||
if [ "$nodetype" = "controller" ]; then
|
||||
((PLATFORM_CORES+=1))
|
||||
PLATFORM_CORES=$(($PLATFORM_CORES+1))
|
||||
fi
|
||||
local PLATFORM_CPULIST=$(topology_to_cpulist ${PLATFORM_SOCKET} ${PLATFORM_START} ${PLATFORM_CORES})
|
||||
local PLATFORM_CPULIST
|
||||
PLATFORM_CPULIST=$(topology_to_cpulist ${PLATFORM_SOCKET} ${PLATFORM_START} ${PLATFORM_CORES})
|
||||
echo ${PLATFORM_CPULIST}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return list of CPUs reserved for vswitch
|
||||
################################################################################
|
||||
function get_vswitch_cpu_list() {
|
||||
function get_vswitch_cpu_list {
|
||||
## Define default avp cpulist based on engineered number of platform cores,
|
||||
## engineered avp cores, and include SMT siblings.
|
||||
if [[ $subfunction = *compute* ]]; then
|
||||
@ -287,12 +274,13 @@ function get_vswitch_cpu_list() {
|
||||
fi
|
||||
fi
|
||||
|
||||
local N_CORES_IN_PKG=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
local N_CORES_IN_PKG
|
||||
N_CORES_IN_PKG=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
awk '/^cpu cores/ {n = $4} END { print (n>0) ? n : 1 }')
|
||||
# engineer platform cores
|
||||
local PLATFORM_CORES=1
|
||||
if [ "$nodetype" = "controller" ]; then
|
||||
((PLATFORM_CORES+=1))
|
||||
PLATFORM_CORES=$(($PLATFORM_CORES+1))
|
||||
fi
|
||||
|
||||
# engineer AVP cores
|
||||
@ -300,35 +288,33 @@ function get_vswitch_cpu_list() {
|
||||
local AVP_START=${PLATFORM_CORES}
|
||||
local AVP_CORES=1
|
||||
if [ ${N_CORES_IN_PKG} -gt 4 ]; then
|
||||
((AVP_CORES+=1))
|
||||
AVP_CORES=$(($AVP_CORES+1))
|
||||
fi
|
||||
local AVP_CPULIST=$(topology_to_cpulist ${AVP_SOCKET} ${AVP_START} ${AVP_CORES})
|
||||
local AVP_CPULIST
|
||||
AVP_CPULIST=$(topology_to_cpulist ${AVP_SOCKET} ${AVP_START} ${AVP_CORES})
|
||||
echo ${AVP_CPULIST}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# vswitch_expanded_cpu_list() - compute the vswitch cpu list, including it's siblings
|
||||
################################################################################
|
||||
function vswitch_expanded_cpu_list() {
|
||||
function vswitch_expanded_cpu_list {
|
||||
list=$(get_vswitch_cpu_list)
|
||||
|
||||
# Expand vswitch cpulist
|
||||
vswitch_cpulist=$(expand_sequence ${list} " ")
|
||||
|
||||
cpulist=""
|
||||
for e in $vswitch_cpulist
|
||||
do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist
|
||||
do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
for e in $vswitch_cpulist; do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist; do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]; then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "$cpulist"
|
||||
@ -338,26 +324,23 @@ function vswitch_expanded_cpu_list() {
|
||||
################################################################################
|
||||
# platform_expanded_cpu_list() - compute the platform cpu list, including it's siblings
|
||||
################################################################################
|
||||
function platform_expanded_cpu_list() {
|
||||
function platform_expanded_cpu_list {
|
||||
list=$(get_platform_cpu_list)
|
||||
|
||||
# Expand platform cpulist
|
||||
platform_cpulist=$(expand_sequence ${list} " ")
|
||||
|
||||
cpulist=""
|
||||
for e in $platform_cpulist
|
||||
do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist
|
||||
do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
for e in $platform_cpulist; do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist; do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]; then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "$cpulist"
|
||||
@ -368,32 +351,33 @@ function platform_expanded_cpu_list() {
|
||||
# Return list of CPUs based on cpu topology. Select the socket, starting core
|
||||
# within the socket, select number of cores, and SMT siblings.
|
||||
################################################################################
|
||||
function topology_to_cpulist() {
|
||||
function topology_to_cpulist {
|
||||
local SOCKET=$1
|
||||
local CORE_START=$2
|
||||
local NUM_CORES=$3
|
||||
local CPULIST=$(cat /proc/cpuinfo 2>/dev/null | perl -sne \
|
||||
local CPULIST
|
||||
CPULIST=$(cat /proc/cpuinfo 2>/dev/null | perl -sne \
|
||||
'BEGIN { %T = {}; %H = {}; $L = $P = $C = $S = 0; }
|
||||
{
|
||||
if (/processor\s+:\s+(\d+)/) { $L = $1; }
|
||||
if (/physical id\s+:\s+(\d+)/) { $P = $1; }
|
||||
if (/core id\s+:\s+(\d+)/) {
|
||||
$C = $1;
|
||||
$T{$P}{$C}++;
|
||||
$S = $T{$P}{$C};
|
||||
$H{$P}{$C}{$S} = $L;
|
||||
}
|
||||
if (/processor\s+:\s+(\d+)/) { $L = $1; }
|
||||
if (/physical id\s+:\s+(\d+)/) { $P = $1; }
|
||||
if (/core id\s+:\s+(\d+)/) {
|
||||
$C = $1;
|
||||
$T{$P}{$C}++;
|
||||
$S = $T{$P}{$C};
|
||||
$H{$P}{$C}{$S} = $L;
|
||||
}
|
||||
}
|
||||
END {
|
||||
@cores = sort { $a <=> $b } keys $T{$socket};
|
||||
@sel_cores = splice @cores, $core_start, $num_cores;
|
||||
@lcpus = ();
|
||||
for $C (@sel_cores) {
|
||||
for $S (sort {$a <=> $b } keys %{ $H{$socket}{$C} }) {
|
||||
push @lcpus, $H{$socket}{$C}{$S};
|
||||
@cores = sort { $a <=> $b } keys $T{$socket};
|
||||
@sel_cores = splice @cores, $core_start, $num_cores;
|
||||
@lcpus = ();
|
||||
for $C (@sel_cores) {
|
||||
for $S (sort {$a <=> $b } keys %{ $H{$socket}{$C} }) {
|
||||
push @lcpus, $H{$socket}{$C}{$S};
|
||||
}
|
||||
}
|
||||
}
|
||||
printf "%s\n", join(",", @lcpus);
|
||||
printf "%s\n", join(",", @lcpus);
|
||||
}' -- -socket=${SOCKET} -core_start=${CORE_START} -num_cores=${NUM_CORES})
|
||||
echo ${CPULIST}
|
||||
echo ${CPULIST}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ if [ ! -z ${1} ]; then
|
||||
NR_CPUS_LIST=(${1//,/ })
|
||||
fi
|
||||
|
||||
function test_cpumap_to_cpulist()
|
||||
{
|
||||
function test_cpumap_to_cpulist {
|
||||
local NR_CPUS=$1
|
||||
declare -A CPULISTS
|
||||
|
||||
@ -49,9 +48,9 @@ function test_cpumap_to_cpulist()
|
||||
CPULISTS["11111111"]="0,4,8,12,16,20,24,28"
|
||||
CPULISTS["0F0F0F0F"]="0-3,8-11,16-19,24-27"
|
||||
CPULISTS["F0F0F0F0"]="4-7,12-15,20-23,28-31"
|
||||
CPULISTS["FFFFFFFF"]="0-31"
|
||||
CPULISTS["FFFFFFFE"]="1-31"
|
||||
CPULISTS["80000001"]="0,31"
|
||||
CPULISTS["FFFFFFFF"]="0-31"
|
||||
CPULISTS["FFFFFFFE"]="1-31"
|
||||
CPULISTS["80000001"]="0,31"
|
||||
fi
|
||||
if [ ${NR_CPUS} -ge 64 ]; then
|
||||
CPULISTS["0000000000000000"]=""
|
||||
@ -59,17 +58,17 @@ function test_cpumap_to_cpulist()
|
||||
CPULISTS["0F0F0F0F0F0F0F0F"]="0-3,8-11,16-19,24-27,32-35,40-43,48-51,56-59"
|
||||
CPULISTS["F0F0F0F0F0F0F0F0"]="4-7,12-15,20-23,28-31,36-39,44-47,52-55,60-63"
|
||||
CPULISTS["FFFFFFFFFFFFFFFF"]="0-63"
|
||||
CPULISTS["FFFFFFFFFFFFFFFE"]="1-63"
|
||||
CPULISTS["8000000000000001"]="0,63"
|
||||
CPULISTS["FFFFFFFFFFFFFFFE"]="1-63"
|
||||
CPULISTS["8000000000000001"]="0,63"
|
||||
fi
|
||||
if [ ${NR_CPUS} -ge 128 ]; then
|
||||
CPULISTS["00000000000000000000000000000000"]=""
|
||||
CPULISTS["11111111111111111111111111111111"]="0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124"
|
||||
CPULISTS["0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F"]="0-3,8-11,16-19,24-27,32-35,40-43,48-51,56-59,64-67,72-75,80-83,88-91,96-99,104-107,112-115,120-123"
|
||||
CPULISTS["F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0"]="4-7,12-15,20-23,28-31,36-39,44-47,52-55,60-63,68-71,76-79,84-87,92-95,100-103,108-111,116-119,124-127"
|
||||
CPULISTS["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]="0-127"
|
||||
CPULISTS["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"]="1-127"
|
||||
CPULISTS["80000000000000000000000000000001"]="0,127"
|
||||
CPULISTS["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]="0-127"
|
||||
CPULISTS["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"]="1-127"
|
||||
CPULISTS["80000000000000000000000000000001"]="0,127"
|
||||
fi
|
||||
|
||||
for CPUMAP in ${!CPULISTS[@]}; do
|
||||
@ -85,8 +84,7 @@ function test_cpumap_to_cpulist()
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
function test_cpulist_to_cpumap()
|
||||
{
|
||||
function test_cpulist_to_cpumap {
|
||||
local NR_CPUS=$1
|
||||
declare -A CPUMAPS
|
||||
|
||||
@ -152,8 +150,7 @@ function test_cpulist_to_cpumap()
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
function test_invert_cpumap()
|
||||
{
|
||||
function test_invert_cpumap {
|
||||
local NR_CPUS=$1
|
||||
declare -A INVERSES
|
||||
|
||||
@ -194,27 +191,27 @@ function test_invert_cpumap()
|
||||
INVERSES["F0F0F0F0"]="FFFFFFFFFFFFFFFFFFFFFFFF0F0F0F0F"
|
||||
INVERSES["FFFFFFFF"]="FFFFFFFFFFFFFFFFFFFFFFFF00000000"
|
||||
INVERSES["FFFFFFFE"]="FFFFFFFFFFFFFFFFFFFFFFFF00000001"
|
||||
INVERSES["80000001"]="FFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFE"
|
||||
INVERSES["80000001"]="FFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFE"
|
||||
fi
|
||||
if [ ${NR_CPUS} -ge 64 ]; then
|
||||
INVERSES["1111111111111111"]="FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEE"
|
||||
INVERSES["0F0F0F0F0F0F0F0F"]="FFFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0"
|
||||
INVERSES["F0F0F0F0F0F0F0F0"]="FFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0F"
|
||||
INVERSES["FFFFFFFFFFFFFFFF"]="FFFFFFFFFFFFFFFF0000000000000000"
|
||||
INVERSES["FFFFFFFFFFFFFFFE"]="FFFFFFFFFFFFFFFF0000000000000001"
|
||||
INVERSES["8000000000000001"]="FFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFE"
|
||||
INVERSES["FFFFFFFFFFFFFFFE"]="FFFFFFFFFFFFFFFF0000000000000001"
|
||||
INVERSES["8000000000000001"]="FFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFE"
|
||||
fi
|
||||
if [ ${NR_CPUS} -ge 128 ]; then
|
||||
if [ ${NR_CPUS} -ge 128 ]; then
|
||||
INVERSES["11111111111111111111111111111111"]="EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
|
||||
INVERSES["0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F"]="F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0"
|
||||
INVERSES["F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0"]="0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F"
|
||||
INVERSES["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]="00000000000000000000000000000000"
|
||||
INVERSES["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"]="00000000000000000000000000000001"
|
||||
INVERSES["80000000000000000000000000000001"]="7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"
|
||||
INVERSES["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]="00000000000000000000000000000000"
|
||||
INVERSES["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"]="00000000000000000000000000000001"
|
||||
INVERSES["80000000000000000000000000000001"]="7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"
|
||||
fi
|
||||
|
||||
for CPUMAP in ${!INVERSES[@]}; do
|
||||
EXPECTED=${INVERSES[${CPUMAP}]}
|
||||
EXPECTED=${INVERSES[${CPUMAP}]}
|
||||
if [ ${NR_CPUS} -lt 128 ]; then
|
||||
EXPECTED=$(echo ${EXPECTED} | cut --complement -c1-$((32-((${NR_CPUS}+3)/4))))
|
||||
fi
|
||||
|
@ -10,8 +10,7 @@
|
||||
# Log if debug is enabled via LOG_DEBUG
|
||||
#
|
||||
################################################################################
|
||||
function log_debug
|
||||
{
|
||||
function log_debug {
|
||||
if [ ! -z "${LOG_DEBUG}" ]; then
|
||||
logger -p debug -t "$0[${PPID}]" -s "$@" 2>&1
|
||||
fi
|
||||
@ -21,8 +20,7 @@ function log_debug
|
||||
# Log unconditionally to STDERR
|
||||
#
|
||||
################################################################################
|
||||
function log_error
|
||||
{
|
||||
function log_error {
|
||||
logger -p error -t "$0[${PPID}]" -s "$@"
|
||||
}
|
||||
|
||||
@ -30,8 +28,7 @@ function log_error
|
||||
# Log unconditionally to STDOUT
|
||||
#
|
||||
################################################################################
|
||||
function log
|
||||
{
|
||||
function log {
|
||||
logger -p info -t "$0[${PPID}]" -s "$@" 2>&1
|
||||
}
|
||||
|
||||
@ -39,8 +36,7 @@ function log
|
||||
# Utility function to print the status of a command result
|
||||
#
|
||||
################################################################################
|
||||
function print_status()
|
||||
{
|
||||
function print_status {
|
||||
if [ "$1" -eq "0" ]; then
|
||||
echo "[ OK ]"
|
||||
else
|
||||
|
@ -12,16 +12,15 @@
|
||||
|
||||
printf "%6s %6s %6s %1c %2s %4s %6s %4s %-24s %2s %-16s %s\n" "PID" "TID" "PPID" "S" "PO" "NICE" "RTPRIO" "PR" "AFFINITY" "P" "COMM" "COMMAND"
|
||||
ps -eL -o pid=,lwp=,ppid=,state=,class=,nice=,rtprio=,priority=,psr=,comm=,command= | \
|
||||
while read pid tid ppid state policy nice rtprio priority psr comm command
|
||||
do
|
||||
bitmask=$(taskset -p $tid 2>/dev/null)
|
||||
aff=${bitmask##*: }
|
||||
if [ -z "${aff}" ]; then
|
||||
aff="0x0"
|
||||
else
|
||||
aff="0x${aff}"
|
||||
fi
|
||||
printf "%6d %6d %6d %1c %2s %4s %6s %4d %-24s %2d %-16s %s\n" $pid $tid $ppid $state $policy $nice $rtprio $priority $aff $psr $comm "$command"
|
||||
done
|
||||
while read pid tid ppid state policy nice rtprio priority psr comm command; do
|
||||
bitmask=$(taskset -p $tid 2>/dev/null)
|
||||
aff=${bitmask##*: }
|
||||
if [ -z "${aff}" ]; then
|
||||
aff="0x0"
|
||||
else
|
||||
aff="0x${aff}"
|
||||
fi
|
||||
printf "%6d %6d %6d %1c %2s %4s %6s %4d %-24s %2d %-16s %s\n" $pid $tid $ppid $state $policy $nice $rtprio $priority $aff $psr $comm "$command"
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
@ -37,12 +37,11 @@ CPU_LIST=$2
|
||||
NUMBER_OF_CPUS=$(getconf _NPROCESSORS_CONF 2>/dev/null)
|
||||
STATUS=1
|
||||
|
||||
for CPU_NUM in $(expand_sequence "$CPU_LIST" " ")
|
||||
do
|
||||
for CPU_NUM in $(expand_sequence "$CPU_LIST" " "); do
|
||||
# Check that we are not setting PM QoS policy for non-existing CPU
|
||||
if [ "$CPU_NUM" -lt "0" ] || [ "$CPU_NUM" -ge "$NUMBER_OF_CPUS" ]; then
|
||||
log_error "CPU number ${CPU_NUM} is invalid, available CPUs are 0-${NUMBER_OF_CPUS-1}"
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Obtain CPU wakeup latencies for all C-states available starting from operating state to deepest sleep
|
||||
@ -70,7 +69,7 @@ do
|
||||
LATENCY=${LIMITS[${#LIMITS[@]}-1]}
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
log_error "Policy is invalid, can be either low or high"
|
||||
exit 1
|
||||
esac
|
||||
|
@ -20,69 +20,66 @@ TAG="TASKAFFINITY:"
|
||||
|
||||
TASK_AFFINING_INCOMPLETE="/etc/platform/.task_affining_incomplete"
|
||||
N_CPUS=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
|
||||
awk '/^[pP]rocessor/ { n +=1 } END { print (n>0) ? n : 1}')
|
||||
FULLSET_CPUS="0-"$((N_CPUS-1))
|
||||
FULLSET_MASK=$(cpulist_to_cpumap ${FULLSET_CPUS} ${N_CPUS})
|
||||
PLATFORM_CPUS=$(get_platform_cpu_list)
|
||||
PLATFORM_CPULIST=$(get_platform_cpu_list| \
|
||||
perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg'| \
|
||||
sed 's/,/ /g')
|
||||
perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg'| \
|
||||
sed 's/,/ /g')
|
||||
VSWITCH_CPULIST=$(get_vswitch_cpu_list| \
|
||||
perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg'| \
|
||||
sed 's/,/ /g')
|
||||
perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg'| \
|
||||
sed 's/,/ /g')
|
||||
IDLE_MARK=95.0
|
||||
KERNEL=`uname -a`
|
||||
|
||||
################################################################################
|
||||
# Check if a given core is one of the platform cores
|
||||
################################################################################
|
||||
function is_platform_core()
|
||||
{
|
||||
local core=$1
|
||||
for CPU in ${PLATFORM_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
function is_platform_core {
|
||||
local core=$1
|
||||
for CPU in ${PLATFORM_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check if a given core is one of the vswitch cores
|
||||
################################################################################
|
||||
function is_vswitch_core()
|
||||
{
|
||||
local core=$1
|
||||
for CPU in ${VSWITCH_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
function is_vswitch_core {
|
||||
local core=$1
|
||||
for CPU in ${VSWITCH_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# An audit and corrective action following a swact
|
||||
################################################################################
|
||||
function audit_and_reaffine()
|
||||
{
|
||||
local mask=$1
|
||||
local cmd_str=""
|
||||
local tasklist
|
||||
function audit_and_reaffine {
|
||||
local mask=$1
|
||||
local cmd_str=""
|
||||
local tasklist
|
||||
|
||||
cmd_str="ps-sched.sh|awk '(\$9==\"$mask\") {print \$2}'"
|
||||
cmd_str="ps-sched.sh|awk '(\$9==\"$mask\") {print \$2}'"
|
||||
|
||||
tasklist=($(eval $cmd_str))
|
||||
# log_debug "cmd str = $cmd_str"
|
||||
log_debug "${TAG} There are ${#tasklist[@]} tasks to reaffine."
|
||||
tasklist=($(eval $cmd_str))
|
||||
# log_debug "cmd str = $cmd_str"
|
||||
log_debug "${TAG} There are ${#tasklist[@]} tasks to reaffine."
|
||||
|
||||
for task in ${tasklist[@]}; do
|
||||
taskset -acp ${PLATFORM_CPUS} $task &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
done
|
||||
tasklist=($(eval $cmd_str))
|
||||
[[ ${#tasklist[@]} -eq 0 ]] && return 0 || return 1
|
||||
for task in ${tasklist[@]}; do
|
||||
taskset -acp ${PLATFORM_CPUS} $task &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
done
|
||||
tasklist=($(eval $cmd_str))
|
||||
[[ ${#tasklist[@]} -eq 0 ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -93,69 +90,67 @@ function audit_and_reaffine()
|
||||
# The induced tasks migration should be done after all VMs have been restored
|
||||
# following a host reboot in AIO, hence the delay.
|
||||
################################################################################
|
||||
function move_inactive_threads_to_platform_cores()
|
||||
{
|
||||
local tasklist
|
||||
local cmd_str=""
|
||||
function move_inactive_threads_to_platform_cores {
|
||||
local tasklist
|
||||
local cmd_str=""
|
||||
|
||||
# Compile a list of non-kernel & non-vswitch/VM related threads that are not
|
||||
# on platform cores.
|
||||
# e.g. if the platform cpulist value is "0 8", the resulting command to be
|
||||
# evaluated should look like this:
|
||||
# ps-sched.sh|grep -v vswitch|awk '($10!=0 && $10!=8 && $3!=2) {if(NR>1)print $2}'
|
||||
cmd_str="ps-sched.sh|grep -v vswitch|awk '("
|
||||
for cpu_num in ${PLATFORM_CPULIST}; do
|
||||
cmd_str=$cmd_str"\$10!="${cpu_num}" && "
|
||||
done
|
||||
cmd_str=$cmd_str"\$3!=2) {if(NR>1)print \$2}'"
|
||||
echo "selection string = $cmd_str"
|
||||
tasklist=($(eval $cmd_str))
|
||||
log_debug "${TAG} There are ${#tasklist[@]} number of tasks to be moved."
|
||||
# Compile a list of non-kernel & non-vswitch/VM related threads that are not
|
||||
# on platform cores.
|
||||
# e.g. if the platform cpulist value is "0 8", the resulting command to be
|
||||
# evaluated should look like this:
|
||||
# ps-sched.sh|grep -v vswitch|awk '($10!=0 && $10!=8 && $3!=2) {if(NR>1)print $2}'
|
||||
cmd_str="ps-sched.sh|grep -v vswitch|awk '("
|
||||
for cpu_num in ${PLATFORM_CPULIST}; do
|
||||
cmd_str=$cmd_str"\$10!="${cpu_num}" && "
|
||||
done
|
||||
cmd_str=$cmd_str"\$3!=2) {if(NR>1)print \$2}'"
|
||||
echo "selection string = $cmd_str"
|
||||
tasklist=($(eval $cmd_str))
|
||||
log_debug "${TAG} There are ${#tasklist[@]} number of tasks to be moved."
|
||||
|
||||
# These sleep tasks are stuck on the wrong core(s). They need to be woken up
|
||||
# so they can be migrated to the right ones. Attaching and detaching strace
|
||||
# momentarily to the task does the trick.
|
||||
for task in ${tasklist[@]}; do
|
||||
strace -p $task 2>/dev/null &
|
||||
pid=$!
|
||||
sleep 0.1
|
||||
kill -SIGINT $pid
|
||||
done
|
||||
tasklist=($(eval $cmd_str))
|
||||
[[ ${#tasklist[@]} -eq 0 ]] && return 0 || return 1
|
||||
# These sleep tasks are stuck on the wrong core(s). They need to be woken up
|
||||
# so they can be migrated to the right ones. Attaching and detaching strace
|
||||
# momentarily to the task does the trick.
|
||||
for task in ${tasklist[@]}; do
|
||||
strace -p $task 2>/dev/null &
|
||||
pid=$!
|
||||
sleep 0.1
|
||||
kill -SIGINT $pid
|
||||
done
|
||||
tasklist=($(eval $cmd_str))
|
||||
[[ ${#tasklist[@]} -eq 0 ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# The following function is called by affine-platform.sh to affine tasks to
|
||||
# all available cores during initial startup and subsequent host reboots.
|
||||
################################################################################
|
||||
function affine_tasks_to_all_cores()
|
||||
{
|
||||
local pidlist
|
||||
local rc=0
|
||||
function affine_tasks_to_all_cores {
|
||||
local pidlist
|
||||
local rc=0
|
||||
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_debug "${TAG} Affining all tasks to CPU (${FULLSET_CPUS})"
|
||||
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
ppid=$(ps -o ppid= -p $pid |tr -d '[:space:]')
|
||||
if [ -z $ppid ] || [ $ppid -eq 2 ]; then
|
||||
continue
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
return 0
|
||||
fi
|
||||
log_debug "Affining pid $pid, parent pid = $ppid"
|
||||
taskset --all-tasks --pid --cpu-list ${FULLSET_CPUS} $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
done
|
||||
# Write the cpu list to a temp file which will be read and removed when
|
||||
# the tasks are reaffined back to platform cores later on.
|
||||
echo ${FULLSET_CPUS} > ${TASK_AFFINING_INCOMPLETE}
|
||||
|
||||
return $rc
|
||||
log_debug "${TAG} Affining all tasks to CPU (${FULLSET_CPUS})"
|
||||
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
ppid=$(ps -o ppid= -p $pid |tr -d '[:space:]')
|
||||
if [ -z $ppid ] || [ $ppid -eq 2 ]; then
|
||||
continue
|
||||
fi
|
||||
log_debug "Affining pid $pid, parent pid = $ppid"
|
||||
taskset --all-tasks --pid --cpu-list ${FULLSET_CPUS} $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
done
|
||||
# Write the cpu list to a temp file which will be read and removed when
|
||||
# the tasks are reaffined back to platform cores later on.
|
||||
echo ${FULLSET_CPUS} > ${TASK_AFFINING_INCOMPLETE}
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -170,75 +165,74 @@ function affine_tasks_to_all_cores()
|
||||
#
|
||||
# Kernel, vswitch and VM related tasks are untouched.
|
||||
################################################################################
|
||||
function affine_tasks_to_idle_cores()
|
||||
{
|
||||
local cpulist
|
||||
local cpuocc_list
|
||||
local vswitch_pid
|
||||
local pidlist
|
||||
local idle_cpulist
|
||||
local platform_cpus
|
||||
local rc=0
|
||||
local cpu=0
|
||||
function affine_tasks_to_idle_cores {
|
||||
local cpulist
|
||||
local cpuocc_list
|
||||
local vswitch_pid
|
||||
local pidlist
|
||||
local idle_cpulist
|
||||
local platform_cpus
|
||||
local rc=0
|
||||
local cpu=0
|
||||
|
||||
if [ -f ${TASK_AFFINING_INCOMPLETE} ]; then
|
||||
read cpulist < ${TASK_AFFINING_INCOMPLETE}
|
||||
log_debug "${TAG} Tasks have already been affined to CPU ($cpulist)."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Compile a list of cpus with idle percentage greater than 95% in the last
|
||||
# 5 seconds.
|
||||
cpuocc_list=($(sar -P ALL 1 5|grep Average|awk '{if(NR>2)print $8}'))
|
||||
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
((cpu++))
|
||||
continue
|
||||
if [ -f ${TASK_AFFINING_INCOMPLETE} ]; then
|
||||
read cpulist < ${TASK_AFFINING_INCOMPLETE}
|
||||
log_debug "${TAG} Tasks have already been affined to CPU ($cpulist)."
|
||||
return 0
|
||||
fi
|
||||
|
||||
is_platform_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
# Platform core is added to the idle list by default
|
||||
idle_cpulist=$idle_cpulist$cpu","
|
||||
else
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Compile a list of cpus with idle percentage greater than 95% in the last
|
||||
# 5 seconds.
|
||||
cpuocc_list=($(sar -P ALL 1 5|grep Average|awk '{if(NR>2)print $8}'))
|
||||
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
cpu=$(($cpu+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
is_platform_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
# Platform core is added to the idle list by default
|
||||
idle_cpulist=$idle_cpulist$cpu","
|
||||
else
|
||||
# Non platform core is added to the idle list if it is more than 95% idle
|
||||
[[ $(echo "$idle_value > ${IDLE_MARK}"|bc) -eq 1 ]] && idle_cpulist=$idle_cpulist$cpu","
|
||||
fi
|
||||
((cpu++))
|
||||
done
|
||||
[[ $(echo "$idle_value > ${IDLE_MARK}"|bc) -eq 1 ]] && idle_cpulist=$idle_cpulist$cpu","
|
||||
fi
|
||||
cpu=$(($cpu+1))
|
||||
done
|
||||
|
||||
idle_cpulist=$(echo $idle_cpulist|sed 's/.$//')
|
||||
platform_affinity_mask=$(cpulist_to_cpumap ${PLATFORM_CPUS} ${N_CPUS} \
|
||||
|awk '{print tolower($0)}')
|
||||
|
||||
log_debug "${TAG} Affining all tasks to idle CPU ($idle_cpulist)"
|
||||
idle_cpulist=$(echo $idle_cpulist|sed 's/.$//')
|
||||
platform_affinity_mask=$(cpulist_to_cpumap ${PLATFORM_CPUS} ${N_CPUS} \
|
||||
|awk '{print tolower($0)}')
|
||||
|
||||
vswitch_pid=$(pgrep vswitch)
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
ppid=$(ps -o ppid= -p $pid |tr -d '[:space:]')
|
||||
if [ -z $ppid ] || [ $ppid -eq 2 ] || [ "$pid" = "$vswitch_pid" ]; then
|
||||
continue
|
||||
fi
|
||||
pid_affinity_mask=$(taskset -p $pid | awk '{print $6}')
|
||||
if [ "${pid_affinity_mask}" == "${platform_affinity_mask}" ]; then
|
||||
# log_debug "Affining pid $pid to idle cores..."
|
||||
taskset --all-tasks --pid --cpu-list $idle_cpulist $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
fi
|
||||
done
|
||||
log_debug "${TAG} Affining all tasks to idle CPU ($idle_cpulist)"
|
||||
|
||||
# Save the cpu list to the temp file which will be read and removed when
|
||||
# tasks are reaffined to the platform cores later on.
|
||||
echo $idle_cpulist > ${TASK_AFFINING_INCOMPLETE}
|
||||
return $rc
|
||||
vswitch_pid=$(pgrep vswitch)
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
ppid=$(ps -o ppid= -p $pid |tr -d '[:space:]')
|
||||
if [ -z $ppid ] || [ $ppid -eq 2 ] || [ "$pid" = "$vswitch_pid" ]; then
|
||||
continue
|
||||
fi
|
||||
pid_affinity_mask=$(taskset -p $pid | awk '{print $6}')
|
||||
if [ "${pid_affinity_mask}" == "${platform_affinity_mask}" ]; then
|
||||
# log_debug "Affining pid $pid to idle cores..."
|
||||
taskset --all-tasks --pid --cpu-list $idle_cpulist $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
fi
|
||||
done
|
||||
|
||||
# Save the cpu list to the temp file which will be read and removed when
|
||||
# tasks are reaffined to the platform cores later on.
|
||||
echo $idle_cpulist > ${TASK_AFFINING_INCOMPLETE}
|
||||
return $rc
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -248,83 +242,81 @@ function affine_tasks_to_idle_cores()
|
||||
# b) sm at the end of swact sequence
|
||||
# to re-affine management tasks back to the platform cores.
|
||||
################################################################################
|
||||
function affine_tasks_to_platform_cores()
|
||||
{
|
||||
local cpulist
|
||||
local pidlist
|
||||
local rc=0
|
||||
local count=0
|
||||
function affine_tasks_to_platform_cores {
|
||||
local cpulist
|
||||
local pidlist
|
||||
local rc=0
|
||||
local count=0
|
||||
|
||||
if [ ! -f ${TASK_AFFINING_INCOMPLETE} ]; then
|
||||
dbg_str="${TAG} Either tasks have never been affined to all/idle cores or"
|
||||
dbg_str=$dbg_str" they have already been reaffined to platform cores."
|
||||
log_debug "$dbg_str"
|
||||
return 0
|
||||
fi
|
||||
|
||||
read cpulist < ${TASK_AFFINING_INCOMPLETE}
|
||||
affinity_mask=$(cpulist_to_cpumap $cpulist ${N_CPUS}|awk '{print tolower($0)}')
|
||||
|
||||
log_debug "${TAG} Reaffining tasks to platform cores (${PLATFORM_CPUS})..."
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
# log_debug "Processing pid $pid..."
|
||||
pid_affinity_mask=$(taskset -p $pid | awk '{print $6}')
|
||||
# Only management tasks need to be reaffined. Kernel, vswitch and VM related
|
||||
# tasks were not affined previously so they should have different affinity
|
||||
# mask(s).
|
||||
if [ "${pid_affinity_mask}" == "${affinity_mask}" ]; then
|
||||
((count++))
|
||||
# log_debug "Affining pid $pid to platform cores..."
|
||||
taskset --all-tasks --pid --cpu-list ${PLATFORM_CPUS} $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
if [ ! -f ${TASK_AFFINING_INCOMPLETE} ]; then
|
||||
dbg_str="${TAG} Either tasks have never been affined to all/idle cores or"
|
||||
dbg_str=$dbg_str" they have already been reaffined to platform cores."
|
||||
log_debug "$dbg_str"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# A workaround for lack of "end of swact" state
|
||||
fullmask=$(echo ${FULLSET_MASK} | awk '{print tolower($0)}')
|
||||
if [ "${affinity_mask}" != "${fullmask}" ]; then
|
||||
log_debug "${TAG} Schedule an audit and cleanup"
|
||||
(sleep 60; audit_and_reaffine "0x"$affinity_mask) &
|
||||
fi
|
||||
read cpulist < ${TASK_AFFINING_INCOMPLETE}
|
||||
affinity_mask=$(cpulist_to_cpumap $cpulist ${N_CPUS}|awk '{print tolower($0)}')
|
||||
|
||||
rm -rf ${TASK_AFFINING_INCOMPLETE}
|
||||
log_debug "${TAG} $count tasks were reaffined to platform cores."
|
||||
log_debug "${TAG} Reaffining tasks to platform cores (${PLATFORM_CPUS})..."
|
||||
pidlist=$(ps --ppid 2 -p 2 --deselect -o pid= | awk '{ print $1; }')
|
||||
for pid in ${pidlist[@]}; do
|
||||
# log_debug "Processing pid $pid..."
|
||||
pid_affinity_mask=$(taskset -p $pid | awk '{print $6}')
|
||||
# Only management tasks need to be reaffined. Kernel, vswitch and VM related
|
||||
# tasks were not affined previously so they should have different affinity
|
||||
# mask(s).
|
||||
if [ "${pid_affinity_mask}" == "${affinity_mask}" ]; then
|
||||
count=$(($count+1))
|
||||
# log_debug "Affining pid $pid to platform cores..."
|
||||
taskset --all-tasks --pid --cpu-list ${PLATFORM_CPUS} $pid &> /dev/null
|
||||
rc=$?
|
||||
[[ $rc -ne 0 ]] && log_error "Failed to set CPU affinity for pid $pid, rc=$rc"
|
||||
fi
|
||||
done
|
||||
|
||||
return $rc
|
||||
# A workaround for lack of "end of swact" state
|
||||
fullmask=$(echo ${FULLSET_MASK} | awk '{print tolower($0)}')
|
||||
if [ "${affinity_mask}" != "${fullmask}" ]; then
|
||||
log_debug "${TAG} Schedule an audit and cleanup"
|
||||
(sleep 60; audit_and_reaffine "0x"$affinity_mask) &
|
||||
fi
|
||||
|
||||
rm -rf ${TASK_AFFINING_INCOMPLETE}
|
||||
log_debug "${TAG} $count tasks were reaffined to platform cores."
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# The following function can be leveraged by cron tasks
|
||||
################################################################################
|
||||
function get_most_idle_core()
|
||||
{
|
||||
local cpuocc_list
|
||||
local cpu=0
|
||||
local most_idle_value=${IDLE_MARK}
|
||||
local most_idle_cpu=0
|
||||
function get_most_idle_core {
|
||||
local cpuocc_list
|
||||
local cpu=0
|
||||
local most_idle_value=${IDLE_MARK}
|
||||
local most_idle_cpu=0
|
||||
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
echo $cpu
|
||||
return
|
||||
fi
|
||||
|
||||
cpuocc_list=($(sar -P ALL 1 5|grep Average|awk '{if(NR>2)print $8}'))
|
||||
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
((cpu++))
|
||||
continue
|
||||
if [[ "${KERNEL}" == *" RT "* ]]; then
|
||||
echo $cpu
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $(echo "$idle_value > $most_idle_value"|bc) -eq 1 ]; then
|
||||
most_idle_value=$idle_value
|
||||
most_idle_cpu=$cpu
|
||||
fi
|
||||
((cpu++))
|
||||
done
|
||||
cpuocc_list=($(sar -P ALL 1 5|grep Average|awk '{if(NR>2)print $8}'))
|
||||
|
||||
echo $most_idle_cpu
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
cpu=$(($cpu+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $(echo "$idle_value > $most_idle_value"|bc) -eq 1 ]; then
|
||||
most_idle_value=$idle_value
|
||||
most_idle_cpu=$cpu
|
||||
fi
|
||||
cpu=$(($cpu+1))
|
||||
done
|
||||
|
||||
echo $most_idle_cpu
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
SERVICE=computeconfig.service
|
||||
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
systemctl status $SERVICE |grep -q running
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
|
@ -25,8 +25,7 @@ case $nodetype in
|
||||
;;
|
||||
esac
|
||||
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
systemctl status $SERVICE |grep -q running
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
|
@ -49,8 +49,7 @@ function log {
|
||||
log "$NAME: performing sample migration from release $FROM_RELEASE to $TO_RELEASE with action $ACTION"
|
||||
|
||||
|
||||
if [ "$FROM_RELEASE" == "17.06" ] && [ "$ACTION" == "migrate" ]
|
||||
then
|
||||
if [ "$FROM_RELEASE" == "17.06" ] && [ "$ACTION" == "migrate" ]; then
|
||||
log "Sample migration from release $FROM_RELEASE"
|
||||
fi
|
||||
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
NOVAOPENRC="/etc/nova/openrc"
|
||||
if [ -e ${NOVAOPENRC} ] ; then
|
||||
source ${NOVAOPENRC} &>/dev/null
|
||||
source ${NOVAOPENRC} &>/dev/null
|
||||
else
|
||||
echo "Admin credentials not found"
|
||||
exit
|
||||
echo "Admin credentials not found"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Delete all the servers
|
||||
|
@ -33,11 +33,9 @@ function do_escape {
|
||||
echo $val_escaped
|
||||
}
|
||||
|
||||
if [ "$ACTION" == "migrate" ]
|
||||
then
|
||||
if [ "$ACTION" == "migrate" ]; then
|
||||
log "Creating new $NEW_PIPELINE_FILE file for release $TO_RELEASE"
|
||||
if [ ! -d "$NEW_PIPELINE_DIR" ]
|
||||
then
|
||||
if [ ! -d "$NEW_PIPELINE_DIR" ]; then
|
||||
mkdir $NEW_PIPELINE_DIR
|
||||
fi
|
||||
cp $PIPELINE_SOURCE_FILE $NEW_PIPELINE_FILE
|
||||
|
@ -15,7 +15,6 @@ source $DEST/stx-config/devstack/lib/stx-config
|
||||
# check for service enabled
|
||||
|
||||
if is_service_enabled sysinv-api sysinv-cond; then
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
# Perform installation of sysinv source
|
||||
echo_summary "Installing cgts_client"
|
||||
|
@ -31,29 +31,29 @@ if [ ! -d /var/run/network-scripts.puppet/ ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function log_it() {
|
||||
function log_it {
|
||||
logger "${0} ${1}"
|
||||
}
|
||||
|
||||
function do_if_up() {
|
||||
function do_if_up {
|
||||
local iface=$1
|
||||
log_it "Bringing $iface up"
|
||||
/sbin/ifup $iface
|
||||
}
|
||||
|
||||
function do_if_down() {
|
||||
function do_if_down {
|
||||
local iface=$1
|
||||
log_it "Bringing $iface down"
|
||||
/sbin/ifdown $iface
|
||||
}
|
||||
|
||||
function do_rm() {
|
||||
function do_rm {
|
||||
local theFile=$1
|
||||
log_it "Removing $theFile"
|
||||
/bin/rm $theFile
|
||||
}
|
||||
|
||||
function do_cp() {
|
||||
function do_cp {
|
||||
local srcFile=$1
|
||||
local dstFile=$2
|
||||
log_it "copying network cfg $srcFile to $dstFile"
|
||||
@ -76,10 +76,11 @@ array_diff () {
|
||||
echo ${result[@]}
|
||||
}
|
||||
|
||||
function normalized_cfg_attr_value() {
|
||||
function normalized_cfg_attr_value {
|
||||
local cfg=$1
|
||||
local attr_name=$2
|
||||
local attr_value=$(cat $cfg | grep $attr_name= | awk -F "=" {'print $2'})
|
||||
local attr_value
|
||||
attr_value=$(cat $cfg | grep $attr_name= | awk -F "=" {'print $2'})
|
||||
|
||||
|
||||
#
|
||||
@ -93,13 +94,13 @@ function normalized_cfg_attr_value() {
|
||||
# line.
|
||||
#
|
||||
if [[ "${attr_name}" == "BONDING_OPTS" ]]; then
|
||||
echo "$(cat $cfg | grep $attr_name=)"
|
||||
return $(true)
|
||||
echo "$(cat $cfg | grep $attr_name=)"
|
||||
return $(true)
|
||||
fi
|
||||
|
||||
if [[ "${attr_name}" != "BOOTPROTO" ]]; then
|
||||
echo "${attr_value}"
|
||||
return $(true)
|
||||
echo "${attr_value}"
|
||||
return $(true)
|
||||
fi
|
||||
#
|
||||
# Special case BOOTPROTO attribute.
|
||||
@ -124,13 +125,13 @@ function normalized_cfg_attr_value() {
|
||||
# "dhcp".
|
||||
#
|
||||
if [[ "${attr_value}" == "none" ]]; then
|
||||
attr_value="none"
|
||||
attr_value="none"
|
||||
fi
|
||||
if [[ "${attr_value}" == "manual" ]]; then
|
||||
attr_value="none"
|
||||
attr_value="none"
|
||||
fi
|
||||
if [[ "${attr_value}" == "" ]]; then
|
||||
attr_value="none"
|
||||
attr_value="none"
|
||||
fi
|
||||
echo "${attr_value}"
|
||||
return $(true)
|
||||
@ -139,7 +140,7 @@ function normalized_cfg_attr_value() {
|
||||
#
|
||||
# returns $(true) if cfg file ( $1 ) has property propName ( $2 ) with a value of propValue ( $3 )
|
||||
#
|
||||
function cfg_has_property_with_value() {
|
||||
function cfg_has_property_with_value {
|
||||
local cfg=$1
|
||||
local propname=$2
|
||||
local propvalue=$3
|
||||
@ -154,7 +155,7 @@ function cfg_has_property_with_value() {
|
||||
#
|
||||
# returns $(true) if cfg file is configured as a slave
|
||||
#
|
||||
function is_slave() {
|
||||
function is_slave {
|
||||
cfg_has_property_with_value $1 "SLAVE" "yes"
|
||||
return $?
|
||||
}
|
||||
@ -162,14 +163,14 @@ function is_slave() {
|
||||
#
|
||||
# returns $(true) if cfg file is configured for DHCP
|
||||
#
|
||||
function is_dhcp() {
|
||||
function is_dhcp {
|
||||
cfg_has_property_with_value $1 "BOOTPROTO" "dhcp"
|
||||
}
|
||||
|
||||
#
|
||||
# returns $(true) if cfg file is configured as a VLAN interface
|
||||
#
|
||||
function is_vlan() {
|
||||
function is_vlan {
|
||||
cfg_has_property_with_value $1 "VLAN" "yes"
|
||||
return $?
|
||||
}
|
||||
@ -180,7 +181,7 @@ function is_vlan() {
|
||||
# a vlan or a slave. This includes both regular ethernet interfaces and bonded
|
||||
# interfaces.
|
||||
#
|
||||
function is_ethernet() {
|
||||
function is_ethernet {
|
||||
if ! is_vlan $1; then
|
||||
if ! is_slave $1; then
|
||||
return $(true)
|
||||
@ -192,7 +193,7 @@ function is_ethernet() {
|
||||
#
|
||||
# returns $(true) if cfg file represents an interface of the specified type.
|
||||
#
|
||||
function iftype_filter() {
|
||||
function iftype_filter {
|
||||
local iftype=$1
|
||||
|
||||
return $(is_$iftype $2)
|
||||
@ -202,22 +203,23 @@ function iftype_filter() {
|
||||
# returns $(true) if ifcfg files have the same number of VFs
|
||||
#
|
||||
#
|
||||
function is_eq_sriov_numvfs() {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
function is_eq_sriov_numvfs {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
local sriov_numvfs_1
|
||||
sriov_numvfs_1=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_1 | awk {'print $2'})
|
||||
local sriov_numvfs_2
|
||||
sriov_numvfs_2=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_2 | awk {'print $2'})
|
||||
|
||||
local sriov_numvfs_1=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_1 | awk {'print $2'})
|
||||
local sriov_numvfs_2=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_2 | awk {'print $2'})
|
||||
sriov_numvfs_1=${sriov_numvfs_1:-0}
|
||||
sriov_numvfs_2=${sriov_numvfs_2:-0}
|
||||
|
||||
sriov_numvfs_1=${sriov_numvfs_1:-0}
|
||||
sriov_numvfs_2=${sriov_numvfs_2:-0}
|
||||
if [[ "${sriov_numvfs_1}" != "${sriov_numvfs_2}" ]]; then
|
||||
log_it "$cfg_1 and $cfg_2 differ on attribute sriov_numvfs [${sriov_numvfs_1}:${sriov_numvfs_2}]"
|
||||
return $(false)
|
||||
fi
|
||||
|
||||
if [[ "${sriov_numvfs_1}" != "${sriov_numvfs_2}" ]]; then
|
||||
log_it "$cfg_1 and $cfg_2 differ on attribute sriov_numvfs [${sriov_numvfs_1}:${sriov_numvfs_2}]"
|
||||
return $(false)
|
||||
fi
|
||||
|
||||
return $(true)
|
||||
return $(true)
|
||||
}
|
||||
|
||||
#
|
||||
@ -226,51 +228,52 @@ function is_eq_sriov_numvfs() {
|
||||
# Warning: Only compares against cfg file attributes:
|
||||
# BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS SRIOV_NUMVFS
|
||||
#
|
||||
function is_eq_ifcfg() {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
function is_eq_ifcfg {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
|
||||
for attr in BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS
|
||||
do
|
||||
local attr_value1=$(normalized_cfg_attr_value $cfg_1 $attr)
|
||||
local attr_value2=$(normalized_cfg_attr_value $cfg_2 $attr)
|
||||
if [[ "${attr_value1}" != "${attr_value2}" ]]; then
|
||||
log_it "$cfg_1 and $cfg_2 differ on attribute $attr"
|
||||
return $(false)
|
||||
fi
|
||||
done
|
||||
for attr in BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS; do
|
||||
local attr_value1
|
||||
attr_value1=$(normalized_cfg_attr_value $cfg_1 $attr)
|
||||
local attr_value2
|
||||
attr_value2=$(normalized_cfg_attr_value $cfg_2 $attr)
|
||||
if [[ "${attr_value1}" != "${attr_value2}" ]]; then
|
||||
log_it "$cfg_1 and $cfg_2 differ on attribute $attr"
|
||||
return $(false)
|
||||
fi
|
||||
done
|
||||
|
||||
is_eq_sriov_numvfs $1 $2
|
||||
return $?
|
||||
is_eq_sriov_numvfs $1 $2
|
||||
return $?
|
||||
}
|
||||
|
||||
# Synchronize with sysinv-agent audit (ifup/down to query link speed).
|
||||
function sysinv_agent_lock() {
|
||||
case $1 in
|
||||
$ACQUIRE_LOCK)
|
||||
local lock_file="/var/run/apply_network_config.lock"
|
||||
# Lock file should be the same as defined in sysinv agent code
|
||||
local lock_timeout=5
|
||||
local max=15
|
||||
local n=1
|
||||
LOCK_FD=0
|
||||
exec {LOCK_FD}>$lock_file
|
||||
while [[ $n -le $max ]]
|
||||
do
|
||||
flock -w $lock_timeout $LOCK_FD && break
|
||||
log_it "Failed to get lock($LOCK_FD) after $lock_timeout seconds ($n/$max), will retry"
|
||||
sleep 1
|
||||
((n++))
|
||||
done
|
||||
if [[ $n -gt $max ]]; then
|
||||
log_it "Failed to acquire lock($LOCK_FD) even after $max retries"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
$RELEASE_LOCK)
|
||||
[[ $LOCK_FD -gt 0 ]] && flock -u $LOCK_FD
|
||||
;;
|
||||
esac
|
||||
function sysinv_agent_lock {
|
||||
case $1 in
|
||||
$ACQUIRE_LOCK)
|
||||
local lock_file="/var/run/apply_network_config.lock"
|
||||
# Lock file should be the same as defined in sysinv agent code
|
||||
local lock_timeout=5
|
||||
local max=15
|
||||
local n=1
|
||||
LOCK_FD=0
|
||||
exec {LOCK_FD}>$lock_file
|
||||
while [[ $n -le $max ]]; do
|
||||
|
||||
flock -w $lock_timeout $LOCK_FD && break
|
||||
log_it "Failed to get lock($LOCK_FD) after $lock_timeout seconds ($n/$max), will retry"
|
||||
sleep 1
|
||||
n=$(($n+1))
|
||||
done
|
||||
if [[ $n -gt $max ]]; then
|
||||
log_it "Failed to acquire lock($LOCK_FD) even after $max retries"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
$RELEASE_LOCK)
|
||||
[[ $LOCK_FD -gt 0 ]] && flock -u $LOCK_FD
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# First thing to do is deal with the case of there being no routes left on an interface.
|
||||
@ -310,7 +313,7 @@ for rt_path in $(find /var/run/network-scripts.puppet/ -name "${RTNAME_INCLUDE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ -s /var/run/network-scripts.puppet/$rt ] ; then
|
||||
# Whether this is a new routes file or there are changes, ultimately we will need
|
||||
# to ifup the file to add any potentially new routes.
|
||||
@ -352,16 +355,16 @@ for cfg_path in $(find /var/run/network-scripts.puppet/ -name "${IFNAME_INCLUDE}
|
||||
is_dhcp /etc/sysconfig/network-scripts/$cfg ; then
|
||||
# if dhcp type iface, then too many possible attr's to compare against, so
|
||||
# just add cfg to the upDown list because we know (from above) cfg file is changed
|
||||
log_it "dhcp detected for $cfg - adding to upDown list"
|
||||
upDown+=($cfg)
|
||||
log_it "dhcp detected for $cfg - adding to upDown list"
|
||||
upDown+=($cfg)
|
||||
else
|
||||
# not in dhcp situation so check if any significant
|
||||
# cfg attributes have changed to warrant an iface restart
|
||||
is_eq_ifcfg /var/run/network-scripts.puppet/$cfg \
|
||||
/etc/sysconfig/network-scripts/$cfg
|
||||
if [ $? -ne 0 ] ; then
|
||||
log_it "$cfg changed - adding to upDown list"
|
||||
upDown+=($cfg)
|
||||
log_it "$cfg changed - adding to upDown list"
|
||||
upDown+=($cfg)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -58,16 +58,15 @@ cp /etc/puppet/hieradata/${PERSONALITY}.yaml ${PUPPET_TMP}/hieradata/personality
|
||||
# the grub. At this time, copying the host file failed due to a timing issue that
|
||||
# has not yet been fully understood. Subsequent retries worked.
|
||||
if [ "${PERSONALITY}" = "compute" ]; then
|
||||
n=0
|
||||
until [ $n -ge 3 ]
|
||||
do
|
||||
cp -f ${HIERADATA}/${HOST}.yaml ${PUPPET_TMP}/hieradata/host.yaml && break
|
||||
n=$[$n+1]
|
||||
logger -t $0 "Failed to copy /etc/puppet/hieradata/${HOST}.yaml"
|
||||
sleep 15
|
||||
done
|
||||
n=0
|
||||
until [ $n -ge 3 ]; do
|
||||
cp -f ${HIERADATA}/${HOST}.yaml ${PUPPET_TMP}/hieradata/host.yaml && break
|
||||
n=$(($n+1))
|
||||
logger -t $0 "Failed to copy /etc/puppet/hieradata/${HOST}.yaml"
|
||||
sleep 15
|
||||
done
|
||||
else
|
||||
cp -f ${HIERADATA}/${HOST}.yaml ${PUPPET_TMP}/hieradata/host.yaml
|
||||
cp -f ${HIERADATA}/${HOST}.yaml ${PUPPET_TMP}/hieradata/host.yaml
|
||||
fi
|
||||
cp -f ${HIERADATA}/system.yaml \
|
||||
${HIERADATA}/secure_system.yaml \
|
||||
@ -81,8 +80,7 @@ fi
|
||||
|
||||
|
||||
# Exit function to save logs from initial apply
|
||||
function finish()
|
||||
{
|
||||
function finish {
|
||||
local SAVEDLOGS=/var/log/puppet/first_apply.tgz
|
||||
if [ ! -f ${SAVEDLOGS} ]; then
|
||||
# Save the logs
|
||||
@ -102,15 +100,13 @@ echo "Applying puppet ${MANIFEST} manifest..."
|
||||
flock /var/run/puppet.lock \
|
||||
puppet apply --debug --trace --modulepath ${PUPPET_MODULES_PATH} ${PUPPET_MANIFEST} \
|
||||
< /dev/null 2>&1 | awk ' { system("date -u +%FT%T.%3N | tr \"\n\" \" \""); print $0; fflush(); } ' > ${LOGFILE}
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[FAILED]"
|
||||
echo "See ${LOGFILE} for details"
|
||||
exit 1
|
||||
else
|
||||
grep -qE '^(.......)?Warning|^....-..-..T..:..:..([.]...)?(.......)?.Warning|^(.......)?Error|^....-..-..T..:..:..([.]...)?(.......)?.Error' ${LOGFILE}
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "[WARNING]"
|
||||
echo "Warnings found. See ${LOGFILE} for details"
|
||||
exit 1
|
||||
|
@ -2,7 +2,6 @@
|
||||
[ -z "$PS1" -o -n "$KUBECONFIG" ] && return
|
||||
|
||||
# Set up the location of the k8s config file for anyone who can read it.
|
||||
if [ -r /etc/kubernetes/admin.conf ]
|
||||
then
|
||||
if [ -r /etc/kubernetes/admin.conf ]; then
|
||||
export KUBECONFIG=/etc/kubernetes/admin.conf
|
||||
fi
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -13,24 +13,21 @@ SYSINV_READY_FLAG=/var/run/.sysinv_ready
|
||||
|
||||
logfile=/var/log/platform.log
|
||||
|
||||
function LOG()
|
||||
{
|
||||
function LOG {
|
||||
logger "$NAME: $*"
|
||||
echo "`date "+%FT%T"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
count=0
|
||||
while [ $count -le 45 ]
|
||||
do
|
||||
if [ -f $SYSINV_READY_FLAG ]
|
||||
then
|
||||
while [ $count -le 45 ]; do
|
||||
if [ -f $SYSINV_READY_FLAG ]; then
|
||||
LOG "SysInv is ready. Passing goenabled check."
|
||||
echo "SysInv goenabled iterations PASS $count"
|
||||
LOG "SysInv goenabled iterations PASS $count"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
(( count++ ))
|
||||
count=$(($count+1))
|
||||
done
|
||||
|
||||
echo "SysInv goenabled iterations FAIL $count"
|
||||
|
@ -33,7 +33,8 @@ wlog() {
|
||||
return
|
||||
fi
|
||||
|
||||
local head="$(date "+%Y-%m-%d %H:%M:%S.%3N") $0 $1"
|
||||
local head
|
||||
head="$(date "+%Y-%m-%d %H:%M:%S.%3N") $0 $1"
|
||||
echo "$head $2: $3" >> $LOG_FILE
|
||||
if [ "$4" = "print_trace" ]; then
|
||||
# Print out the stack trace
|
||||
@ -50,8 +51,7 @@ device_path=$1 && shift
|
||||
part_numbers=( `parted -s $device_path print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
|
||||
sector_size=$(blockdev --getss $device_path)
|
||||
|
||||
for part_number in "${part_numbers[@]}";
|
||||
do
|
||||
for part_number in "${part_numbers[@]}"; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $device_path)
|
||||
|
||||
# Parse the output and put it in the right return format.
|
||||
|
14
tox.ini
14
tox.ini
@ -21,12 +21,14 @@ commands =
|
||||
-not -name \*~ \
|
||||
-not -name \*.md \
|
||||
-name \*.sh \
|
||||
-print0 | xargs -0 bashate -v"
|
||||
bash -c "find {toxinidir} \
|
||||
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
|
||||
-o \( -name .tox -prune \) \
|
||||
-o -type f -name '*.yaml' \
|
||||
-print0 | xargs -0 yamllint"
|
||||
-print0 | xargs -0 bashate -v -e E* \
|
||||
-i E006,E010"
|
||||
|
||||
# bash -c "find {toxinidir} \
|
||||
# \( -name .tox -prune \) \
|
||||
# -o -type f -name '*.yaml' \
|
||||
# -print0 | xargs -0 yamllint -f parsable \
|
||||
# -c {toxinidir}/.yamllint"
|
||||
|
||||
[testenv:pep8]
|
||||
usedevelop = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user