Skip to content

Commit 36d0d31

Browse files
fix(volume): do not exceed maximum allowed volume size (backport #34) (#35)
fix(volume): do not exceed maximum allowed volume size (#34) * fix(volume): do not exceed maximum allowed volume size * allow overriding minimum number of volumes * only probe available storage capacity if user has not provided a size * comments (cherry picked from commit d8a7cd5) Co-authored-by: Andrew Azores <me@andrewazor.es>
1 parent 87af001 commit 36d0d31

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cryostat-entrypoint.bash

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,22 @@ createBuckets "${names[@]}" &
5555

5656
set -e
5757

58-
VOLUME_MIN=40
58+
VOLUME_MIN=${VOLUME_MIN:-40}
5959
NUM_VOLUMES=$(( ${VOLUME_MAX:-0} > VOLUME_MIN ? VOLUME_MAX : VOLUME_MIN ))
6060
DATA_DIR="${DATA_DIR:-/tmp}"
61-
AVAILABLE_DISK_BYTES="$(df -P -B1 "${DATA_DIR}" | tail -1 | tr -s ' ' | cut -d' ' -f 4)"
62-
STORAGE_CAPACITY=${STORAGE_CAPACITY:-${AVAILABLE_DISK_BYTES}}
61+
62+
# if the user specifies a STORAGE_CAPACITY they may specify it in raw byte count, or byte count with a B suffix, or
63+
# using other suffices like '50MB'. If the user does not specify it then we use df to check the available space on the
64+
# disk in raw byte count and attempt to fill all available space, or fill the maximum space that we are able to given
65+
# the individual volume size limit and the maximum number of volumes we will create.
66+
# The usage of numfmt here allows us to accept this flexible input and convert it to a byte count, then use tr to
67+
# remove the B suffix.
68+
STORAGE_CAPACITY=${STORAGE_CAPACITY:-"$(df -P -B1 "${DATA_DIR}" | tail -1 | tr -s ' ' | cut -d' ' -f 4)"}
6369
STORAGE_CAPACITY_BYTES=$(echo "${STORAGE_CAPACITY}" | numfmt --from=iec --suffix=B | tr -d 'B')
70+
6471
VOLUME_SIZE_BYTES=$(( "${STORAGE_CAPACITY_BYTES}" / "${NUM_VOLUMES}" ))
72+
VOLUME_SIZE_BYTES_MAX=31457280000 # 30000MB, the maximum volume size SeaweedFS will create
73+
VOLUME_SIZE_BYTES=$(( VOLUME_SIZE_BYTES > VOLUME_SIZE_BYTES_MAX ? VOLUME_SIZE_BYTES_MAX : VOLUME_SIZE_BYTES ))
6574

6675
FLAGS=(
6776
"-filer.allowedOrigins=${FILER_ORIGINS:-0.0.0.0}"

0 commit comments

Comments
 (0)