diff --git a/Dockerfile b/Dockerfile index 202473c..059df4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,3 +14,7 @@ FROM $BASE ### To install the nginx package for opensuse ### #RUN zypper refresh && zypper install nginx -y + +# Add custom health check for two-node liveness + +# ADD overlay/files/opt/spectrocloud/bin/check-disk-size.sh /opt/spectrocloud/bin/ diff --git a/overlay/files/opt/spectrocloud/bin/check-disk-size.sh b/overlay/files/opt/spectrocloud/bin/check-disk-size.sh new file mode 100755 index 0000000..6dab5a6 --- /dev/null +++ b/overlay/files/opt/spectrocloud/bin/check-disk-size.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +REQUIRED_FREE_DISK=$1 + +FREE=$(df -h --output=pcent /var/ | tail -n 1 | tr -d '\% ') + +if (( $FREE < $REQUIRED_FREE_DISK )); then + echo "Not enough free disk, required: $1. Free: $FREE" + exit 1 +fi + +echo "Free disk ok, required: $1. Free: $FREE" +exit 0