Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE][CLOUD-2453][KEYCLOAK-7098] Add wait_for_service launch script routine #295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions os-sso/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ execute:
modules:
install:
- name: os-eap-launch

envs:
- name: "SSO_ADMIN_USERNAME"
example: "admin"
description: "Username of the administrator account for the 'master' realm of the RH-SSO server. Required. If no value is specified, it is auto generated and displayed as an OpenShift Instructional message when the template is instantiated."
- name: "SSO_ADMIN_PASSWORD"
example: "hardtoguess"
description: "Password of the administrator account for the 'master' realm of the RH-SSO server. Required. If no value is specified, it is auto generated and displayed as an OpenShift Instructional message when the template is instantiated."
- name: "SSO_SERVICE_USERNAME"
example: "username"
description: "RH-SSO Server service username with rights to create Client configurations in SSO_REALM. This user is created if this ENV is provided"
- name: "SSO_SERVICE_PASSWORD"
example: "password"
description: "Password for SSO_SERVICE_USERNAME"
3 changes: 3 additions & 0 deletions os-sso71/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ run:
user: 185
cmd:
- "/opt/eap/bin/openshift-launch.sh"

# See os-sso/module.yaml for the description of SSO_ADMIN_USERNAME,
# SSO_ADMIN_PASSWORD, SSO_SERVICE_USERNAME, and SSO_SERVICE_PASSWORD variables
31 changes: 31 additions & 0 deletions os-sso72/added/openshift-launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,40 @@ function clean_shutdown() {
wait $!
}

# CLOUD-2453 Connect-retry loop to wait for the service to become reachable over network
function wait_for_service() {
if [ -n "${SERVICE_WAIT_NAME}" ]; then
local -r retry_period_seconds_default="10"
local -r connect_retry_message="${SERVICE_WAIT_RETRY_MESSAGE:-"Waiting for the \"${SERVICE_WAIT_NAME}\" service to become available ..."}"
local service="${SERVICE_WAIT_NAME/-/_}"
local -r service_host="${service^^}_SERVICE_HOST"
local -r service_port="${service^^}_SERVICE_PORT"
if [ -n "${SERVICE_WAIT_RETRY_PERIOD_SECONDS}" ] && [[ ! "${SERVICE_WAIT_RETRY_PERIOD_SECONDS}" =~ '^[0-9]+\.?[0-9]*$' ]]; then
log_warning "Value of SERVICE_WAIT_RETRY_PERIOD_SECONDS variable can be only arbitrary floating point number. Ignoring \"${SERVICE_WAIT_RETRY_PERIOD_SECONDS}\" setting, defaulting to ${retry_period_seconds_default} seconds."
unset SERVICE_WAIT_RETRY_PERIOD_SECONDS
fi
if [ -z "${!service_host}" -o -z "${!service_port}" ]; then
log_warning "Unable to determine target host or port of the \"${SERVICE_WAIT_NAME}\" service. The RH-SSO pod will start without waiting for the \"${SERVICE_WAIT_NAME}\" service to become reachable over network. Please make sure you specified correct service name in SERVICE_WAIT_NAME."
else
until ( echo > /dev/tcp/"${!service_host}"/"${!service_port}" ) &> /dev/null; do
if [ -n "${SERVICE_WAIT_INTRO_MESSAGE}" ]; then
log_warning "${SERVICE_WAIT_INTRO_MESSAGE}"
unset SERVICE_WAIT_INTRO_MESSAGE
fi
log_info "${connect_retry_message}"
sleep "${SERVICE_WAIT_RETRY_PERIOD_SECONDS:-${retry_period_seconds_default}}s"
done
fi
fi
}

function runServer() {
local instanceDir=$1
local count=$2
export NODE_NAME="${NODE_NAME:-node}-${count}"

wait_for_service

source $JBOSS_HOME/bin/launch/configure.sh

log_info "Running $JBOSS_IMAGE_NAME image, version $JBOSS_IMAGE_VERSION"
Expand Down Expand Up @@ -47,6 +76,8 @@ if [ "${SPLIT_DATA^^}" = "TRUE" ]; then

partitionPV "${DATA_DIR}" "${SPLIT_LOCK_TIMEOUT:-30}"
else
wait_for_service

source $JBOSS_HOME/bin/launch/configure.sh

log_info "Running $JBOSS_IMAGE_NAME image, version $JBOSS_IMAGE_VERSION"
Expand Down
13 changes: 13 additions & 0 deletions os-sso72/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ run:
user: 185
cmd:
- "/opt/eap/bin/openshift-launch.sh"

envs:
# See os-sso/module.yaml for the description of SSO_ADMIN_USERNAME,
# SSO_ADMIN_PASSWORD, SSO_SERVICE_USERNAME, and SSO_SERVICE_PASSWORD variables
- name: "SERVICE_WAIT_NAME"
example: "sso-mysql"
description: "Name of the OpenShift service, the RH-SSO pod should wait for to become reachable over network, prior starting the RH-SSO server. Not set by default."
- name: "SERVICE_WAIT_RETRY_MESSAGE"
example: "Waiting for the \"${SERVICE_WAIT_NAME}\" service to become reachable over network ..."
description: "Message to be displayed in connect-retry loop, in which the RH-SSO pod is waiting for the SERVICE_WAIT_NAME to become reachable over network. Defaults to 'Waiting for the \"${SERVICE_WAIT_NAME}\" service to become available ....' if the SERVICE_WAIT_NAME variable is set."
- name: "SERVICE_WAIT_INTRO_MESSAGE"
example: "Ensure a persistent volume is available for the \"${APPLICATION_NAME}-mysql-claim\" or a storage class is set."
description: "Message to be displayed prior starting the connect-retry loop, in which the RH-SSO pod is waiting for the SERVICE_WAIT_NAME to become reachable over network. Typically describes additional requirements in order the connect-retry loop of the RH-SSO pod successfully to finish. Not set by default."