diff --git a/os-eap-node-name/added/launch/openshift-node-name.sh b/os-eap-node-name/added/launch/openshift-node-name.sh index f594d0dc..c692f650 100644 --- a/os-eap-node-name/added/launch/openshift-node-name.sh +++ b/os-eap-node-name/added/launch/openshift-node-name.sh @@ -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 diff --git a/os-eap7-launch/added/openshift-launch.sh b/os-eap7-launch/added/openshift-launch.sh index e6ade86b..2c615a9f 100755 --- a/os-eap7-launch/added/openshift-launch.sh +++ b/os-eap7-launch/added/openshift-launch.sh @@ -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 $! } diff --git a/os-partition/added/partitionPV.sh b/os-partition/added/partitionPV.sh index 34411fab..59266706 100644 --- a/os-partition/added/partitionPV.sh +++ b/os-partition/added/partitionPV.sh @@ -1,4 +1,3 @@ -source ${JBOSS_HOME}/bin/launch/openshift-node-name.sh [ "${SCRIPT_DEBUG}" = "true" ] && DEBUG_QUERY_API_PARAM="-l debug" # parameters @@ -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=$! @@ -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 @@ -104,7 +114,7 @@ function migratePV() { # 1.a.i) if 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 @@ -112,7 +122,11 @@ function migratePV() { ( # 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=$! @@ -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 @@ -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 diff --git a/os-partition/added/queryapi/query.py b/os-partition/added/query.py similarity index 99% rename from os-partition/added/queryapi/query.py rename to os-partition/added/query.py index 0190e52b..c9291bc7 100644 --- a/os-partition/added/queryapi/query.py +++ b/os-partition/added/query.py @@ -1,3 +1,4 @@ +#!/bin/python """ Copyright 2018 Red Hat, Inc. diff --git a/os-partition/install_as_root.sh b/os-partition/install_as_root.sh index c4e3a3cd..7fa743f8 100755 --- a/os-partition/install_as_root.sh +++ b/os-partition/install_as_root.sh @@ -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/* diff --git a/os-partition/module.yaml b/os-partition/module.yaml index 0aa42892..7beccac9 100644 --- a/os-partition/module.yaml +++ b/os-partition/module.yaml @@ -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