Skip to content

Commit 22be7d5

Browse files
authored
Temporarily disable trap in diff_model as logFileRotate or testLogFileRotate may return non-zero code. (#2629)
* Temporarily disable trap in diff_model as it logFileRotate or testLogFileRotate may return non-zero code. * Changes to check that file exists before trying to move or remove it. * Remove disabling of trap in wdtRotateAndCopyLogFile function.
1 parent 223eeb9 commit 22be7d5

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ function diff_model_v1() {
626626

627627
function diff_model() {
628628
trace "Entering diff_model"
629+
# wdt shell script or logFileRotate may return non-zero code if trap is on, then it will go to trap instead
630+
# temporarily disable it
631+
stop_trap
629632

630633
export __WLSDEPLOY_STORE_MODEL__=1
631634
# $1 - new model, $2 original model
@@ -678,6 +681,9 @@ function diff_model() {
678681

679682
wdtRotateAndCopyLogFile "${WDT_COMPARE_MODEL_LOG}"
680683

684+
# restore trap
685+
start_trap
686+
681687
trace "Exiting diff_model"
682688
}
683689

@@ -1351,10 +1357,8 @@ function logSevereAndExit() {
13511357
# 1 - Name of the log file to rotate and copy to WDT output directory.
13521358
function wdtRotateAndCopyLogFile() {
13531359
local logFileName=$1
1354-
testLogFileRotate "${WDT_OUTPUT_DIR}/${logFileName}"
1355-
[ $? -ne 0 ] && trace SEVERE "Error accessing '${WDT_OUTPUT_DIR}'. See previous log messages." && exit 1
13561360

1357-
logFileRotate ${WDT_OUTPUT_DIR}/${logFileName} ${WDT_LOG_FILE_MAX:-11}
1361+
logFileRotate "${WDT_OUTPUT_DIR}/${logFileName}" "${WDT_LOG_FILE_MAX:-11}"
13581362

13591363
cp ${WDT_ROOT}/logs/${logFileName} ${WDT_OUTPUT_DIR}/
13601364
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ function logFileRotateInner() {
160160
_logmax_=$((logmax - 1))
161161
fi
162162
for logcur in $(logFilesReverse ${1} | tail -n +${_logmax_}); do
163-
[ ! "$3" = "quiet" ] && trace "Removing old log file '${logcur}'."
164-
rm $logcur
163+
if [ -f "$logcur" ] ; then
164+
[ ! "$3" = "quiet" ] && trace "Removing old log file '${logcur}'."
165+
rm $logcur
166+
fi
165167
done
166168

167169
# if highest lognum is 99999, renumber existing files starting with 1
@@ -172,7 +174,9 @@ function logFileRotateInner() {
172174
local logcur
173175
for logcur in $(logFiles "$1"); do
174176
lastlognum=$((lastlognum + 1))
175-
mv "$logcur" "${1}$(printf "%0.5i" $lastlognum)"
177+
if [ -f "$logcur" ] ; then
178+
mv "$logcur" "${1}$(printf "%0.5i" $lastlognum)"
179+
fi
176180
done
177181
fi
178182

@@ -182,13 +186,16 @@ function logFileRotateInner() {
182186
if [ -f "$1" ]; then
183187
local nextlognum=$((lastlognum + 1))
184188
[ ! "$3" = "quiet" ] && trace "Rotating '$1' to '${1}$(printf "%0.5i" $nextlognum)'."
185-
mv "$1" "${1}$(printf "%0.5i" $nextlognum)"
189+
if [ -f "$1" ] ; then
190+
mv "$1" "${1}$(printf "%0.5i" $nextlognum)"
191+
fi
186192
fi
187193
else
188-
rm -f "$1"
194+
if [ -f "$1" ] ; then
195+
rm -f "$1"
196+
fi
189197
fi
190198
}
191-
192199
#
193200
# internal helper for logFileRotate():
194201
#

0 commit comments

Comments
 (0)