@@ -40,47 +40,7 @@ output:
4040 # This script block ensures its exit code is preserved
4141 # while its stdout and stderr are tee'd.
4242 _script_to_run() {
43-
44- export POSTSTART_TIMEOUT_DURATION="0"
45- export POSTSTART_KILL_AFTER_DURATION="5"
46-
47- _TIMEOUT_COMMAND_PART=""
48- _WAS_TIMEOUT_USED="false" # Use strings "true" or "false" for shell boolean
49-
50- if command -v timeout >/dev/null 2>&1; then
51- echo "[postStart hook] Executing commands with timeout: ${POSTSTART_TIMEOUT_DURATION} seconds, kill after: ${POSTSTART_KILL_AFTER_DURATION} seconds" >&2
52- _TIMEOUT_COMMAND_PART="timeout --preserve-status --kill-after=${POSTSTART_KILL_AFTER_DURATION} ${POSTSTART_TIMEOUT_DURATION}"
53- _WAS_TIMEOUT_USED="true"
54- else
55- echo "[postStart hook] WARNING: 'timeout' utility not found. Executing commands without timeout." >&2
56- fi
57-
58- # Execute the user's script
59- ${_TIMEOUT_COMMAND_PART} /bin/sh -c 'set -e
60- echo '\''hello world 1'\'''
61- exit_code=$?
62-
63- # Check the exit code based on whether timeout was attempted
64- if [ "$_WAS_TIMEOUT_USED" = "true" ]; then
65- if [ $exit_code -eq 143 ]; then # 128 + 15 (SIGTERM)
66- echo "[postStart hook] Commands terminated by SIGTERM (likely timed out after ${POSTSTART_TIMEOUT_DURATION}s). Exit code 143." >&2
67- elif [ $exit_code -eq 137 ]; then # 128 + 9 (SIGKILL)
68- echo "[postStart hook] Commands forcefully killed by SIGKILL (likely after --kill-after ${POSTSTART_KILL_AFTER_DURATION}s expired). Exit code 137." >&2
69- elif [ $exit_code -ne 0 ]; then # Catches any other non-zero exit code
70- echo "[postStart hook] Commands failed with exit code $exit_code." >&2
71- else
72- echo "[postStart hook] Commands completed successfully within the time limit." >&2
73- fi
74- else
75- if [ $exit_code -ne 0 ]; then
76- echo "[postStart hook] Commands failed with exit code $exit_code (no timeout)." >&2
77- else
78- echo "[postStart hook] Commands completed successfully (no timeout)." >&2
79- fi
80- fi
81-
82- exit $exit_code
83- # This will be replaced by scriptWithTimeout
43+ echo 'hello world 1' # This will be replaced by scriptWithTimeout
8444 }
8545 _script_to_run
8646 } 1> >(tee -a "/tmp/poststart-stdout.txt") 2> >(tee -a "/tmp/poststart-stderr.txt" >&2)
@@ -97,50 +57,10 @@ output:
9757 # This script block ensures its exit code is preserved
9858 # while its stdout and stderr are tee'd.
9959 _script_to_run() {
100-
101- export POSTSTART_TIMEOUT_DURATION="0"
102- export POSTSTART_KILL_AFTER_DURATION="5"
103-
104- _TIMEOUT_COMMAND_PART=""
105- _WAS_TIMEOUT_USED="false" # Use strings "true" or "false" for shell boolean
106-
107- if command -v timeout >/dev/null 2>&1; then
108- echo "[postStart hook] Executing commands with timeout: ${POSTSTART_TIMEOUT_DURATION} seconds, kill after: ${POSTSTART_KILL_AFTER_DURATION} seconds" >&2
109- _TIMEOUT_COMMAND_PART="timeout --preserve-status --kill-after=${POSTSTART_KILL_AFTER_DURATION} ${POSTSTART_TIMEOUT_DURATION}"
110- _WAS_TIMEOUT_USED="true"
111- else
112- echo "[postStart hook] WARNING: 'timeout' utility not found. Executing commands without timeout." >&2
113- fi
114-
115- # Execute the user's script
116- ${_TIMEOUT_COMMAND_PART} /bin/sh -c 'set -e
117- cd '\''/tmp/test-dir'\'' && echo '\''hello world 2'\'''
118- exit_code=$?
119-
120- # Check the exit code based on whether timeout was attempted
121- if [ "$_WAS_TIMEOUT_USED" = "true" ]; then
122- if [ $exit_code -eq 143 ]; then # 128 + 15 (SIGTERM)
123- echo "[postStart hook] Commands terminated by SIGTERM (likely timed out after ${POSTSTART_TIMEOUT_DURATION}s). Exit code 143." >&2
124- elif [ $exit_code -eq 137 ]; then # 128 + 9 (SIGKILL)
125- echo "[postStart hook] Commands forcefully killed by SIGKILL (likely after --kill-after ${POSTSTART_KILL_AFTER_DURATION}s expired). Exit code 137." >&2
126- elif [ $exit_code -ne 0 ]; then # Catches any other non-zero exit code
127- echo "[postStart hook] Commands failed with exit code $exit_code." >&2
128- else
129- echo "[postStart hook] Commands completed successfully within the time limit." >&2
130- fi
131- else
132- if [ $exit_code -ne 0 ]; then
133- echo "[postStart hook] Commands failed with exit code $exit_code (no timeout)." >&2
134- else
135- echo "[postStart hook] Commands completed successfully (no timeout)." >&2
136- fi
137- fi
138-
139- exit $exit_code
140- # This will be replaced by scriptWithTimeout
60+ cd /tmp/test-dir
61+ echo 'hello world 2' # This will be replaced by scriptWithTimeout
14162 }
14263 _script_to_run
14364 } 1> >(tee -a "/tmp/poststart-stdout.txt") 2> >(tee -a "/tmp/poststart-stderr.txt" >&2)
144-
14565 - name : test-component-3
14666 image : test-img
0 commit comments