-
Notifications
You must be signed in to change notification settings - Fork 44
/
pvc
executable file
·29 lines (25 loc) · 849 Bytes
/
pvc
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
#!/usr/bin/env bash
# description: Checks if there are persistent volume claims that are not bound
[ -z ${UTILSFILE} ] && source $(echo "$(dirname ${0})/../utils")
error=false
if oc auth can-i get pvc -A >/dev/null 2>&1; then
pvc_not_bound=$(oc get pvc -A -o json | jq '.items[] | { name: .metadata.name, namespace: .metadata.namespace, phase: .status.phase } | select (.phase!="Bound")')
if [[ -n ${pvc_not_bound} ]]; then
PVCNOTBOUND=$(echo "${pvc_not_bound}" | jq .)
msg "Persistent Volume Claims ${RED}NotBound${NOCOLOR}: ${PVCNOTBOUND}"
errors=$(("${errors}" + 1))
error=true
fi
if [ ! -z "${ERRORFILE}" ]; then
echo $errors >${ERRORFILE}
fi
if [[ $error == true ]]; then
exit ${OCERROR}
else
exit ${OCOK}
fi
else
msg "Couldn't get pvc, check permissions"
exit ${OCSKIP}
fi
exit ${OCUNKNOWN}