Skip to content

Commit 9f946bb

Browse files
committed
Make Oracle Database healthcheck wait for the custom scripts to finish
1 parent 801bdcb commit 9f946bb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

OracleDatabase/SingleInstance/dockerfiles/21.3.0/checkDBStatus.sh

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ EOF
7373
################ MAIN #######################
7474
#############################################
7575

76+
if [ "${BYPASS_STARTED_MARKER:-false}" = false ] && [ ! -f /tmp/.oracle_database_started ]; then
77+
echo "Database was not started yet" >&2
78+
exit 1
79+
fi
80+
7681
# Setting up ORACLE_PWD if podman secret is passed on
7782
if [ -e '/run/secrets/oracle_pwd' ]; then
7883
export ORACLE_PWD="$(cat '/run/secrets/oracle_pwd')"

OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ EOF
113113
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
114114
###################################
115115

116+
# Marker file for the healthcheck
117+
rm -f /tmp/.oracle_database_started
118+
116119
# Check whether container has enough memory
117120
if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
118121
memory=$(cat /sys/fs/cgroup/memory.max)
@@ -280,7 +283,7 @@ else
280283
"$ORACLE_BASE"/"$CREATE_DB_FILE" $ORACLE_SID "$ORACLE_PDB" "$ORACLE_PWD" || exit 1;
281284

282285
# Check whether database is successfully created
283-
if "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
286+
if BYPASS_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
284287
# Create a checkpoint file if database is successfully created
285288
# Populate the checkpoint file with the current date to avoid timing issue when using NFS persistence in multi-replica mode
286289
echo "$(date -Iseconds)" > "$ORACLE_BASE"/oradata/.${ORACLE_SID}"${CHECKPOINT_FILE_EXTN}"
@@ -303,7 +306,7 @@ else
303306
fi;
304307

305308
# Check whether database is up and running
306-
"$ORACLE_BASE"/"$CHECK_DB_FILE"
309+
BYPASS_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"
307310
status=$?
308311

309312
# Check whether database is up and running
@@ -317,7 +320,9 @@ if [ $status -eq 0 ]; then
317320

318321
# Execute custom provided startup scripts
319322
"$ORACLE_BASE"/"$USER_SCRIPTS_FILE" "$ORACLE_BASE"/scripts/startup
320-
323+
324+
# Marker file for the healthcheck
325+
touch /tmp/.oracle_database_started
321326
else
322327
echo "#####################################"
323328
echo "########### E R R O R ###############"

0 commit comments

Comments
 (0)