Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(buckets): add CRYOSTAT_BUCKETS for pre-created buckets #4

Merged
merged 7 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN dnf install -y go git make gettext \
&& popd

FROM registry.access.redhat.com/ubi8/ubi-micro:${runner_version}
COPY --from=builder /usr/bin/envsubst /root/go/bin/weed /root/seaweedfs/docker/entrypoint.sh /usr/bin/
COPY --from=builder /usr/bin/envsubst /root/go/bin/weed /usr/bin/
COPY ./cryostat-entrypoint.bash /usr/bin/
COPY seaweed_conf.template.json /etc/seaweed_conf.template.json
ENTRYPOINT ["/usr/bin/cryostat-entrypoint.bash"]
37 changes: 35 additions & 2 deletions cryostat-entrypoint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,40 @@ set -xe
cfg="$(mktemp)"
envsubst '$CRYOSTAT_ACCESS_KEY $CRYOSTAT_SECRET_KEY' < /etc/seaweed_conf.template.json > "${cfg}"

exec /usr/bin/entrypoint.sh \
server -dir="${DATA_DIR:-/tmp}" \
function waitForStartup() {
echo "cluster.check" | timeout "${BUCKET_CREATION_STARTUP_SECONDS:-30}"s weed shell 1>/dev/null 2>/dev/null || true
sleep "${BUCKET_CREATION_DELAY_SECONDS:-5}"
}

function createBucket() {
echo "s3.bucket.create -name $1" | timeout "${BUCKET_CREATION_TIMEOUT_SECONDS:-5}"s weed shell
}

function createBuckets() {
waitForStartup
for name in "$@"; do
createBucket "${name}"
done
}

names=()
for i in $(echo "$CRYOSTAT_BUCKETS" | tr ',' '\n'); do
len="${#i}"
if [ "${len}" -lt 3 ]; then
echo "Bucket names must be at least 3 characters"
exit 1
fi
if [ "${len}" -gt 63 ]; then
echo "Bucket names must be at most 63 characters"
exit 1
fi
names+=("${i}")
done

createBuckets "${names[@]}" &

exec weed -logtostderr=true server \
-dir="${DATA_DIR:-/tmp}" \
-master.volumePreallocate="${VOLUME_PREALLOCATE:-true}" -volume.max="${VOLUME_MAX:-0}" -master.volumeSizeLimitMB="${VOLUME_SIZE_LIMIT_MB:-4096}" \
-s3 -s3.config="${cfg}" \
"$@"