From b21490601fe51ddf731129a3596687f297f4b879 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Sat, 14 Oct 2023 07:43:09 +0000 Subject: [PATCH] Dockefile: use wrapper script to run radosgw This abstracts calling on radosgw, limiting the options the user can use by default, while forcing (unless overridden by the user) all the parameters we know we need (like the storage driver). Signed-off-by: Joao Eduardo Luis --- Dockerfile | 16 ++-- tools/run-s3gw.sh | 209 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+), 9 deletions(-) create mode 100755 tools/run-s3gw.sh diff --git a/Dockerfile b/Dockerfile index 5d173f20..347eda4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -170,9 +170,11 @@ FROM s3gw-base as s3gw ARG QUAY_EXPIRATION=Never ARG S3GW_VERSION=Development -ARG ID=s3gw +ARG S3GW_ID=s3gw -ENV ID=${ID} +ENV S3GW_ID=${S3GW_ID} +ENV S3GW_DNS_NAME="" +ENV S3GW_DEBUG="none" LABEL Name=s3gw LABEL Version=${S3GW_VERSION} @@ -189,13 +191,9 @@ COPY --from=buildenv [ \ "/srv/ceph/build/lib/libceph-common.so.2", \ "/radosgw/lib/" ] +COPY tools/run-s3gw.sh /radosgw/bin/ + EXPOSE 7480 EXPOSE 7481 -ENTRYPOINT [ "radosgw", "-d", \ - "--no-mon-config", \ - "--id", "${ID}", \ - "--rgw-data", "/data/", \ - "--run-dir", "/run/", \ - "--rgw-sfs-data-path", "/data" ] -CMD [ "--rgw-backend-store", "sfs", "--debug-rgw", "1" ] +ENTRYPOINT [ "run-s3gw.sh" ] diff --git a/tools/run-s3gw.sh b/tools/run-s3gw.sh new file mode 100755 index 00000000..8e6e5ae4 --- /dev/null +++ b/tools/run-s3gw.sh @@ -0,0 +1,209 @@ +#!/bin/bash +# +# run-s3gw.sh - wrapper to run a radosgw binary +# Copyright 2022 SUSE, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +default_id="s3gw" +default_debug_level="none" + +rgw_pid= + +usage() { + cat </dev/stderr + exit 1 + ;; + esac + + shift 1 + +done + +# this can only happen if the user specifies "--id ''". +[[ -z "${s3gw_id}" ]] && + echo "ERROR: s3gw ID can't be empty!" >/dev/stderr && + exit 1 + +rgw_debug_value=0 + +if [[ -n "${s3gw_debug_level}" ]]; then + case ${s3gw_debug_level} in + none) ;; + low) + rgw_debug_value=1 + ;; + medium) + rgw_debug_value=10 + ;; + high) + rgw_debug_value=20 + ;; + *) + echo "ERROR: unknown debug value '${s3gw_debug_level}'" >/dev/stderr + exit 1 + ;; + esac +fi + +if [[ -n "${cert_file}" ]]; then + if [[ -z "${cert_key}" ]]; then + echo "ERROR: missing SSL certificate key file" + exit 1 + fi +elif [[ -n "${cert_key}" ]]; then + echo "ERROR: missing SSL certificate file" + exit 1 +fi + +frontend_args="beast port=7480" +if [[ -n "${cert_file}" ]]; then + [[ ! -f "${cert_file}" ]] && + echo "ERROR: certificate file not found at '${cert_file}'" && + exit 1 + + [[ ! -f "${cert_key}" ]] && + echo "ERROR: certificate key file not found at '${cert_key}'" && + exit 1 + + frontend_args="beast port=7480 ssl_port=7481 + ssl_certificate=${cert_file} ssl_private_key=${cert_key}" +fi + +if [[ $with_status -eq 1 ]]; then + frontend_args+=", status" +fi + +args="--id ${s3gw_id} --debug-rgw ${rgw_debug_value}" + +[[ -n "${s3gw_dns_name}" ]] && + args="${args} --rgw-dns-name ${s3gw_dns_name}" + +[[ -n "${extra_args}" ]] && + args="${args} ${extra_args[@]}" + +if [[ $with_telemetry -eq 1 ]]; then + if [[ -n "${telemetry_url}" ]]; then + args+="--rgw-s3gw-telemetry-upgrade-responder-url ${telemetry_url}" + fi +else + args+="--rgw-s3gw-enable-telemetry false" +fi + +radosgw -d \ + --no-mon-config \ + --rgw-data /data/ \ + --run-dir /run/ \ + --rgw-sfs-data-path /data \ + --rgw-backend-store sfs \ + --rgw-frontends "${frontend_args}" \ + ${args} & + +rgw_pid=$! +wait ${rgw_pid}