wzcheng99 33821f7a9f T2 ckpt 9 follow-up: Discovery no longer gated on backend readiness
Architect residual-risk note (round-9 review): iSCSI Target
opened the frontend.Backend at accept time, before login. Any
connection — including Discovery — blocked on Provider.Open's
ErrNotReady wait, so `iscsiadm -m discovery` against a
not-yet-Healthy volume would hang instead of returning
SendTargets. Called out as a future m01 compat risk, not a
reject, but small enough to close now.

Fix:
  - Target.handleConn no longer opens the backend. It hands
    Provider + VolumeID + HandlerConfig to newSession and
    lets the session decide.
  - Session.serve does login FIRST. After login:
      Discovery session  → skip backend open entirely;
                           serve Text/Logout/NOP-Out only.
      Normal session     → call Provider.Open; a failure (e.g.
                           ErrNotReady) closes the session
                           cleanly after login rather than
                           blocking at accept.
  - Target shutdown watcher now cancels the session ctx in
    addition to closing the conn — required so a Provider.Open
    that only wakes on ctx.Done can unblock during
    Target.Close (avoids shutdown deadlock in the
    never-ready regression test).

core/frontend/iscsi/session.go
  Session now carries provider + volumeID + hcfg + backend.
  serve(): loginPhase → (SessionType==Normal ? Provider.Open
  + build SCSIHandler : skip) → fullFeatureLoop. close()
  also closes the opened backend.

core/frontend/iscsi/target.go
  handleConn hands provider/volumeID/hcfg to newSession;
  shutdown watcher cancels ctx so blocked Open unblocks.

core/frontend/iscsi/discovery_without_backend_test.go (NEW)
  Two regression tests:
    - TestT2Route_ISCSI_DiscoveryDoesNotDependOnBackendReady:
        target bound to a neverReadyProvider (Open blocks
        forever until ctx done); Discovery session completes
        login + SendTargets + assertion within 5s. Asserts
        Provider.Open was called ZERO times during Discovery.
    - TestT2Route_ISCSI_NormalSessionClosesWhenProviderNotReady:
        Normal-session login completes within 2s even though
        Open blocks indefinitely — proves login isn't gated
        on backend readiness.

Tests green (no regressions):
  core/frontend/iscsi:  56 tests (was 54; +2 residual-risk regs)
  All other packages:   unchanged.

Stop-rule audit: fix is mechanism-level, stays inside the ckpt 9
allowlist (no new auth / digest / storage / authority paths).
Signs-off tier unchanged (T2A-iSCSI-provisional).
2026-04-21 22:19:26 -07:00
Languages
Go 84.6%
Rust 7.8%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%