Skip to content

Temporarily disable trap in diff_model as logFileRotate or testLogFileRotate may return non-zero code. #2629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions operator/src/main/resources/scripts/modelInImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ function diff_model_v1() {

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

export __WLSDEPLOY_STORE_MODEL__=1
# $1 - new model, $2 original model
Expand Down Expand Up @@ -678,6 +681,9 @@ function diff_model() {

wdtRotateAndCopyLogFile "${WDT_COMPARE_MODEL_LOG}"

# restore trap
start_trap

trace "Exiting diff_model"
}

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

logFileRotate ${WDT_OUTPUT_DIR}/${logFileName} ${WDT_LOG_FILE_MAX:-11}
logFileRotate "${WDT_OUTPUT_DIR}/${logFileName}" "${WDT_LOG_FILE_MAX:-11}"

cp ${WDT_ROOT}/logs/${logFileName} ${WDT_OUTPUT_DIR}/
}
19 changes: 13 additions & 6 deletions operator/src/main/resources/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ function logFileRotateInner() {
_logmax_=$((logmax - 1))
fi
for logcur in $(logFilesReverse ${1} | tail -n +${_logmax_}); do
[ ! "$3" = "quiet" ] && trace "Removing old log file '${logcur}'."
rm $logcur
if [ -f "$logcur" ] ; then
[ ! "$3" = "quiet" ] && trace "Removing old log file '${logcur}'."
rm $logcur
fi
done

# if highest lognum is 99999, renumber existing files starting with 1
Expand All @@ -172,7 +174,9 @@ function logFileRotateInner() {
local logcur
for logcur in $(logFiles "$1"); do
lastlognum=$((lastlognum + 1))
mv "$logcur" "${1}$(printf "%0.5i" $lastlognum)"
if [ -f "$logcur" ] ; then
mv "$logcur" "${1}$(printf "%0.5i" $lastlognum)"
fi
done
fi

Expand All @@ -182,13 +186,16 @@ function logFileRotateInner() {
if [ -f "$1" ]; then
local nextlognum=$((lastlognum + 1))
[ ! "$3" = "quiet" ] && trace "Rotating '$1' to '${1}$(printf "%0.5i" $nextlognum)'."
mv "$1" "${1}$(printf "%0.5i" $nextlognum)"
if [ -f "$1" ] ; then
mv "$1" "${1}$(printf "%0.5i" $nextlognum)"
fi
fi
else
rm -f "$1"
if [ -f "$1" ] ; then
rm -f "$1"
fi
fi
}

#
# internal helper for logFileRotate():
#
Expand Down