Skip to content

Commit

Permalink
CLOUD-2261 tweaks to pass unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: rcernich <[email protected]>
  • Loading branch information
rcernich committed Jun 6, 2018
1 parent 715c36b commit fca2b70
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
20 changes: 7 additions & 13 deletions os-eap-node-name/added/launch/openshift-node-name.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
function init_pod_name() {
# when POD_NAME is non-zero length using that given name

# docker sets up container_uuid
[ -z "${POD_NAME}" ] && POD_NAME="${container_uuid}"
# openshift sets up the node id as host name
[ -z "${POD_NAME}" ] && POD_NAME="${HOSTNAME}"
# TODO: fail when pod name is not set here?
}

function init_node_name() {
if [ -z "${JBOSS_NODE_NAME}" ] ; then
init_pod_name

JBOSS_NODE_NAME="${POD_NAME}"
if [ -n "${NODE_NAME}" ]; then
JBOSS_NODE_NAME="${NODE_NAME}"
elif [ -n "${container_uuid}" ]; then
JBOSS_NODE_NAME="${container_uuid}"
else
JBOSS_NODE_NAME="${HOSTNAME}"
fi

# CLOUD-427: truncate to 23 characters max (from the end backwards)
if [ ${#JBOSS_NODE_NAME} -gt 23 ]; then
Expand Down
2 changes: 1 addition & 1 deletion os-eap7-launch/added/openshift-launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source $JBOSS_HOME/bin/launch/logging.sh
# TERM signal handler
function clean_shutdown() {
log_error "*** JBossAS wrapper process ($$) received TERM signal ***"
$JBOSS_HOME/bin/jboss-cli.sh -c ":shutdown(timeout=60)"
$JBOSS_HOME/bin/jboss-cli.sh -c "shutdown --timeout=60"
wait $!
}

Expand Down
26 changes: 20 additions & 6 deletions os-partition/added/partitionPV.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source ${JBOSS_HOME}/bin/launch/openshift-node-name.sh
[ "${SCRIPT_DEBUG}" = "true" ] && DEBUG_QUERY_API_PARAM="-l debug"

# parameters
Expand Down Expand Up @@ -55,7 +54,9 @@ function partitionPV() {
fi

# 4) launch EAP with node name as pod name
NODE_NAME="${POD_NAME}" runServer "${SERVER_DATA_DIR}" &
#NODE_NAME="${POD_NAME}" runServer "${SERVER_DATA_DIR}" &
# node name cannot be longer than 23 chars
runServer "${SERVER_DATA_DIR}" &

PID=$!

Expand All @@ -76,6 +77,15 @@ function partitionPV() {
exit $STATUS
}

function init_pod_name() {
# when POD_NAME is non-zero length using that given name

# docker sets up container_uuid
[ -z "${POD_NAME}" ] && POD_NAME="${container_uuid}"
# openshift sets up the node id as host name
[ -z "${POD_NAME}" ] && POD_NAME="${HOSTNAME}"
# TODO: fail when pod name is not set here?
}

# parameters
# - base directory
Expand Down Expand Up @@ -104,15 +114,19 @@ function migratePV() {
# 1.a.i) if <applicationPodName> is not in the cluster
echo "examining existence of living pod for directory: '${applicationPodDir}'"
unset LIVING_PODS
LIVING_PODS=($(python ${JBOSS_HOME}/bin/queryapi/query.py -q pods_living -f list_space ${DEBUG_QUERY_API_PARAM}))
LIVING_PODS=($(${BASH_SOURCE[0]}/query.py -q pods_living -f list_space ${DEBUG_QUERY_API_PARAM}))
[ $? -ne 0 ] && echo "ERROR: Can't get list of living pods" && continue
STATUS=-1 # here we have data about living pods and the recovery marker can be removed if the pod is living
if ! arrContains ${applicationPodName} "${LIVING_PODS[@]}"; then

(
# 1.a.ii) run recovery until empty (including orphan checks and empty object store hierarchy deletion)
SERVER_DATA_DIR="${applicationPodDir}/serverData"
JBOSS_NODE_NAME="$applicationPodName" runMigration "${SERVER_DATA_DIR}" &
JBOSS_NODE_NAME="$applicationPodName"
if [ ${#JBOSS_NODE_NAME} -gt 23 ]; then
JBOSS_NODE_NAME=${JBOSS_NODE_NAME: -23}
fi
runMigration "${SERVER_DATA_DIR}" &

PID=$!

Expand Down Expand Up @@ -160,7 +174,7 @@ function migratePV() {
local recoveryPodNameToCheck=${recoveryPodFileToCheck#*RECOVERY-}

unset LIVING_PODS
LIVING_PODS=($(python ${JBOSS_HOME}/bin/queryapi/query.py -q pods_living -f list_space ${DEBUG_QUERY_API_PARAM}))
LIVING_PODS=($(${BASH_SOURCE[0]}/query.py -q pods_living -f list_space ${DEBUG_QUERY_API_PARAM}))
[ $? -ne 0 ] && echo "ERROR: Can't get list of living pods" && continue

if ! arrContains ${recoveryPodNameToCheck} "${LIVING_PODS[@]}"; then
Expand All @@ -182,7 +196,7 @@ function probePodLog() {
init_pod_name
local podNameToProbe=${1:-$POD_NAME}

local logOutput=$(python ${JBOSS_HOME}/bin/queryapi/query.py -q log ${podNameToProbe})
local logOutput=$(${BASH_SOURCE[0]}/query.py -q log ${podNameToProbe})
local probeStatus=$?

if [ $probeStatus -ne 0 ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/python
"""
Copyright 2018 Red Hat, Inc.
Expand Down
5 changes: 2 additions & 3 deletions os-partition/install_as_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ADDED_DIR=${SCRIPT_DIR}/added

test -d /opt/partition || mkdir /opt/partition

cp "$ADDED_DIR"/partitionPV.sh \
/opt/partition/
cp "$ADDED_DIR"/* /opt/partition/

chmod 755 /opt/partition/partitionPV.sh
chmod 755 /opt/partition/*
2 changes: 0 additions & 2 deletions os-partition/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ name: os-partition
version: '1.0'
description: Lock-free os-partition script package.
execute:
- script: configure.sh
user: '185'
- script: install_as_root.sh

0 comments on commit fca2b70

Please sign in to comment.