feat(monitor): wire isolated target recovery
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
2d4e4878ae
commit
5f3a6953ee
16 files changed
+1919
-73
No files matched your search
+53
-1
@@ -107,7 +107,7 @@ and exact GGC filtering are unchanged.
|
||||
The isolated [Compose definition](deploy/managed-target/README.md) now supplies
|
||||
the marker, mount and ordered startup; it has not been built or deployed.
|
||||
No Docker socket, remote/container operations, old target paths, Xray edits,
|
||||
monitor loop or host firewall provisioning are included. Before deployment,
|
||||
or host firewall provisioning are included. Before deployment,
|
||||
provisioning must verify the pinned image honors `ZAPRET_CONFIG`, supports all
|
||||
listed variables, and starts ss-local while the baseline leaves nfqws2 disabled.
|
||||
Start the fresh target with that baseline, then verify active apply installs
|
||||
@@ -117,6 +117,58 @@ uncertain, deployment must fail closed, not substitute `restart-daemons` or
|
||||
alter an old config. Persistent volume durability is a provisioning
|
||||
requirement; mountinfo alone cannot establish the storage lifecycle.
|
||||
|
||||
Internal `recoverManagedTarget` and `wireManagedRecovery` add injectable startup
|
||||
bootstrap and saved-first recovery callbacks for the persisted monitor. Bootstrap
|
||||
scans/checks/saves frontend and applies it alone with Player API post-check.
|
||||
Recovery keeps an already healthy frontend, otherwise stops only the fixed
|
||||
target zapret service, tries up to ten qualified saved IDs newest-first, and
|
||||
scans only after complete valid non-pass results or health-rejected rollbacks.
|
||||
Malformed reports/runner errors fail closed. GGC discovery uses the injected
|
||||
managed-SOCKS path, revalidates against the fresh exact host, and saves new
|
||||
immutable evidence before full-set apply. A frontend-only rollback boundary
|
||||
survives GGC failure; unresolved GGC is reported separately, not playback health.
|
||||
Cancelled/failed downtime restores the committed configuration and runs fixed
|
||||
target `start` with an independent 30-second cleanup deadline. Failed cleanup or
|
||||
rollback is fatal to the supervisor; unresolved journal state is never started.
|
||||
The callback caller must hold the monitor singleton; the wiring repeats runtime
|
||||
identity/SOCKS guards. Fake-only checks are added, but tests/build are deferred
|
||||
to the orchestrator. `managed monitor` now binds those callbacks and only the
|
||||
dedicated target entrypoint starts it; no live/runtime validation has occurred.
|
||||
|
||||
## Dedicated monitor integration (verification deferred)
|
||||
|
||||
`zapret-autotune managed monitor [--interval 5m] [--failure-threshold 3]
|
||||
[--cooldown 30m]` uses the health environment defaults. Interval is positive and
|
||||
at most 24h, threshold 1–1000, cooldown positive and at most 168h; explicit empty
|
||||
or invalid settings fail before any lock. No executable/path/proxy flags exist.
|
||||
The DB environment must be exactly `/var/lib/zapret-autotune/target/candidates.db`;
|
||||
existing DB/sidecars must be private, owned regular files without aliases/hard links.
|
||||
Runtime/SOCKS, directory, identity and DB path guards run before the singleton.
|
||||
SQLite opens writable target-owned state; active IDs remain journal/DB/hash validated.
|
||||
|
||||
Probe reuses `health youtube`'s Player API contract, forced owned loopback SOCKS,
|
||||
no direct fallback. Discovery uses that same SOCKS adapter. Scan/check execute
|
||||
only `/usr/bin/blockcheckw`, daemon operations only fixed target-local
|
||||
`/opt/zapret2/init.d/sysv/zapret2` start/stop/restart argv; no shell/eval command
|
||||
strings. Context cancellation kills/waits process groups and bounded restoration
|
||||
finishes before returning. Reports suppress untrusted diagnostics and credentials.
|
||||
|
||||
Startup reconciles transactions under the singleton and bootstraps only when no
|
||||
qualified active frontend exists. Bootstrap/recovery checks saved candidates first;
|
||||
GGCError reports unresolved and continues probing, not playback success. Other
|
||||
DB/safety/journal/runner failures stop nonzero; joined cancellation plus a cleanup
|
||||
failure is also fatal. A qualified frontend at startup is probed immediately,
|
||||
not rescanned merely because the process restarted.
|
||||
|
||||
Entrypoint ordering is SS children → listener → managed init/status → zapret start
|
||||
→ one installed `/usr/local/bin/zapret-autotune managed monitor` child. It supervises
|
||||
all three children; monitor exit is fatal even if it exits zero unexpectedly.
|
||||
SIGTERM/SIGINT cancels and waits the monitor before target-local zapret stop and
|
||||
SS child termination/wait. Existing targets and Xray remain unchanged. Deployment
|
||||
must allow enough shutdown grace for independently bounded rollback/restoration
|
||||
(potentially more than the currently defined 45s); this increment changes no Docker
|
||||
configuration. Code integration is not image/routing/signal live verification.
|
||||
|
||||
Injected unit tests cover exact identity/path/config, mountpoint refusal,
|
||||
old-container-like env, SOCKS port/process refusal, correct fresh-target success,
|
||||
non-overwrite, transaction rollback and redaction. Tests/build/network are
|
||||
|
||||
Reference in new issue
Block a user