forked from RHsyseng/openshift-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathport-thrashing
executable file
·43 lines (38 loc) · 1.29 KB
/
port-thrashing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# description: Checks if there are OVN pods thrashing
THRASHINGMSG="Changing chassis for lport"
NAMESPACE="openshift-ovn-kubernetes"
error=false
[ -z ${UTILSFILE} ] && source $(echo "$(dirname ${0})/../utils")
if [[ $(oc get network/cluster -o jsonpath={.spec.networkType}) != "OVNKubernetes" ]]; then
msg "This check only works for OVNKubernetes SDN"
exit ${OCSKIP}
else
if oc auth can-i get pods -n ${NAMESPACE} >/dev/null 2>&1; then
if oc auth can-i get pods --subresource=log -n ${NAMESPACE} >/dev/null 2>&1; then
for pod in $(oc get pods -o name -n ${NAMESPACE} -l app=ovnkube-node); do
numerrors=$(oc logs -n ${NAMESPACE} ${pod} -c ovn-controller | grep "${THRASHINGMSG}" -c)
if [[ ${numerrors} -gt ${THRASHING_THRESHOLD} ]]; then
msg "${RED}${pod} port thrashing errors detected${NOCOLOR}"
errors=$(("${errors}" + 1))
error=true
fi
done
if [ ! -z "${ERRORFILE}" ]; then
echo $errors >${ERRORFILE}
fi
if [[ $error == true ]]; then
exit ${OCERROR}
else
exit ${OCOK}
fi
else
msg "Couldn't get pods logs, check permissions"
exit ${OCSKIP}
fi
else
msg "Couldn't get pods, check permissions"
exit ${OCSKIP}
fi
fi
exit ${OCUNKNOWNN}