docs: add lifecycle script exit code reliability guide#81
docs: add lifecycle script exit code reliability guide#81
Conversation
Adds addon-lifecycle-script-exit-code-reliability-guide.md — a cross-engine reference for writing and reviewing KubeBlocks lifecycle action scripts. Covers: - The exit-0 silent-failure root cause and why KubeBlocks cannot detect it - Three mandatory verification paths: happy path, forced failure, runtime readback - kbagent 60s hard clamp and retryPolicy budget calculation - Pre-merge 7-item checklist Appendix A: Oracle W8b sqlplus WHENEVER SQLERROR / CDB open-mode wait case (contributed by Sophia). Appendix B: redis-cli exit-0 pitfalls and output-inspection pattern. Adds one entry to SKILL-INDEX.md Section 1 (设计/开发新 addon).
weicao
left a comment
There was a problem hiding this comment.
Blocking issue before merge:
- The Oracle forced-failure example says
Expected: exit 1476. Shell/process exit statuses are not a reliable place to preserve the full Oracle error number; values are constrained/truncated by the OS/shell. The test should assert onlyexit != 0and verify the output containsORA-01476, not compare the exact numeric exit code.
Please change that expected line to something like: Expected: non-zero exit; output contains ORA-01476. The rest of the structure looks aligned: engine-neutral body, runtime readback retained, and SKILL-INDEX entry present.
|
Oracle Appendix A / forced-failure assertion patch proposal from Sophia, reviewed by James. Allen's requested change is addressed in two places:
James completed 8-class XP review and approved the final form. diff --git a/docs/addon-lifecycle-script-exit-code-reliability-guide.md b/docs/addon-lifecycle-script-exit-code-reliability-guide.md
index 85e2fba..40d6b2e 100644
--- a/docs/addon-lifecycle-script-exit-code-reliability-guide.md
+++ b/docs/addon-lifecycle-script-exit-code-reliability-guide.md
@@ -82,6 +82,12 @@ This is the path most teams skip. Without it, you cannot know whether your error
Criterion: exit_code != 0 (the script must propagate the failure)+Rule: for forced failure, assert 2.3 Runtime ReadbackAfter a successful action (exit 0), independently verify the side effect occurred: -kubectl exec -i -n $NAMESPACE $POD -c oracle -- bash -lc "
+if output=$(kubectl exec -i -n $NAMESPACE $POD -c oracle -- bash -lc "
sqlplus -S / as sysdba <<'SQL'
WHENEVER SQLERROR EXIT SQL.SQLCODE
SELECT 1/0 FROM dual;
EXIT;
-SQL"
-echo "Exit code: $?"
-# Expected: exit 1476 (ORA-01476: divisor is equal to zero)
+SQL" 2>&1)
+then
+ rc=0
+else
+ rc=$?
+fi
+printf '%s\n' "$output"
+echo "Exit code: $rc"
+
+# Expected: non-zero exit; output contains ORA-01476.
+# Do not assert rc == 1476: shell exit status is 8-bit, so SQLCODE is truncated.
+test "$rc" -ne 0
+printf '%s\n' "$output" | grep -q "ORA-01476"Without fix (expected: exit 0 — old silent behavior): |
Summary
addon-lifecycle-script-exit-code-reliability-guide.md— a cross-engine guide on writing and verifying KubeBlocks lifecycle action scriptsdocs/SKILL-INDEX.mdSection 1 (设计/开发新 addon)Test plan