Skip to content

✨ feat(v1.5): config-defaults reflection + default upstream request_timeout - #120

Merged
scttbnsn merged 2 commits into
dev/v1.5from
feat/v1.5-spine-1
Jul 4, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.5from
feat/v1.5-spine-1

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

First two items of the v1.5 spine, built per the specs from the prep workflow and sequenced consolidation-first.

🔄 Config Viper-default registration by reflection. load.go's ~200-line hand-written v.SetDefault block is replaced with a reflection walker driven by Defaults() + mapstructure tags. Closes the silently-dead-env-var bug class that has shipped three times — and the parity audit found two more pre-existing instances (8 keys total: the container_create/service image_trust mode/keys fields and the allowed_device_cgroup_rules/allowed_device_requests fields had no registration, so their SOCKGUARD_* env vars did nothing). Those env vars are now live; default values are bit-for-bit unchanged. New completeness tests: Load('') deep-equals Defaults(), an exhaustive SOCKGUARD_ env-override sweep, and a fail-on-missing-mapstructure-tag check. The intentionally env-inaccessible pointer blocks (clients.global_concurrency, profile limits) stay inaccessible.

✨ upstream.request_timeout defaults to 60s (was unlimited). The v1.2.0 opt-in deadline that turns a hung upstream body into a fast 504 is now on by default. Migration: set request_timeout: "off" to restore unlimited (legacy "" still works in YAML; use "off" via env var since an empty env var reads as unset). GET/PUT /containers/{id}/archive added to the long-lived exemption list in the same change so a large docker cp doesn't regress under the new ceiling. Effective value logged on the startup line. All 16 presets validate unchanged.

Both worktree-built, diff-reviewed, then integrated and re-gated on the combined branch: go build/test (all packages), golangci-lint 0 issues, full pre-push chain green. CHANGELOG carries both entries under [Unreleased] with the migration story.

Remaining spine per the sequencing plan: cpu-hard-cap → exec-env allowlist → namespace-sharing gate (last two collide with cpu-cap on ContainerCreateRequestBodyConfig, so they serialize).

scttbnsn added 2 commits July 3, 2026 20:35
- setLoadDefaults's ~199-line hand-written v.SetDefault block is replaced
  with registerDefaults, a small recursive reflect walker driven by
  Config's mapstructure tags, so a new config field can never again
  silently miss its Viper registration (and with it its SOCKGUARD_* env
  var override) — this exact bug class has already shipped three times
  (allow_sysctls, four service-hardening rails, the SELinux/
  deny_unconfined_system_paths trio)
- auditing the walker's output against the old hand-written list surfaced
  two more, previously-unknown instances of the same gap, now closed as a
  side effect: request_body.{container_create,service}.image_trust.
  {mode,allowed_signing_keys,allowed_keyless} and request_body.
  container_create.{allowed_device_cgroup_rules,allowed_device_requests}
  had no v.SetDefault registration either
- adds load_defaults_completeness_test.go: TestLoadDefaultsCoversEvery
  MapstructureLeaf (Load("") deep-equals Defaults(), field by field),
  TestLoadDefaultsEnvOverrideSweep (generalizes the one-off regression
  tests in load_env_defaults_test.go into an exhaustive SOCKGUARD_<PATH>
  sweep), and TestConfigFieldsHaveMapstructureTags (fails CI if any
  Config field, at any depth, lacks a mapstructure tag)
- clients.global_concurrency and clients.profiles[].limits.rate/
  concurrency stay deliberately non-env-configurable: nil pointer leaves
  are skipped rather than registered, and Profiles is a slice leaf the
  walker never recurses into
- no YAML key, env var, CLI flag, or default value changes otherwise;
  documents the new registration path in CONTRIBUTING.md and README.md
- config.Defaults().Upstream.RequestTimeout now "60s" (was "" / unlimited);
  a wedged daemon that hangs the response body is now caught by default
  instead of pinning a request indefinitely.
- Add the "off" sentinel (exact-lowercase) to explicitly disable the
  deadline; legacy empty string "" still works for backward compat.
  Centralized in UpstreamConfig.RequestTimeoutDisabled(), the single
  source of truth used by both validate.go and cmd/serve.go.
- Add GET/PUT /containers/{id}/archive (docker cp, both directions) to
  proxy/timeout.go's long-lived exemption list, closing the large-copy
  regression the new default would otherwise introduce.
- Log the effective value ("off" or the duration) as
  upstream_request_timeout on the "sockguard started" INFO line.
- CHANGELOG: migration note under a new [Unreleased] heading — who's
  affected, and how to opt back out with request_timeout: "off" (env var
  callers must use "off", not an empty string, per Viper's empty-env
  semantics).
- Update README feature table + roadmap, and configuration.mdx /
  multi-host.mdx docs to match the new default and "off" opt-out.
@vercel

vercel Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sockguard-website Ready Ready Preview, Comment Jul 4, 2026 12:44am

@scttbnsn
scttbnsn merged commit 1e620e6 into dev/v1.5 Jul 4, 2026
42 of 43 checks passed
@scttbnsn
scttbnsn deleted the feat/v1.5-spine-1 branch July 4, 2026 00:48

This branch was successfully deployed

1 active deployment
Preview — 03117e16 Deployed Jul 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant