Add disk usage monitoring to BuildKite script.

If disk usage of any filesystem approaches or reaches 100%, the agent
will log its disk usage to the console, and then reboot.

PiperOrigin-RevId: 555334222
This commit is contained in:
Etienne Perot
2023-08-09 18:21:17 -07:00
committed by gVisor bot
parent 821459c942
commit 582bf0d72d
+8
View File
@@ -1,5 +1,13 @@
set -euo pipefail
if POSIXLY_CORRECT=true df --local --output=pcent,ipcent,target | grep -vE '/snap/' | grep -qE '9[4-9]%|100%'; then
echo "Disk usage has reached critical level, node is bad." >&2
sudo df -h --local | sed -r 's/^/[df] /' >&2
sleep 3
sudo poweroff
exit 1
fi
if [[ "${BUILDKITE_PIPELINE_NAME:-}" == "Pipeline" ]]; then
# Check that the target branch exists.
git fetch origin "${BUILDKITE_BRANCH}" || {