Repository navigation
feat: ✨ Start the hostegress proxy from env - #2132
evaline-ju wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
b42f117 to
04f6c15
Compare
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The env-only start for the hostegress build works as described, and I found nothing blocking. I built the hostegress profile and ran it with env -i, so no PATH or HOME. It refuses to start without MOCA_EGRESS_ALLOW (an empty or comma-only value counts as missing), without MOCA_EGRESS_CONTROL_UIDS, or with a bare-host allow entry. With a valid environment, every listener binds a kernel-picked 127.0.0.1 port, the VM control socket is bound before READY=1, off-list destinations get 403 destination_denied, private destinations are refused by the egress guard, and SIGTERM with an idle client connection and an open control-socket connection stopped in about 70 ms with drain=false. With no MOCA_EGRESS_CONTROL_SOCK the old --config is required error is unchanged, and the non-moca builds never offer the built-in config. The Load to Parse split keeps behaviour the same: no decoder or field changes.
I left one suggestion inline: in built-in mode, the moca variables this build ignores are skipped without any log line.
Author: evaline-ju (CONTRIBUTOR association, admin repo permission — maintainer)
Areas reviewed: Go (cmd/cortex, core/bootstrap, core/config), embedded YAML config, docs (cmd/README.md, vmcontrol CLAUDE.md)
Agent/IDE config (.claude/.vscode): none (core/listener/vmcontrol/CLAUDE.md is a docs-only change; I read it and it is harmless)
Commits: 1 commit, all signed-off: yes
CI status: everything that has finished passes; several Go CI jobs, including Go CI (authbridge cortex), which runs the hostegress profile tests, were still queued when I posted. Locally, go test -tags include_driver_moca,include_plugin_staticinject ./... and the local-profile ./... in cmd/cortex pass, and so do core/bootstrap and core/config with -race.
| if _, err := interfaceAddrs(); err != nil { | ||
| return nil, true, fmt.Errorf("the egress guard cannot read this host's addresses: %w", err) | ||
| } | ||
| return hostEgressConfig, true, nil |
There was a problem hiding this comment.
suggestion: The docs say this mode reads none of the moca harness's other variables (MOCA_EGRESS_RESOLVER, MOCA_EGRESS_PERMIT_CIDRS, the timeouts). But a moca unit that sets them and swaps in this binary gets no sign that they were ignored. For example, a permitted private upstream would start returning destination_private, or the system resolver would be used in place of the configured one, and nothing in the log would say why. A single slog.Warn here naming each of those variables that is set (and ignored) would make the swap much easier to debug. It doesn't block merging.
Summary
A MOCA host can now run Cortex as its egress proxy without a config file. Today the hostegress build exits at startup unless it's given one, so it can't stand in for moca's egress proxy. Now it starts the way moca's proxy does, from the environment alone. It runs a built-in, loopback-only config with the egress guard on. It refuses to start without the control-socket uids and an egress allowlist, so it never runs with open egress. On a stop it exits cleanly at once, as moca's proxy does.
Cortex can also run as a systemd Type=notify service. It tells systemd it's ready once it serves, so services ordered after it, such as moca's VM worker, start only when the proxy can take their connections.
Assisted-By: Claude (Anthropic AI)
Related issue(s)
Part of #2085 (part 2 after #2117)
Summary by CodeRabbit