Skip to content

Commit 282a99a

Browse files
committed
Merge branch 'handle-wdt-postcreatefiles' into 'main'
Add support of copying WDT post create hooks output files to log home and refactor the old logic See merge request weblogic-cloud/weblogic-kubernetes-operator!4571
2 parents cbf0e93 + 712e6f7 commit 282a99a

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ IMG_VARIABLE_FILES_ROOTDIR="${IMG_MODELS_HOME}"
1919
WDT_ROOT="/auxiliary/weblogic-deploy"
2020
WDT_OUTPUT_DIR="${LOG_HOME:-/tmp}"
2121
WDT_OUTPUT="${WDT_OUTPUT_DIR}/wdt_output.log"
22-
WDT_CREATE_DOMAIN_LOGROOT="${WLSDEPLOY_LOG_DIRECTORY:-$(echo ${WDT_ROOT}/logs)}"
23-
WDT_CREATE_DOMAIN_LOG="${WDT_CREATE_DOMAIN_LOGROOT}/createDomain.log"
22+
WDT_CREATE_DOMAIN_LOG=createDomain.log
23+
24+
2425
WDT_BINDIR="${WDT_ROOT}/bin"
2526
WLSDEPLOY_PROPERTIES="${WLSDEPLOY_PROPERTIES} -Djava.security.egd=file:/dev/./urandom"
2627
WDT_CONFIGMAP_ROOT="/weblogic-operator/wdt-config-map"
@@ -236,21 +237,18 @@ createDomainFromWDTModel() {
236237
# We need to prevent retries with a "FatalIntrospectorError". We are not retrying create domain for now.
237238
#
238239
trace SEVERE "Domain On PV: FatalIntrospectorError: WDT Create domain failed, return code ${ret}. ${FATAL_JRF_INTROSPECTOR_ERROR_MSG}"
239-
240240
cat ${WDT_OUTPUT}
241-
242-
if [ -d "$LOG_HOME" ] ; then
243-
cp "$WDT_CREATE_DOMAIN_LOG" "$LOG_HOME"
244-
if ls $WDT_ROOT/logs/*.out &> /dev/null ; then (cp $WDT_ROOT/logs/*.out $LOG_HOME) ; fi
245-
trace "WDT log files have been copied to '$LOG_HOME'. Additional RCU log files if any can be found under '$LOG_HOME/rculogdir'"
246-
fi
247-
248241
exitOrLoop
249242
else
250243
trace "WDT Create Domain Succeeded, ret=${ret}:"
251244
cat ${WDT_OUTPUT}
252245
fi
253246

247+
wdtRotateAndCopyLogFile "${WDT_CREATE_DOMAIN_LOG}"
248+
wdtRotateAndCopyOutFile
249+
250+
trace "WDT log files have been copied to '$LOG_HOME'. Additional RCU log files if any can be found under '$LOG_HOME/rculogdir'"
251+
254252
# restore trap
255253
start_trap
256254

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ wdtCreatePrimordialDomain() {
955955
fi
956956

957957
wdtRotateAndCopyLogFile "${WDT_CREATE_DOMAIN_LOG}"
958+
wdtRotateAndCopyOutFile
958959

959960
# restore trap
960961
start_trap

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,33 @@ sort_files() {
7575
shopt -u nullglob
7676
}
7777

78-
79-
# Function to rotate WDT script log file and copy the file to WDT output dir.
78+
# Function to rotate WDT script log file and copy the file to log home
8079
# parameter:
81-
# 1 - Name of the log file to rotate and copy to WDT output directory.
80+
# 1 - Name of the log file to rotate and copy to log home.
8281
wdtRotateAndCopyLogFile() {
8382
local logFileName=$1
83+
# If the special variable WLSDEPLOY_LOG_DIRECTORY is set to log home do nothing
84+
# else copy the command log files
85+
if [ -d "${LOG_HOME}" ] && [ "${WLSDEPLOY_LOG_DIRECTORY}" != "${LOG_HOME}" ] ; then
86+
WDT_LOG_ROOT="${WLSDEPLOY_LOG_DIRECTORY:-$(echo $WDT_ROOT/logs)}"
87+
logFileRotate "${LOG_HOME}/${logFileName}" "${WDT_LOG_FILE_MAX:-11}"
88+
cp "${WDT_LOG_ROOT}/${logFileName}" "${LOG_HOME}"/
89+
fi
90+
91+
}
8492

85-
logFileRotate "${WDT_OUTPUT_DIR}/${logFileName}" "${WDT_LOG_FILE_MAX:-11}"
93+
# These out files are generated by WDT post creation hooks
94+
#
95+
wdtRotateAndCopyOutFile() {
96+
97+
if [ -d "${LOG_HOME}" ] && [ "${WLSDEPLOY_LOG_DIRECTORY}" != "${LOG_HOME}" ] ; then
98+
WDT_LOG_ROOT="${WLSDEPLOY_LOG_DIRECTORY:-$(echo $WDT_ROOT/logs)}"
99+
for file in "${WDT_LOG_ROOT}"/*.out ; do
100+
logFileRotate "${LOG_HOME}/${file}" "${WDT_LOG_FILE_MAX:-11}"
101+
cp "${WDT_LOG_ROOT}/${file}" "${LOG_HOME}"/
102+
done
103+
fi
86104

87-
WDT_LOG_ROOT="${WLSDEPLOY_LOG_DIRECTORY:-$(echo $WDT_ROOT/logs)}"
88-
cp "${WDT_LOG_ROOT}/${logFileName}" ${WDT_OUTPUT_DIR}/
89105
}
90106

91107

0 commit comments

Comments
 (0)