diff --git a/os-sso/module.yaml b/os-sso/module.yaml index e41d511e..18d2b0d5 100644 --- a/os-sso/module.yaml +++ b/os-sso/module.yaml @@ -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" diff --git a/os-sso71/module.yaml b/os-sso71/module.yaml index 88928eb0..7c4925a7 100644 --- a/os-sso71/module.yaml +++ b/os-sso71/module.yaml @@ -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 diff --git a/os-sso72/added/openshift-launch.sh b/os-sso72/added/openshift-launch.sh index cc8db872..512100b6 100755 --- a/os-sso72/added/openshift-launch.sh +++ b/os-sso72/added/openshift-launch.sh @@ -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" @@ -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" diff --git a/os-sso72/module.yaml b/os-sso72/module.yaml index bd36f63d..ea5f7aa6 100644 --- a/os-sso72/module.yaml +++ b/os-sso72/module.yaml @@ -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."