From 710d810bb28cf43abca13cf5741236f116b6aee8 Mon Sep 17 00:00:00 2001 From: Kirby Chin Date: Tue, 25 Aug 2026 14:18:30 -0400 Subject: [PATCH 1/3] Wait for port open before populating SCC --- README.md | 6 ++++ ga/latest/kernel/helpers/build/configure.sh | 6 ++++ .../kernel/helpers/build/populate_scc.sh | 33 +++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1009617d..5aa11973 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,12 @@ This feature can be controlled via the following variables: * `WARM_OPENAPI_ENDPOINT_URL` (enviornment variable) * Description: (24.0.0.4+) The URL to access during SCC population if WARM_OPENAPI_ENDPOINT is true. * Default: `"localhost:9080/openapi"` +* `PORT_OPEN_TIMEOUT_SECONDS` (environment variable) + * Description: The timeout in seconds to wait for the Liberty server port to open (detected via message `CWWKO0219I` in the messages log) during SCC population before failing. + * Default: `"30"` +* `MESSAGES_LOG_FILE` (environment variable) + * Description: The path to the Liberty server messages log file to check for port open during SCC population. + * Default: `"/logs/messages.log"` ## Logging diff --git a/ga/latest/kernel/helpers/build/configure.sh b/ga/latest/kernel/helpers/build/configure.sh index ddacb7cd..af7716dc 100755 --- a/ga/latest/kernel/helpers/build/configure.sh +++ b/ga/latest/kernel/helpers/build/configure.sh @@ -198,6 +198,12 @@ function main() { if [ ! "$WARM_OPENAPI_ENDPOINT_URL" = "" ]; then cmd+=" -o $WARM_OPENAPI_ENDPOINT_URL" fi + if [ ! "$PORT_OPEN_TIMEOUT_SECONDS" = "" ]; then + cmd+=" -r $PORT_OPEN_TIMEOUT_SECONDS" + fi + if [ ! "$MESSAGES_LOG_FILE" = "" ]; then + cmd+=" -f $MESSAGES_LOG_FILE" + fi eval $cmd fi } diff --git a/ga/latest/kernel/helpers/build/populate_scc.sh b/ga/latest/kernel/helpers/build/populate_scc.sh index a74c52a9..b27f72cc 100755 --- a/ga/latest/kernel/helpers/build/populate_scc.sh +++ b/ga/latest/kernel/helpers/build/populate_scc.sh @@ -33,6 +33,8 @@ WARM_ENDPOINT=true WARM_ENDPOINT_URL=localhost:9080/ WARM_OPENAPI_ENDPOINT=true WARM_OPENAPI_ENDPOINT_URL=localhost:9080/openapi +PORT_OPEN_TIMEOUT_SECONDS=${PORT_OPEN_TIMEOUT_SECONDS:-30} # Default timeout in seconds to wait for port to open. +MESSAGES_LOG_FILE=${MESSAGES_LOG_FILE:-/logs/messages.log} # Default log file location to check for port open. # If this directory exists and has at least ug=rwx permissions, assume the base image includes an SCC called 'openj9_system_scc' and build on it. # If not, build on our own SCC. @@ -63,7 +65,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess" DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy" PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats" -while getopts ":i:s:u:o:tdhwcml" OPT +while getopts ":i:s:u:o:r:f:tdhwcml" OPT do case "$OPT" in i) @@ -97,9 +99,15 @@ do o) WARM_OPENAPI_ENDPOINT_URL="${OPTARG}" ;; + r) + PORT_OPEN_TIMEOUT_SECONDS="${OPTARG}" + ;; + f) + MESSAGES_LOG_FILE="${OPTARG}" + ;; h) echo \ -"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-c] [-u url] [-m] [-l] [-o url] +"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-c] [-u url] [-m] [-l] [-o url] [-r timeout_seconds] [-f log_file] -i Number of iterations to run to populate the SCC. (Default: $ITERATIONS) -s Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE) -t Trim the SCC to eliminate most of the free space, if any. @@ -110,6 +118,8 @@ do -m Use curl/wget to warm the openapi endpoint during SCC creation. (Default: $WARM_OPENAPI_ENDPOINT) -l Do not warm the openapi endpoint during SCC creation. -o The Open API URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_OPENAPI_URL) + -r Timeout in seconds to wait for port to open. (Default: $PORT_OPEN_TIMEOUT_SECONDS) + -f Log file location to check for port open. (Default: $MESSAGES_LOG_FILE) Trimming enabled=$TRIM_SCC" exit 1 @@ -128,6 +138,23 @@ done OLD_UMASK=`umask` umask 002 # 002 is required to provide group rw permission to the cache when `-Xshareclasses:groupAccess` options is used +wait_for_port_open() { + local log_file="${MESSAGES_LOG_FILE}" + local timeout=${PORT_OPEN_TIMEOUT_SECONDS} + local count=0 + + while [ $count -lt $timeout ]; do + if [ -f "$log_file" ] && grep -q "CWWKO0219I" "$log_file"; then + return 0 + fi + sleep 1 + count=$((count + 1)) + done + + echo "Exiting populate_scc because port didn't open after $timeout seconds (CWWKO0219I not found in $log_file)." >&2 + exit 1 +} + # Explicity create a class cache layer for this image layer here rather than allowing # `server start` to do it, which will lead to problems because multiple JVMs will be started. java $CREATE_LAYER -Xscmx$SCC_SIZE -version @@ -137,6 +164,7 @@ then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. /opt/ibm/wlp/bin/server start + wait_for_port_open if [ ${WARM_ENDPOINT} == true ] then @@ -172,6 +200,7 @@ fi for ((i=0; i<$ITERATIONS; i++)) do /opt/ibm/wlp/bin/server start + wait_for_port_open if [ ${WARM_ENDPOINT} == true ] then From 99bb8d56a3490a632cac932b250b373aa4b5eb20 Mon Sep 17 00:00:00 2001 From: Kirby Chin Date: Tue, 25 Aug 2026 14:59:51 -0400 Subject: [PATCH 2/3] Cleanly exit populate_scc.sh when the port isn't live --- README.md | 2 +- ga/latest/kernel/helpers/build/populate_scc.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5aa11973..91883f22 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ This feature can be controlled via the following variables: * Description: (24.0.0.4+) The URL to access during SCC population if WARM_OPENAPI_ENDPOINT is true. * Default: `"localhost:9080/openapi"` * `PORT_OPEN_TIMEOUT_SECONDS` (environment variable) - * Description: The timeout in seconds to wait for the Liberty server port to open (detected via message `CWWKO0219I` in the messages log) during SCC population before failing. + * Description: The timeout in seconds to wait for the Liberty server port to open (detected via message `CWWKO0219I` in the messages log) during SCC population before exiting populate_scc. * Default: `"30"` * `MESSAGES_LOG_FILE` (environment variable) * Description: The path to the Liberty server messages log file to check for port open during SCC population. diff --git a/ga/latest/kernel/helpers/build/populate_scc.sh b/ga/latest/kernel/helpers/build/populate_scc.sh index b27f72cc..5c201fb0 100755 --- a/ga/latest/kernel/helpers/build/populate_scc.sh +++ b/ga/latest/kernel/helpers/build/populate_scc.sh @@ -151,8 +151,8 @@ wait_for_port_open() { count=$((count + 1)) done - echo "Exiting populate_scc because port didn't open after $timeout seconds (CWWKO0219I not found in $log_file)." >&2 - exit 1 + echo "Exiting populate_scc because port didn't open after $timeout seconds (CWWKO0219I not found in $log_file)." + exit 0 } # Explicity create a class cache layer for this image layer here rather than allowing From be169f101c0110d05d37143bb516b0cc0e8565a3 Mon Sep 17 00:00:00 2001 From: Kirby Chin Date: Tue, 25 Aug 2026 15:34:25 -0400 Subject: [PATCH 3/3] Remove messages log file before server start --- ga/latest/kernel/helpers/build/populate_scc.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ga/latest/kernel/helpers/build/populate_scc.sh b/ga/latest/kernel/helpers/build/populate_scc.sh index 5c201fb0..058adef2 100755 --- a/ga/latest/kernel/helpers/build/populate_scc.sh +++ b/ga/latest/kernel/helpers/build/populate_scc.sh @@ -163,6 +163,7 @@ if [ $TRIM_SCC == yes ] then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. + rm -f "$MESSAGES_LOG_FILE" /opt/ibm/wlp/bin/server start wait_for_port_open @@ -199,6 +200,7 @@ fi # Server start/stop to populate the /output/workarea and make subsequent server starts faster. for ((i=0; i<$ITERATIONS; i++)) do + rm -f "$MESSAGES_LOG_FILE" /opt/ibm/wlp/bin/server start wait_for_port_open