Skip to content

FP-6: bounded S3 queue that never blocks polling; string policy for tenant/network strings - #308

Open
randomizedcoder wants to merge 6 commits into
mainfrom
sec/fp6-s3-queue-strpolicy
Open

randomizedcoder wants to merge 6 commits into
mainfrom
sec/fp6-s3-queue-strpolicy

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

FP-6 of the security-hardening plan (C3, C4): a tenant or an S3 outage can cost data, not the collector.

S3 queue

  • Send never blocks: it used to stall the poller mid-poll once 16 envelopes waited on S3.
  • envelopeQueue (pkg/xtcp/s3queue.go) drops the oldest past -s3QueueDepth (default 16, max 4096) or -s3MaxBufferedBytes (default 64 MiB, 0 = no byte bound), always keeping the newest.
  • New metrics xtcp_s3_dropped_total{reason}, xtcp_s3_dropped_bytes_total{reason}, xtcp_s3_buffered_bytes{stage}; queueFull now counts drops.
  • XtcpConfig fields 116/117, env S3_QUEUE_DEPTH / S3_MAX_BUFFERED_BYTES; startup-only (preserveCaps keeps them across Set).
  • Memory budget documented next to the GOMEMLIMIT guidance (≈ 190 MiB with defaults).

String policy

  • New pkg/strpolicy.Clean: cut at a UTF-8 boundary (256 bytes, 16 for ifnames and congestion names), invalid UTF-8 and C0/DEL/C1 become U+FFFD; printable ASCII returns without allocating.
  • Applied once where each value enters: docker name/image, NIC and LLDP strings, tenant ifnames (localnet), ASN network owner, netns names, congestion name.

Tests / evidence

  • Table-driven TestClean, FuzzClean, TestEnvelopeQueue (+ concurrent, -race), TestS3ParquetDest_queueBounds, reworked corner_queueFull, one test per call site, flag/env/validation/preserveCaps rows.
  • BenchmarkDeserializeCongInfoXTCP vs main (10 interleaved): 21.0 → 23.3 ns, allocs unchanged; BenchmarkS3Send 52 ns vs 118 ns for the old channel send.
  • New microVM Check 14c (S3PARQUET_OUTAGE): Garage stopped mid-run → polls continue, 22 drops, RSS +5 MB, upload resumes after restart. microvm-x86_64-lifecycle-s3parquet: all checks pass.
  • Fixes TestS3ParquetDest_timeFlush, which failed under -race on main (fixed 30 ms sleep).
  • nix checks green: lint-baseline, nix-fmt, gofmt, go-vet, golangci (3 tiers), no-write-encoders, flavor-tags, tcp-controller-unit.

Follow-ups (plan doc TODOs)

  • protovalidate max_len for operator strings (label, tag, location, hostname).
  • Disk spill for the S3 queue during long outages.

🤖 Generated with Claude Code

randomizedcoder and others added 6 commits November 14, 2026 07:33
pkg/strpolicy.Clean cuts a string at a UTF-8 boundary (256 bytes, 16 for
interface and congestion names) and replaces invalid UTF-8, C0, DEL and
C1 with U+FFFD; printable ASCII that fits returns without allocating.

Applied once per entity: dockermeta inspect (name, image), the uplink
stamp (NIC strings, LLDP fields), localnet ifnames, the ipasn owner,
netns names, and the congestion decode, which folds the check into its
NUL scan (+3 ns per socket, allocs unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Send used to block the poller once 16 envelopes waited on a slow or
unreachable S3. envelopeQueue drops the oldest past -s3QueueDepth
(default 16, max 4096) or -s3MaxBufferedBytes (default 64 MiB, 0 = no
byte bound), always keeping the newest. New xtcp_s3_dropped_total,
xtcp_s3_dropped_bytes_total and xtcp_s3_buffered_bytes{stage};
queueFull now counts drops. XtcpConfig fields 116/117, env
S3_QUEUE_DEPTH / S3_MAX_BUFFERED_BYTES, kept across Set by preserveCaps.

Docs: metrics, memory budget, plan FP-6 done-as, CHANGELOG. Also polls
in TestS3ParquetDest_timeFlush, which failed under -race on a fixed
30 ms sleep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check 14c: with -s3QueueDepth 2, a Garage outage must keep polls at
cadence, raise xtcp_s3_dropped_total, keep RSS growth under 128 MiB,
and land a new object after Garage restarts (S3PARQUET_OUTAGE).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…3 queue env/print in helpers (funlen)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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