Skip to content

Commit

Permalink
fix(volumes): default to 40 volumes spanning available disk space (#15)
Browse files Browse the repository at this point in the history
* fix(volumes): increase volume count and decrease size to ensure available volumes for s3 buckets

* env var for controlling maximum storage capacity, calculate volume size within entrypoint

* default storage capacity to filling currently available disk space
  • Loading branch information
andrewazores authored Apr 16, 2024
1 parent b83da17 commit 03a6445
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cryostat-entrypoint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ done

createBuckets "${names[@]}" &

FLAGS=()

if [ -n "${VOLUME_MAX}" ]; then
FLAGS+=("-volume.max=${VOLUME_MAX}")
fi

if [ -n "${VOLUME_SIZE_LIMIT_MB}" ]; then
FLAGS+=("-master.volumeSizeLimitMB=${VOLUME_SIZE_LIMIT_MB}")
fi
VOLUME_MIN=40
NUM_VOLUMES=$(( VOLUME_MAX > VOLUME_MIN ? VOLUME_MAX : VOLUME_MIN ))
DATA_DIR="${DATA_DIR:-/tmp}"
AVAILABLE_DISK_BYTES="$(df -P -B1 "${DATA_DIR}" | tail -1 | tr -s ' ' | cut -d' ' -f 4)"
STORAGE_CAPACITY=${STORAGE_CAPACITY:-${AVAILABLE_DISK_BYTES}}
STORAGE_CAPACITY_BYTES=$(echo "${STORAGE_CAPACITY}" | numfmt --from=iec --suffix=B | tr -d 'B')
VOLUME_SIZE_BYTES=$(( "${STORAGE_CAPACITY_BYTES}" / "${NUM_VOLUMES}" ))

exec weed -logtostderr=true server \
-dir="${DATA_DIR:-/tmp}" \
-dir="${DATA_DIR}" \
-volume.max=${NUM_VOLUMES} \
-volume.fileSizeLimitMB="${FILE_SIZE_LIMIT_MB:-4096}" \
-master.volumeSizeLimitMB="$(( "${VOLUME_SIZE_BYTES}" / 1024 / 1024 ))" \
-master.volumePreallocate="${VOLUME_PREALLOCATE:-false}" \
"${FLAGS[@]}" \
-s3 -s3.config="${cfg}" \
"$@"

0 comments on commit 03a6445

Please sign in to comment.