Skip to content

Commit 0e54f8c

Browse files
authored
#5553: add data path file purge after verify-range container finishes (#5754)
1 parent ad8907d commit 0e54f8c

File tree

1 file changed

+13
-0
lines changed
  • services/horizon/docker/verify-range

1 file changed

+13
-0
lines changed

services/horizon/docker/verify-range/start

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ set -e
88
CONTAINER_WORKING_DIR="/data/job_${AWS_BATCH_JOB_ARRAY_INDEX:-0}"
99
echo "Job working directory path on data volume: $CONTAINER_WORKING_DIR"
1010

11+
cleanup() {
12+
# need to purge these files at end as the db and the downloaed datastore
13+
# files can be significatn GB's in size and in a cloud batch environment
14+
# we don't want to keep them around after the job is done, i.e. pay for that space still.
15+
sudo -u postgres --preserve-env=PGDATA /usr/lib/postgresql/14/bin/pg_ctl stop -D "$PGDATA"
16+
sudo chattr -R -i -a "$CONTAINER_WORKING_DIR"
17+
if [ -d "$CONTAINER_WORKING_DIR" ]; then
18+
sudo rm -rf "$CONTAINER_WORKING_DIR"
19+
echo "Purged working data files from $CONTAINER_WORKING_DIR"
20+
fi
21+
}
22+
trap cleanup EXIT
23+
1124
# Ensure CONTAINER_WORKING_DIR exists and is empty
1225
rm -rf "$CONTAINER_WORKING_DIR"/*
1326
mkdir -p "$CONTAINER_WORKING_DIR"

0 commit comments

Comments
 (0)