Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
shellcheck: demo.sh
Browse files Browse the repository at this point in the history
make shellcheck happy on demo.sh

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 08a74b7)
  • Loading branch information
guits authored and dsavineau committed Feb 13, 2021
1 parent 5a37272 commit 1a2776f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/daemon/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MDS_PATH="/var/lib/ceph/mds/${CLUSTER}-$MDS_NAME"
RGW_PATH="/var/lib/ceph/radosgw/${CLUSTER}-rgw.${RGW_NAME}"
# shellcheck disable=SC2153
MGR_PATH="/var/lib/ceph/mgr/${CLUSTER}-$MGR_NAME"
# shellcheck disable=SC2034
MGR_IP=$MON_IP
: "${DEMO_DAEMONS:=all}"
: "${RGW_ENABLE_USAGE_LOG:=true}"
Expand All @@ -35,6 +36,7 @@ MGR_IP=$MON_IP
#######
function bootstrap_mon {
if [[ ! "${CEPH_VERSION}" =~ ^(luminous|mimic)$ ]]; then
# shellcheck disable=SC2034
MON_PORT=3300
fi
# shellcheck disable=SC1091
Expand Down Expand Up @@ -73,7 +75,7 @@ function parse_size {
function bootstrap_osd {
# Apply the tuning on Nautilus and above only since the values applied are causing the ceph-osd to crash on earlier versions
if [[ ${OSD_BLUESTORE} -eq 1 ]] && [[ ! "${CEPH_VERSION}" =~ ^(luminous|mimic)$ ]]; then
tune_memory $(get_available_ram)
tune_memory "$(get_available_ram)"
fi

if [[ -n "$OSD_DEVICE" ]]; then
Expand All @@ -93,7 +95,7 @@ function bootstrap_osd {
: "${OSD_COUNT:=1}"

for i in $(seq 1 1 "$OSD_COUNT"); do
let OSD_ID="$i"-1 || true
(( OSD_ID="$i"-1 )) || true
OSD_PATH="/var/lib/ceph/osd/${CLUSTER}-${OSD_ID}"

if [ ! -e "$OSD_PATH"/keyring ]; then
Expand Down Expand Up @@ -162,6 +164,7 @@ function bootstrap_mds {
#######
function bootstrap_rgw {
if [[ "$RGW_FRONTEND_TYPE" == "civetweb" ]]; then
# shellcheck disable=SC2153
RGW_FRONTED_OPTIONS="$RGW_FRONTEND_OPTIONS port=$RGW_FRONTEND_IP:$RGW_FRONTEND_PORT"
elif [[ "$RGW_FRONTEND_TYPE" == "beast" ]]; then
RGW_FRONTED_OPTIONS="$RGW_FRONTEND_OPTIONS endpoint=$RGW_FRONTEND_IP:$RGW_FRONTEND_PORT"
Expand Down
14 changes: 7 additions & 7 deletions travis-builds/validate_demo_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ set -xe
# FUNCTIONS #
#############
function get_cluster_name {
cluster=$(docker exec ceph-demo grep -R fsid /etc/ceph/ | egrep -o '^[^.]*')
DOCKER_COMMAND="docker exec ceph-demo ceph --connect-timeout 3 --cluster $(basename $cluster)"
cluster=$(docker exec ceph-demo grep -R fsid /etc/ceph/ | grep -Eo '^[^.]*')
DOCKER_COMMAND="docker exec ceph-demo ceph --connect-timeout 3 --cluster $(basename "$cluster")"
}

function wait_for_daemon () {
timeout=90
daemon_to_test=$1
while [ $timeout -ne 0 ]; do
if eval $daemon_to_test; then
if eval "$daemon_to_test"; then
return 0
fi
sleep 1
let timeout=timeout-1
(( timeout=timeout-1 ))
done
return 1
}

function get_ceph_version {
# shellcheck disable=SC2046
echo $($DOCKER_COMMAND --version | grep -Eo '[0-9][0-9]\.[0-9]')
$DOCKER_COMMAND --version | grep -Eo '[0-9][0-9]\.[0-9]'
}

function ceph_status {
Expand Down Expand Up @@ -75,7 +75,7 @@ function test_demo_mgr {

function test_demo_rest_api {
key=$($DOCKER_COMMAND restful list-keys | python -c 'import json, sys; print(json.load(sys.stdin)["demo"])')
docker exec ceph-demo curl -s --connect-timeout 1 -u demo:$key -k https://0.0.0.0:8003/server
docker exec ceph-demo curl -s --connect-timeout 1 -u demo:"$key" -k https://0.0.0.0:8003/server
# shellcheck disable=SC2046
return $(wait_for_daemon "$DOCKER_COMMAND mgr dump | grep -sq 'restful\": \"https://.*:8003'")
}
Expand All @@ -85,7 +85,7 @@ function test_demo_rest_api {
########
get_cluster_name
ceph_status # wait for the cluster to stabilize
ceph_version=$(get_ceph_version)
get_ceph_version
test_demo_mon
test_demo_osd
test_demo_rgw
Expand Down

0 comments on commit 1a2776f

Please sign in to comment.