Skip to content

Commit 5166066

Browse files
committed
Merge branch 'trap' into 'main'
Cleanup traps and container exit messages See merge request weblogic-cloud/weblogic-kubernetes-operator!4933
2 parents 48eb0dc + c6a065f commit 5166066

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

deployment/scripts/operator.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2017, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
echo "Launching Oracle WebLogic Server Kubernetes Operator..."
@@ -9,10 +9,27 @@ relay_SIGTERM() {
99
pid=`grep java /proc/[0-9]*/comm | awk -F / '{ print $3; }'`
1010
echo "Sending SIGTERM to java process " $pid
1111
kill -SIGTERM $pid
12+
exit 0
1213
}
1314

1415
trap relay_SIGTERM SIGTERM
1516

17+
# Relays SIGKILL to all java processes
18+
relay_SIGKILL() {
19+
pid=`grep java /proc/[0-9]*/comm | awk -F / '{ print $3; }'`
20+
echo "Sending SIGKILL to java process " $pid
21+
kill -SIGKILL $pid
22+
exit 0
23+
}
24+
25+
trap relay_SIGKILL SIGKILL
26+
27+
exitMessage() {
28+
echo "Exiting container for the Oracle WebLogic Server Kubernetes Operator..."
29+
}
30+
31+
trap exitMessage EXIT
32+
1633
DEPLOYMENT_DIR="/deployment"
1734
${DEPLOYMENT_DIR}/initialize-external-operator-identity.sh
1835

deployment/scripts/webhook.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
2-
# Copyright (c) 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

5-
echo "Launching the Domain Custom Resource Conversion Webhook for Oracle WebLogic Server Kubernetes Operator..."
5+
echo "Launching the Schema Conversion Webhook for Oracle WebLogic Server Kubernetes Operator..."
66

77
# Relays SIGTERM to all java processes
88
relay_SIGTERM() {
@@ -13,6 +13,22 @@ relay_SIGTERM() {
1313

1414
trap relay_SIGTERM SIGTERM
1515

16+
# Relays SIGKILL to all java processes
17+
relay_SIGKILL() {
18+
pid=`grep java /proc/[0-9]*/comm | awk -F / '{ print $3; }'`
19+
echo "Sending SIGKILL to java process " $pid
20+
kill -SIGKILL $pid
21+
exit 0
22+
}
23+
24+
trap relay_SIGKILL SIGKILL
25+
26+
exitMessage() {
27+
echo "Exiting container for the Schema Conversion Webhook for Oracle WebLogic Server Kubernetes Operator..."
28+
}
29+
30+
trap exitMessage EXIT
31+
1632
if [[ ! -z "$REMOTE_DEBUG_PORT" ]]; then
1733
DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,suspend=$DEBUG_SUSPEND,address=*:$REMOTE_DEBUG_PORT"
1834
echo "DEBUG=$DEBUG"

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#!/bin/bash
2-
# Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2017, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
#
66
# startServer.sh
77
# This is the script WebLogic Operator WLS Pods use to start their WL Server.
88
#
99

10+
cleanup() {
11+
trace "Suppressing signal to allow container to exit cleanly."
12+
exit 0
13+
}
14+
15+
trap cleanup SIGTERM SIGKILL
16+
17+
exitMessage() {
18+
trace "Exiting container for WebLogic Server '${SERVER_NAME}'."
19+
}
20+
21+
trap exitMessage EXIT
22+
1023
if [ -z ${SCRIPTPATH+x} ]; then
1124
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
1225
fi
@@ -312,7 +325,7 @@ else
312325
fi
313326

314327
#
315-
# Wait forever. Kubernetes will monitor this pod via liveness and readyness probes.
328+
# Wait forever. Kubernetes will monitor this pod via liveness and readiness probes.
316329
#
317330

318331
waitForShutdownMarker

0 commit comments

Comments
 (0)