fix: prevent automatic retries of failed startup apply
Latch explicit resource apply once per PID 1 lifetime. Fail closed before launch and permanently pause after authoritative cleanup on failed or incomplete apply; retain reconciliation on successful monitor and service restarts. Cover deterministic 180-second retry windows, launch/ACK/child/session/service failures, cancellation, successful restarts and fresh-PID1 flags. Document RAM-only reset limits and repair-only startup; no remote health acceptance is claimed. Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
36aace02da
commit
643d0c6220
3 files changed
+111
-13
No files matched your search
@@ -20,6 +20,8 @@ generic_mode=0
|
||||
[ -z "${ZAPRET_AUTOTUNE_RESOURCE_CONFIG-}" ] || generic_mode=1
|
||||
qualification_mode=0
|
||||
qualification_attempted=0
|
||||
# RAM-only authorization: a new PID 1 may attempt again, never a runtime retry.
|
||||
resource_apply_state=unattempted
|
||||
if [ -n "${ZAPRET_AUTOTUNE_QUALIFY_CONFIG-}${ZAPRET_AUTOTUNE_STRATEGY_CONFIG-}" ]; then
|
||||
[ -n "${ZAPRET_AUTOTUNE_QUALIFY_CONFIG-}" ] && [ -n "${ZAPRET_AUTOTUNE_STRATEGY_CONFIG-}" ] || {
|
||||
echo 'error: isolated qualification requires both config and strategy paths' >&2; exit 64;
|
||||
@@ -375,6 +377,7 @@ launch_controller() {
|
||||
fi
|
||||
}
|
||||
run_cycle() {
|
||||
[ "$resource_apply_state" != failed ] || return 78
|
||||
[ "$qualification_attempted" -eq 0 ] || return 78
|
||||
start_dns || return $?
|
||||
set -- ss-server -c "$config_dir/server.json"
|
||||
@@ -406,7 +409,8 @@ fi
|
||||
timeout -k 5 45 /usr/local/bin/zapret-autotune managed reconcile || return 78
|
||||
if [ "$qualification_mode" -eq 0 ]; then
|
||||
zapret_started=1
|
||||
if [ "${ZAPRET_AUTOTUNE_RESOURCE_APPLY-0}" = 1 ]; then
|
||||
if [ "${ZAPRET_AUTOTUNE_RESOURCE_APPLY-0}" = 1 ] && [ "$resource_apply_state" = unattempted ]; then
|
||||
resource_apply_state=failed
|
||||
launch_controller managed resource-apply --resource-config "$ZAPRET_AUTOTUNE_RESOURCE_CONFIG" || return 78
|
||||
while dns_alive && kill -0 "$server_pid" && kill -0 "$local_pid" && kill -0 "$monitor_pid"; do pause 1; done
|
||||
{ dns_alive && kill -0 "$server_pid" && kill -0 "$local_pid"; } || return 75
|
||||
@@ -416,6 +420,7 @@ if [ "${ZAPRET_AUTOTUNE_RESOURCE_APPLY-0}" = 1 ]; then
|
||||
monitor_pid=
|
||||
cleanup_session || { echo 'controller-startup: apply_cleanup=failed' >&2; return 78; }
|
||||
[ "$apply_code" -eq 0 ] || return 78
|
||||
resource_apply_state=succeeded
|
||||
fi
|
||||
# Idempotent apply may have only verified the already committed config.
|
||||
timeout -k 5 30 /opt/zapret2/init.d/sysv/zapret2 start || return 78
|
||||
@@ -501,6 +506,10 @@ while :; do
|
||||
fi
|
||||
code=78
|
||||
fi
|
||||
if [ "$resource_apply_state" = failed ]; then
|
||||
echo 'BLOCKED: resource apply failed/incomplete; operator repair/restart required' >&2
|
||||
while :; do pause 60; done
|
||||
fi
|
||||
if [ "$generic_mode" -eq 1 ] && [ "$code" -eq 78 ]; then
|
||||
echo 'BLOCKED: generic target trust/startup failure; checks paused' >&2
|
||||
pause 60
|
||||
|
||||
Reference in new issue
Block a user