Skip to content

Commit 24950e6

Browse files
authored
Merge pull request #1137 from oracle/tbarnes-version-check
Add WebLogic version and WebLogic patch checks
2 parents 1a14718 + 8e7a17e commit 24950e6

File tree

17 files changed

+265
-31
lines changed

17 files changed

+265
-31
lines changed

operator/src/main/resources/scripts/introspectDomain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
import re
8888
from datetime import datetime
8989

90-
# Include this script's current directory in the import path (so we can import traceUtils, etc.)
90+
# Include this script's current directory in the import path (so we can import utils, etc.)
9191
# sys.path.append('/weblogic-operator/scripts')
9292

9393
# Alternative way to dynamically get script's current directory
@@ -96,7 +96,7 @@
9696
tmp_scriptdir=os.path.dirname(tmp_info[0])
9797
sys.path.append(tmp_scriptdir)
9898

99-
from traceUtils import *
99+
from utils import *
100100

101101
class OfflineWlstEnv(object):
102102

operator/src/main/resources/scripts/introspectDomain.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
4040

4141
# setup tracing
4242

43-
source ${SCRIPTPATH}/traceUtils.sh
44-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
43+
source ${SCRIPTPATH}/utils.sh
44+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit 1
4545

4646
trace "Introspecting the domain"
4747

@@ -58,6 +58,7 @@ export MW_HOME=${MW_HOME:-/u01/oracle}
5858
checkEnv DOMAIN_UID \
5959
NAMESPACE \
6060
DOMAIN_HOME \
61+
ORACLE_HOME \
6162
JAVA_HOME \
6263
NODEMGR_HOME \
6364
WL_HOME \
@@ -70,14 +71,19 @@ for script_file in "${SCRIPTPATH}/wlst.sh" \
7071
[ ! -f "$script_file" ] && trace "Error: missing file '${script_file}'." && exit 1
7172
done
7273

73-
for dir_var in DOMAIN_HOME JAVA_HOME WL_HOME MW_HOME; do
74+
for dir_var in DOMAIN_HOME JAVA_HOME WL_HOME MW_HOME ORACLE_HOME; do
7475
[ ! -d "${!dir_var}" ] && trace "Error: missing ${dir_var} directory '${!dir_var}'." && exit 1
7576
done
7677

7778
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed
7879

7980
exportEffectiveDomainHome || exit 1
8081

82+
# check if we're using a supported WebLogic version
83+
# (the check will log a message if it fails)
84+
85+
checkWebLogicVersion || exit 1
86+
8187
# start node manager
8288

8389
trace "Starting node manager"

operator/src/main/resources/scripts/livenessProbe.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
RETVAL=$(test -f /weblogic-operator/debug/livenessProbeSuccessOverride ; echo $?)
1313

1414
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
15-
source ${SCRIPTPATH}/traceUtils.sh
16-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit $RETVAL
15+
source ${SCRIPTPATH}/utils.sh
16+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit $RETVAL
1717

1818
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
1919
exportEffectiveDomainHome || exit $RETVAL

operator/src/main/resources/scripts/monitorLog.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
echo $$ > /tmp/monitorLog-pid
1515

1616
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
17-
source ${SCRIPTPATH}/traceUtils.sh
17+
source ${SCRIPTPATH}/utils.sh
1818

1919
trace "Monitoring server log file $1 every $2 seconds for selected known log messages."
2020

operator/src/main/resources/scripts/readState.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# file which is updated by the node manager.
99

1010
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
11-
source ${SCRIPTPATH}/traceUtils.sh
12-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
11+
source ${SCRIPTPATH}/utils.sh
12+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit 1
1313

1414
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
1515
exportEffectiveDomainHome || exit 1

operator/src/main/resources/scripts/startNodeManager.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
4949

50-
source ${SCRIPTPATH}/traceUtils.sh
51-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
50+
source ${SCRIPTPATH}/utils.sh
51+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit 1
5252

5353
export WL_HOME="${WL_HOME:-/u01/oracle/wlserver}"
5454

operator/src/main/resources/scripts/startServer.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#
1111

1212
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
13-
source ${SCRIPTPATH}/traceUtils.sh
14-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exitOrLoop
13+
source ${SCRIPTPATH}/utils.sh
14+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exitOrLoop
1515

1616
trace "Starting WebLogic Server '${SERVER_NAME}'."
1717

@@ -175,6 +175,7 @@ checkEnv \
175175
DOMAIN_NAME \
176176
DOMAIN_HOME \
177177
NODEMGR_HOME \
178+
ORACLE_HOME \
178179
SERVER_NAME \
179180
SERVICE_NAME \
180181
ADMIN_NAME \
@@ -190,6 +191,7 @@ trace "JAVA_OPTIONS=${JAVA_OPTIONS}"
190191
#
191192
# check DOMAIN_HOME for a config/config.xml, reset DOMAIN_HOME if needed:
192193
#
194+
193195
exportEffectiveDomainHome || exitOrLoop
194196

195197
#
@@ -202,6 +204,15 @@ if [ ! -f /weblogic-operator/introspector/boot.properties ]; then
202204
exitOrLoop
203205
fi
204206

207+
#
208+
# Check if we're using a supported WebLogic version. The check will
209+
# log a message if it fails.
210+
#
211+
212+
if ! checkWebLogicVersion ; then
213+
exitOrLoop
214+
fi
215+
205216
#
206217
# Copy/update domain introspector files for the domain
207218
#

operator/src/main/resources/scripts/stopServer.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#
1111

1212
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
13-
source ${SCRIPTPATH}/traceUtils.sh
14-
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
13+
source ${SCRIPTPATH}/utils.sh
14+
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit 1
1515

1616
trace "Stop server ${SERVER_NAME}" &>> /weblogic-operator/stopserver.out
1717

@@ -79,4 +79,4 @@ if [ -f /weblogic-operator/pid ]; then
7979
kill -2 $(</weblogic-operator/pid)
8080
fi
8181

82-
trace "Exit script" &>> /weblogic-operator/stopserver.out
82+
trace "Exit script" &>> /weblogic-operator/stopserver.out

operator/src/main/resources/scripts/traceUtils.py renamed to operator/src/main/resources/scripts/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Usage: trace('string')
55
#
6-
# This matches format of bash trace_utils.sh trace, and the operator's log format.
6+
# This matches format of bash utils.sh trace, and the operator's log format.
77
#
88
# Sample output: @[2018-09-28T17:23:55.335 UTC][introspectDomain.py:614] Domain introspection complete.
99
#

operator/src/main/resources/scripts/traceUtils.sh renamed to operator/src/main/resources/scripts/utils.sh

Lines changed: 115 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
#
55
# Purpose:
6-
# Define a trace functions that match format of the trace function
7-
# in traceUtils.py and of the logging in the java operator.
6+
# Define trace functions that match format of the trace function
7+
# in utils.py and of the logging in the java operator.
8+
#
9+
# Define various shared utility functions.
810
#
911
# Load this file via the following pattern:
1012
# SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
11-
# source ${SCRIPTPATH}/traceUtils.sh
12-
# [ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
13+
# source ${SCRIPTPATH}/utils.sh
14+
# [ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/utils.sh" && exit 1
1315
#
1416

1517
# timestamp
@@ -164,3 +166,112 @@ function exportEffectiveDomainHome() {
164166
trace "Error: More than one config.xml found at DOMAIN_HOME/config/config.xml and DOMAIN_HOME/*/config/config.xml, DOMAIN_HOME='$DOMAIN_HOME': ${found_configs}. Configure your 'domainHome' setting in your WebLogic Operator Domain resource to reference a single WebLogic domain."
165167
return 1
166168
}
169+
170+
171+
# versionCmp
172+
# Compares two wl versions $1 $2 up to the length of $2
173+
# Expects form N.N.N.N
174+
# Uses '0' for an N in $1 if $1 is shorter than $2
175+
# echo "1" if v1 > v2
176+
# echo "-1" if v1 < v2
177+
# echo "0" if v1 == v2
178+
versionCmp()
179+
{
180+
IFS='.' read -r -a v1_arr <<< "`echo $1`"
181+
IFS='.' read -r -a v2_arr <<< "`echo $2`"
182+
183+
for i in "${!v2_arr[@]}"
184+
do
185+
[ ${v1_arr[i]:-0} -gt ${v2_arr[i]:-0} ] && echo "1" && return
186+
[ ${v1_arr[i]:-0} -lt ${v2_arr[i]:-0} ] && echo "-1" && return
187+
done
188+
echo "0"
189+
}
190+
191+
# versionGE
192+
# return success if WL v1 >= v2
193+
versionGE()
194+
{
195+
[ `versionCmp "$1" "$2"` -ge 0 ] && return 0
196+
return 1
197+
}
198+
199+
# versionEQ
200+
# return success if v1 == v2
201+
versionEQ()
202+
{
203+
[ `versionCmp "$1" "$2"` -eq 0 ] && return 0
204+
return 1
205+
}
206+
207+
# hasWebLogicPatches
208+
# check for the given patch numbers in the install inventory,
209+
# and return 1 if not found
210+
# - if we can't find the install inventory then we
211+
# assume the patch is there...
212+
# - we parse the install inventory as this is far faster than
213+
# using opatch or weblogic.version
214+
hasWebLogicPatches()
215+
{
216+
local reg_file=$ORACLE_HOME/inventory/registry.xml
217+
[ ! -f $reg_file ] && return 0
218+
for pnum in "$@"; do
219+
grep --silent "patch-id=\"$1\"" $reg_file || return 1
220+
done
221+
}
222+
223+
# getWebLogicVersion
224+
# parse wl version from install inventory
225+
# - if we can't get a version number then we return
226+
# a high dummy version number that's sufficient
227+
# to pass version checks "9999.9999.9999.9999"
228+
# - we parse the install inventory as this is far faster than
229+
# using opatch or weblogic.version
230+
getWebLogicVersion()
231+
{
232+
local reg_file=$ORACLE_HOME/inventory/registry.xml
233+
234+
[ ! -f $reg_file ] && echo "9999.9999.9999.9999" && return
235+
236+
# The following grep captures both "WebLogic Server" and "WebLogic Server for FMW"
237+
local wlver="`grep 'name="WebLogic Server.*version=' $reg_file \
238+
| sed 's/.*version="\([0-9.]*\)".*/\1/g'`"
239+
240+
echo ${wlver:-"9999.9999.9999.9999"}
241+
}
242+
243+
244+
# checkWebLogicVersion
245+
# check if the WL version is supported by the Operator
246+
# - skip check if SKIP_WL_VERSION_CHECK = "true"
247+
# - log an error if WL version < 12.2.1.3
248+
# - log an error if WL version == 12.2.1.3 && patch 29135930 is missing
249+
# - you can override the required 12.2.1.3 patches by exporting
250+
# global WL12213REQUIREDPATCHES to an empty string or to other
251+
# patch number(s)
252+
# - return 1 if logged an error
253+
# - return 0 otherwise
254+
checkWebLogicVersion()
255+
{
256+
[ "$SKIP_WL_VERSION_CHECK" = "true" ] && return 0
257+
local cur_wl_ver="`getWebLogicVersion`"
258+
local exp_wl_ver="12.2.1.3"
259+
local exp_wl_12213_patches="${WL12213REQUIREDPATCHES:-"29135930"}"
260+
if versionEQ "$cur_wl_ver" "12.2.1.3" ; then
261+
if ! hasWebLogicPatches $exp_wl_12213_patches ; then
262+
trace "Error: The Operator requires that WebLogic version '12.2.1.3' have patch '$exp_wl_12213_patches'. To bypass this check, set env var SKIP_WL_VERSION_CHECK to 'true'."
263+
return 1
264+
fi
265+
fi
266+
if versionEQ "$cur_wl_ver" "9999.9999.9999.9999" ; then
267+
trace "Info: Could not determine WebLogic version. Assuming version is fine. (The Operator requires WebLogic version '${exp_wl_ver}' or higher, and also requires patches '$exp_wl_12213_patches' for version '12.2.1.3'.)."
268+
return 0
269+
fi
270+
if versionGE "$cur_wl_ver" "${exp_wl_ver}" ; then
271+
trace "Info: WebLogic version='$cur_wl_ver'. Version check passed. (The Operator requires WebLogic version '${exp_wl_ver}' or higher)."
272+
else
273+
trace "Error: WebLogic version='$cur_wl_ver' and the Operator requires WebLogic version '${exp_wl_ver}' or higher. To bypass this check, set env var SKIP_WL_VERSION_CHECK to 'true'."
274+
return 1
275+
fi
276+
return 0
277+
}

0 commit comments

Comments
 (0)