Skip to content

Commit 2d23373

Browse files
committed
Merge pull request #95 from richm/es-use-pv
enable pv for elasticsearch for testing
2 parents 3c2879b + 26a0852 commit 2d23373

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

hack/testing/logging.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ USE_LOGGING_DEPLOYER_SCRIPT=
3333
ENABLE_OPS_CLUSTER=${ENABLE_OPS_CLUSTER:-false}
3434
DEBUG_FAILURES=${DEBUG_FAILURES:-false}
3535
USE_LOCAL_SOURCE=${USE_LOCAL_SOURCE:-false}
36+
ES_VOLUME=${ES_VOLUME:-/var/lib/es}
37+
ES_OPS_VOLUME=${ES_OPS_VOLUME:-/var/lib/es-ops}
3638

3739
# includes util.sh and text.sh
3840
source "${OS_ROOT}/hack/cmd_util.sh"
@@ -128,6 +130,11 @@ function wait_for_builds_complete()
128130
return 0
129131
}
130132

133+
function get_running_pod() {
134+
# $1 is component for selector
135+
oc get pods -l component=$1 | awk -v sel=$1 '$1 ~ sel && $3 == "Running" {print $1}'
136+
}
137+
131138
trap "exit" INT TERM
132139
trap "cleanup" EXIT
133140

@@ -238,6 +245,49 @@ fi
238245

239246
# this fails because the imagestreams already exist
240247
os::cmd::expect_failure_and_text "oc process logging-support-template | oc create -f -" "already exists"
248+
if [ -n "$ES_VOLUME" ] ; then
249+
if [ ! -d $ES_VOLUME ] ; then
250+
sudo mkdir -p $ES_VOLUME
251+
sudo chown 1000:1000 $ES_VOLUME
252+
fi
253+
# allow es and es-ops to mount volumes from the host
254+
os::cmd::expect_success "oadm policy add-scc-to-user hostmount-anyuid \
255+
system:serviceaccount:logging:aggregated-logging-elasticsearch"
256+
# get es dc
257+
esdc=`oc get dc -l component=es -o jsonpath='{.items[0].metadata.name}'`
258+
# shutdown es
259+
espod=`get_running_pod es`
260+
os::cmd::expect_success "oc scale dc $esdc --replicas=0"
261+
os::cmd::try_until_failure "oc describe pod $espod > /dev/null" "$(( 3 * TIME_MIN ))"
262+
if [ "$ENABLE_OPS_CLUSTER" = "true" -a -n "$ES_OPS_VOLUME" ] ; then
263+
if [ ! -d $ES_OPS_VOLUME ] ; then
264+
sudo mkdir -p $ES_OPS_VOLUME
265+
sudo chown 1000:1000 $ES_OPS_VOLUME
266+
fi
267+
# get es-ops dc
268+
esopsdc=`oc get dc -l component=es-ops -o jsonpath='{.items[0].metadata.name}'`
269+
# shutdown es-ops
270+
esopspod=`get_running_pod es-ops`
271+
os::cmd::expect_success "oc scale dc $esopsdc --replicas=0"
272+
os::cmd::try_until_failure "oc describe pod $esopspod > /dev/null" "$(( 3 * TIME_MIN ))"
273+
fi
274+
# mount volume
275+
os::cmd::expect_success "oc volume dc/$esdc \
276+
--add --overwrite --name=elasticsearch-storage \
277+
--type=hostPath --path=$ES_VOLUME"
278+
if [ "$ENABLE_OPS_CLUSTER" = "true" -a -n "$ES_OPS_VOLUME" ] ; then
279+
os::cmd::expect_success "oc volume dc/$esopsdc \
280+
--add --overwrite --name=elasticsearch-storage \
281+
--type=hostPath --path=$ES_OPS_VOLUME"
282+
fi
283+
# start up es
284+
os::cmd::expect_success "oc scale dc $esdc --replicas=1"
285+
os::cmd::try_until_text "oc get pods -l component=es" "Running" "$(( 3 * TIME_MIN ))"
286+
if [ "$ENABLE_OPS_CLUSTER" = "true" -a -n "$ES_OPS_VOLUME" ] ; then
287+
os::cmd::expect_success "oc scale dc $esopsdc --replicas=1"
288+
os::cmd::try_until_text "oc get pods -l component=es-ops" "Running" "$(( 3 * TIME_MIN ))"
289+
fi
290+
fi
241291

242292
# start fluentd
243293
os::cmd::try_until_success "oc get daemonset logging-fluentd" "$(( 1 * TIME_MIN ))"

0 commit comments

Comments
 (0)