Skip to content

Commit

Permalink
onboot.sh: Diskspace recovery if less than 4Gbyte free. Works with ZFS
Browse files Browse the repository at this point in the history
Signed-off-by: eriknordmark <[email protected]>
  • Loading branch information
eriknordmark committed Jan 12, 2024
1 parent 71505e2 commit 49902b4
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions pkg/pillar/scripts/onboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ FIRSTBOOT=
TPM_DEVICE_PATH="/dev/tpmrm0"
SECURITYFSPATH=/sys/kernel/security
PATH=$BINDIR:$PATH
DISKSPACE_RECOVERY_LIMIT=70 # XXX remove
MIN_DISKSPACE=4096 # MBytes

echo "$(date -Ins -u) Starting onboot.sh"
Expand Down Expand Up @@ -157,54 +156,35 @@ free_space() {
# /persist/vault/downloader
# /persist/vault/verifier
# /persist/agentdbug
# XXX remove
diskspace_used=$(percent_used persist)
echo "Used percentage of /persist: $diskspace_used"
if [ "$diskspace_used" -ge "$DISKSPACE_RECOVERY_LIMIT" ]
then
echo "Used percentage of /persist is $diskspace_used more than the limit $DISKSPACE_RECOVERY_LIMIT"
for DIR in log pubsub-large netdump newlog/keepSentQueue newlog/failedUpload newlog/appUpload newlog/devUpload containerd-system-root vault/containerd vault/downloader vault/verifier agentdebug
do
dir_del=$PERSISTDIR/$DIR
# XXX disable for test purposes
# rm -rf "${dir_del:?}/"*
echo "XXX rm -rf "${dir_del:?}/"*"
diskspace_used=$(percent_used persist)
echo "Used percentage of /persist is $diskspace_used after clearing $dir_del"
if [ "$diskspace_used" -le "$DISKSPACE_RECOVERY_LIMIT" ]
then
break
fi
done
diskspace_used=$(percent_used persist)
echo "Used percentage of /persist after recovery: $diskspace_used"
fi

diskspace_free=$(free_space persist)
echo "Free space in /persist: $diskspace_free MBytes"
echo "Free space in /persist: $diskspace_free MBytes" | tee /dev/console
if [ "$diskspace_free" -lt "$MIN_DISKSPACE" ]
then
echo "Free space in /persist is only $diskspace_free hence below the limit $MIN_DISKSPACE MBytes"
echo "Free space in /persist is only $diskspace_free hence below the limit $MIN_DISKSPACE MBytes" | tee /dev/console
for DIR in log pubsub-large netdump newlog/keepSentQueue newlog/failedUpload newlog/appUpload newlog/devUpload containerd-system-root vault/containerd vault/downloader vault/verifier agentdebug
do
dir_del=$PERSISTDIR/$DIR
rm -rf "${dir_del:?}/"*
diskspace_free=$(free_space persist)
echo "Free space in /persist after clearing $dir_del: $diskspace_free MBytes"
echo "Free space in /persist after clearing $dir_del: $diskspace_free MBytes" | tee /dev/console
# Need to wait for ZFS to free space
# Two separate sleeps to log long delays
sleep 5
diskspace_free=$(free_space persist)
echo "Free space in /persist after clearing $dir_del and 5s sleep: $diskspace_free MBytes" | tee /dev/console
sleep 55
diskspace_free=$(free_space persist)
echo "Free space in /persist after clearing $dir_del and 60s sleep: $diskspace_free MBytes" | tee /dev/console
if [ "$diskspace_free" -ge "$MIN_DISKSPACE" ]
then
break
fi
done
diskspace_free=$(free_space persist)
echo "Free space in /persist after recovery: $diskspace_free MBytes"
echo "Free space in /persist after recovery: $diskspace_free MBytes" | tee /dev/console
fi

# XXX dump sizes by appending to /persist/log/sizes
echo "$(date -Ins -u) onboot.sh sizes" >>/persist/log/sizes
du -m /persist >>/persist/log/sizes
echo "$(date -Ins -u) onboot.sh sizes done" >>/persist/log/sizes

# Run upgradeconverter
mkdir -p /persist/ingested/
echo "$(date -Ins -u) onboot.sh: Starting upgradeconverter (pre-vault)"
Expand Down

0 comments on commit 49902b4

Please sign in to comment.