Skip to content

Commit 176107b

Browse files
authored
Merge pull request #575 from oracle/owls-70534-error-handling
OWLS-70534 improve create domain job error handling
2 parents 0955ec3 + 6b55f87 commit 176107b

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/common/create-domain-job.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
44
#
55

6+
function exitIfError {
7+
if [ "$1" != "0" ]; then
8+
echo "$2"
9+
exit $1
10+
fi
11+
}
12+
613
# Include common utility functions
714
source ${CREATE_DOMAIN_SCRIPT_DIR}/utility.sh
815

@@ -15,9 +22,11 @@ prepareDomainHomeDir
1522

1623
# Execute the script to create the domain
1724
source $script
25+
exitIfError $? "ERROR: $script failed."
1826

1927
# Create the node manager
2028
wlst.sh -skipWLSModuleScanning ${CREATE_DOMAIN_SCRIPT_DIR}/setup-nodemanager.py
29+
exitIfError $? "ERROR: setup node manager failed."
2130

2231
# DON'T REMOVE THIS
2332
# This script has to contain this log message.

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,34 +469,35 @@ function createDomainHome {
469469
while [ "$JOB_STATUS" != "Completed" -a $count -lt $max ] ; do
470470
sleep 30
471471
count=`expr $count + 1`
472-
JOB_STATUS=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $3; } '`
473-
JOB_INFO=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print "pod", $1, "status is", $3; } '`
472+
JOBS=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME}`
473+
JOB_ERRORS=`kubectl logs jobs/$JOB_NAME -n ${namespace} | grep "ERROR:" `
474+
JOB_STATUS=`echo $JOBS | awk ' { print $3; } '`
475+
JOB_INFO=`echo $JOBS | awk ' { print "pod", $1, "status is", $3; } '`
474476
echo "status on iteration $count of $max"
475477
echo "$JOB_INFO"
476478

477479
# Terminate the retry loop when a fatal error has already occurred. Search for "ERROR:" in the job log file
478480
if [ "$JOB_STATUS" != "Completed" ]; then
479-
JOB_ERRORS=`kubectl logs jobs/$JOB_NAME -n ${namespace} | grep "ERROR:" `
480481
ERR_COUNT=`echo $JOB_ERRORS | grep "ERROR:" | wc | awk ' {print $1; }'`
481482
if [ "$ERR_COUNT" != "0" ]; then
482-
echo A failure was detected in the log file for job $JOB_NAME
483-
echo $JOB_ERRORS
484-
echo Check the log output for additional information
485-
fail "Exiting due to failure - the job has failed"
483+
echo "A failure was detected in the log file for job $JOB_NAME."
484+
echo "$JOB_ERRORS"
485+
echo "Check the log output for additional information."
486+
fail "Exiting due to failure - the job has failed!"
486487
fi
487488
fi
488489
done
489490

490491
# Confirm the job pod is status completed
491-
JOB_POD=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $1; } '`
492492
if [ "$JOB_STATUS" != "Completed" ]; then
493-
echo The create domain job is not showing status completed after waiting 300 seconds
494-
echo Check the log output for errors
493+
echo "The create domain job is not showing status completed after waiting 300 seconds."
494+
echo "Check the log output for errors."
495495
kubectl logs jobs/$JOB_NAME -n ${namespace}
496496
fail "Exiting due to failure - the job status is not Completed!"
497497
fi
498498

499499
# Check for successful completion in log file
500+
JOB_POD=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $1; } '`
500501
JOB_STS=`kubectl logs $JOB_POD -n ${namespace} | grep "Successfully Completed" | awk ' { print $1; } '`
501502
if [ "${JOB_STS}" != "Successfully" ]; then
502503
echo The log file for the create domain job does not contain a successful completion status

0 commit comments

Comments
 (0)