Repository navigation
fix(mpc): actionable optimizer error when the ftw-optimizer sidecar is unavailable - #700
Conversation
miravoss26
left a comment
There was a problem hiding this comment.
Read the diff. Clean, well-scoped fix: ensureStartedLocked now resolves the worker interpreter with exec.LookPath before fork/exec, so an absent Python worker on the containerized core returns the actionable errOptimizerWorkerMissing ("run the ftw-optimizer sidecar") instead of a bare exec: "python3": not found in $PATH that reads as a missing core dependency. Pure observability change: the Go DP fallback path is untouched, and there's a regression test that pins the wrapped-error behavior.
- Correctness: same failure outcome, clearer message at the source, so it propagates through
FallbackReason+ logs + the components API as the description says.LookPathaccepting an absolute path keeps theFTW_OPTIMIZER_PYTHONnative builds working.errorsis already imported on the file, so the new sentinel compiles. Looks right to me. - Security: nothing flagged. Stdlib only (no new deps), no secrets, no authz or network surface. The docker-compose diff is comment-only.
- Landing blocker: GitHub shows this as CONFLICTING with the base, so it needs a rebase before it can merge.
- No CI checks are attached to this PR that I can see. Worth confirming
go build ./... && go test ./internal/mpc/is green locally before it lands.
Safe to merge from my read once it's rebased and the build's confirmed green. Not in my auto-merge allowlist, so I'm leaving the merge to a human.
miravoss26
left a comment
There was a problem hiding this comment.
Read the whole diff. Clean, well-scoped fix: ensureStartedLocked now LookPaths the worker before fork/exec, so the containerized core (ships no Python) returns a wrapped errOptimizerWorkerMissing pointing at the ftw-optimizer sidecar instead of a bare exec: "python3": not found in $PATH. Two things I checked and liked: the lookup sits after the t.cmd != nil guard so it's cold-start only, and FTW_OPTIMIZER_PYTHON native builds keep working since LookPath takes absolute paths too.
Security screen: clean. No secrets, no new deps (stdlib os/exec), no network or authz changes; the command string is operator config, not user input. The %w wrap plus the new regression test cover the errors.Is path.
One optional question, not a blocker: does the auto transport still fall back to the Go DP planner on the new errOptimizerWorkerMissing the way it did on the old bare exec error? The existing fallback tests look like they cover any process-transport error, so likely yes. A one-liner asserting auto-fallback specifically on the missing-worker error would nail the regression shut.
Safe to merge from my read.
…s unavailable The containerized core ships no Python, so the auto/process optimizer transport can never start the bundled python3 worker there. Instead of surfacing a bare 'exec: "python3": not found in $PATH' — which reads as a missing core dependency and hides the real remedy — ProcessTransport now resolves the interpreter with exec.LookPath before fork/exec and returns an actionable errOptimizerWorkerMissing that points operators at the ftw-optimizer sidecar. The message propagates unchanged to FallbackReason, logs and the components API. Native/all-in-one builds that set FTW_OPTIMIZER_PYTHON are unaffected (LookPath accepts an absolute path). Also corrects the docker-compose.yml comment that claimed core falls back to a bundled Python worker it does not have. Fixes srcfl#699 Co-authored-by: HuggeK <[email protected]>
97afac0 to
7e302d1
Compare
|
Thanks for the review, @miravoss26 — both points addressed:
|
Fixes #699.
Problem
On the containerized core (
ghcr.io/srcfl/ftw, analpineimage with noPython), whenever the
auto/processoptimizer transport is selected and theftw-optimizersidecar is unavailable, core tries to spawn the bundledpython3 -m ftw_optimizer.workerand fails with:That string is surfaced as the optimizer's
error/fallback_reason(and inlogs), so an operator sees a "missing Python" error that (a) reads as a missing
core dependency — contradicting the module architecture, where Python lives
only in the optimizer image — and (b) hides the real remedy: start the
ftw-optimizersidecar. Core still plans safely on the Go DP fallback, so thisis an observability defect, not a safety one.
Fix
Resolve the worker interpreter with
exec.LookPathbefore fork/exec inProcessTransport. When it is absent, return a sentinelerrOptimizerWorkerMissingwhose message names the remedy instead of the rawexec error:
external_optimizer.go→service.goFallbackReason, logs and thecomponents API.
LookPathaccepts an absolute path too, so native/all-in-one deployments thatset
FTW_OPTIMIZER_PYTHONare unaffected — only the missing-interpretermessage changes.
Why not just install Python into core?
The optimizer is deliberately a separate, independently updatable image
(
Dockerfile.optimizer); core stays a slim Go binary so optimizer dependencychurn never enlarges the safety-critical runtime (
docs/architecture.md,Dockerfile:1-3). The bundledpython3process transport only makes sense fornative/all-in-one deployments; on the container it can never run, which is
exactly why the error needed to be actionable rather than literal.
Testing
Rebased onto
master;go build ./...andgo vet ./internal/mpc/are clean.go test ./internal/mpc/covers the missing-worker path at all three entrypoints:
TestProcessTransportReportsMissingWorkerActionably—RoundTripwith anabsent interpreter wraps
errOptimizerWorkerMissingand names theftw-optimizer sidecar.TestProcessTransportHealthReportsMissingWorker— theHealthpath (read by/api/components) now asserts the same actionable sentinel instead of the oldbare
start optimizer …string.TestAutoTransportSurfacesMissingWorkerFromProcessFallback— new, perreview feedback: with the
autotransport (down sidecar + process fallback),the wrapped
errOptimizerWorkerMissingsurvives the auto layer viaerrors.Is, soservice.go'sFallbackReasoncarries the actionable textall the way to the operator.
One pre-existing test fails only on a Windows dev box
TestUnixTransportHandshakeAndRoundTripfails locally withlisten unix /tmp/…: bind: A socket operation encountered a dead network— itbinds an AF_UNIX socket at a
/tmppath, which Git-Bash on Windows can't do.It's unrelated to this change (which only touches
ProcessTransport/AutoTransport) and passes on Linux CI.Operator note
This makes the failure legible; it does not install the optimizer. To actually
use the CVXPY optimizer, start the sidecar (
docker compose up -d ftw-optimizer, or Update Center → Optimizer). Core stays on the Go planneruntil it is healthy.
🤖 Generated with Claude Code