-
Notifications
You must be signed in to change notification settings - Fork 44
/
nodes
executable file
·42 lines (38 loc) · 1.54 KB
/
nodes
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
#!/usr/bin/env bash
# description: Checks if there are not ready or not schedulable nodes
[ -z ${UTILSFILE} ] && source $(echo "$(dirname ${0})/../utils")
error=false
if oc auth can-i get nodes >/dev/null 2>&1; then
nodes_not_ready=$(oc get nodes -o json | jq '.items[] | { name: .metadata.name, type: .status.conditions[] } | select ((.type.type == "Ready") and (.type.status != "True"))')
if [[ -n ${nodes_not_ready} ]]; then
NODESNOTREADY=$(echo "${nodes_not_ready}" | jq .)
msg "Nodes ${RED}NotReady${NOCOLOR}: ${NODESNOTREADY}"
errors=$(("${errors}" + 1))
error=true
fi
disabled_nodes=$(oc get nodes -o json | jq '.items[] | { name: .metadata.name, status: .spec.unschedulable } | select (.status == true)')
if [[ -n ${disabled_nodes} ]]; then
NODESDISABLED=$(echo "${disabled_nodes}" | jq .)
msg "Nodes ${RED}Disabled${NOCOLOR}: ${NODESDISABLED}"
errors=$(("${errors}" + 1))
error=true
fi
pressure_nodes=$(oc get node -o json | jq '.items[] | { name: .metadata.name, conditions: .status.conditions[] } | select ((.conditions.type | contains("Pressure")) and .conditions.status != "False")')
if [[ -n ${pressure_nodes} ]]; then
NODESPRESSURE=$(echo "${pressure_nodes}" | jq .)
msg "Nodes with ${RED}Pressure${NOCOLOR}: ${NODESPRESSURE}"
errors=$(("${errors}" + 1))
fi
if [ ! -z "${ERRORFILE}" ]; then
echo $errors >${ERRORFILE}
fi
if [[ $error == true ]]; then
exit ${OCERROR}
else
exit ${OCOK}
fi
else
msg "Couldn't get nodes, check permissions"
exit ${OCSKIP}
fi
exit ${OCUNKNOWNN}