nas-burnin/app
Brandon Walter 9cbae44495
Some checks are pending
Security scan / pip-audit (push) Waiting to run
Security scan / bandit (push) Waiting to run
Security scan / gitleaks (push) Waiting to run
refactor: split burnin.py into a package — extract unlock + kill (1.0.0-30)
First slice of the planned tech-debt cleanup. burnin.py was 1667 lines
and growing; staged extraction gives smaller diffs to review and a
clear bisect target if anything regresses.

Mechanical move only — no behaviour change. The two extracted modules:

* app/burnin/unlock.py — _UnlockGrant, _unlock_grants, PoolMemberError,
  is_unlocked / unlock_expiry / grant_pool_unlock, plus the four
  *_TOKEN constants and UNLOCK_TTL_SECONDS. Owns its module-level
  state; opens its own DB connection in grant_pool_unlock so it
  doesn't depend on the parent package's _db() helper.

* app/burnin/kill.py — _remote_pids dict and the kill_remote_process /
  set_remote_pid / clear_remote_pid / get_remote_pid helpers. Pulled
  out of __init__.py so the asyncssh-ignores-signals workaround lives
  next to the state it operates on.

app/burnin/__init__.py re-exports every public symbol the rest of the
app imports — `from app import burnin; burnin.start_job(...)`,
`burnin.PoolMemberError`, `burnin.UNLOCK_TTL_SECONDS`, etc. all keep
working unchanged. Internal aliases `_remote_pids` and `_unlock_grants`
on the package root point at the SAME dict objects in the submodules,
so existing in-package mutations (set in stages, cleared in cleanup
callbacks) work without rewrite.

Test fix: tests/test_unlock_flow.py:test_expired_grant_returns_false
monkey-patches UNLOCK_TTL_SECONDS. The package-root alias is bound at
import time and won't propagate back to the submodule's read site, so
the test now patches `app.burnin.unlock.UNLOCK_TTL_SECONDS` directly.

Verification: 44/44 unit tests pass in container; /health 200;
container boots clean. routes.py, mailer.py, poller.py untouched —
the public API is identical.

Future: extract stages, task, _common in subsequent versions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:44:28 -04:00
..
burnin refactor: split burnin.py into a package — extract unlock + kill (1.0.0-30) 2026-05-03 00:44:28 -04:00
static feat: secret handling — status badges + redacted endpoint + rotation audit (1.0.0-26) 2026-05-02 18:15:57 -04:00
templates feat: secret handling — status badges + redacted endpoint + rotation audit (1.0.0-26) 2026-05-02 18:15:57 -04:00
__init__.py Initial commit — TrueNAS Burn-In Dashboard v0.5.0 2026-02-24 00:08:29 -05:00
auth.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
auth_cli.py feat: app-level login + hardening sweep (1.0.0-22 -> 1.0.0-23) 2026-05-02 11:08:29 -04:00
config.py refactor: split burnin.py into a package — extract unlock + kill (1.0.0-30) 2026-05-03 00:44:28 -04:00
database.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
logging_config.py Initial commit — TrueNAS Burn-In Dashboard v0.5.0 2026-02-24 00:08:29 -05:00
mailer.py feat: app-level login + hardening sweep (1.0.0-22 -> 1.0.0-23) 2026-05-02 11:08:29 -04:00
main.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
models.py feat: pool-membership lock + cancellation hardening + smart_health refresh + tunables (1.0.0-13 -> 1.0.0-21) 2026-05-02 09:25:56 -04:00
notifier.py Stage 7: SSH architecture, SMART attribute monitoring, drive reset, and polish 2026-02-24 08:09:30 -05:00
poller.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
renderer.py Stage 7: SSH architecture, SMART attribute monitoring, drive reset, and polish 2026-02-24 08:09:30 -05:00
retention.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
routes.py fix: address Codex audit findings (1.0.0-28) 2026-05-02 18:48:16 -04:00
settings_store.py feat: pool-membership lock + cancellation hardening + smart_health refresh + tunables (1.0.0-13 -> 1.0.0-21) 2026-05-02 09:25:56 -04:00
ssh_client.py fix: live pool re-check before start_job + drop dead run_badblocks (1.0.0-29) 2026-05-02 21:29:11 -04:00
terminal.py chore: re-sync deployed work that pre-dates this session 2026-05-02 09:24:42 -04:00
truenas.py chore: re-sync deployed work that pre-dates this session 2026-05-02 09:24:42 -04:00