Skip to content

fix(egress-proxy): publish activity after quiet at once; status states its bounds (#1528) - #1548

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1528-egress-activity-edge
Nov 6, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1528-egress-activity-edge

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1528

spawn egress-proxy status read spawn:egress-proxy-last-activity as if it were exact. spored rewrites that tag at most every 10 minutes (egressproxy.ActivityPublisher), so it can trail the proxy's real last activity, and the countdown erred toward "sooner". In the live case, status at 23:42 said "expires in 8m" (about 23:51), and spored terminated the proxy at 23:55:24, 15 minutes after its last traffic at 23:39:58. Expiry itself was always correct. This PR changes both halves.

(a) Publisher rule (changes spored)

pkg/egressproxy/activitytag.go ActivityPublisher.Due:

  • Write only on change (unchanged): a value equal to the last one written is never due.
  • After quiet, at once (new): if the published value is older than the window (ActivityPublishEvery, 10m), and the previous attempt was the write that published it, a new value is due on the tick that sees it, even within 10 minutes of the last attempt.
  • Otherwise throttled (unchanged): at most once per window since the last attempt.
  • Failed writes (unchanged pace): a refused CreateTags counts as an attempt and turns the after-quiet exemption off until a write succeeds. A refusal is therefore retried at the throttle's pace, never on every tick.

What the rule guarantees, checked by a 20,000-tick randomized property test:

  1. A tag at least the window old equals the proxy's real last activity, to within spored's one-minute tick. That is the regime in which an idle expiry is near.
  2. Writes stay rare: never three in one window, and one per window in steady traffic. An after-quiet write can carry a value that is already minutes old. That value then ages past the window early, so two writes can land in one window. This is inherent to guarantee 1.

Honest limit: on the issue's own timeline, spored's first write (23:39:46) carried the launch time 23:36:25. The tag now updates at 23:46:46, when that value turns 10 minutes old, rather than at 23:49:46. Before then it still trails by up to its own age, and the status wording in (b) covers that window.

Rollout: this is a spored change. It reaches a proxy only after a release, when a proxy is launched, or upgraded with spawn egress-proxy upgrade, on that release. Proxies that are already running keep the old rule, and the (b) wording is correct for them as well.

(b) status states its bounds

Text, before:

    activity  idle for 3h (last 2026-11-03T09:00:00Z), expires in 2d21h (idle period 3d)

After:

    activity  last at or after 2026-11-03T09:00:00Z (tag 3h old; spored updates it at most every 10m in steady use)
    expires   no earlier than 2026-11-06T09:00:00Z, in 2d21h (idle period 3d)

Other expiry lines:

  • deadline first: expires at its deadline, in 3m. The deadline is exact.
  • deadline passed: expires at its deadline, passed 2m ago
  • idle expiry passed by the tag: expires no earlier than <t> (idle period 15m; by the tag it passed 2m ago, but spored ends it on its own clock, from its real last activity)

--help (and docs-gen/egress-proxy.md) gains a paragraph on this.

JSON: every existing key is kept, and the key-set test pins two new ones:

  • activity.expires_at_is_lower_bound: true when expires_at is the idle expiry, false when it is the deadline or unknown.
  • activity.publish_interval_seconds: 600, or null when activity is unknown.

Tests

  • pkg/egressproxy/activitytag_test.go:
    • first activity after quiet: the issue's timeline replayed tick by tick, due at 23:46:46 and not before, followed by a 40-minute burst whose writes land at exactly 23:50:46 00:00:46 00:10:46 00:20:46
    • no change, no write: up to 72h
    • a failed after-quiet write is retried at the throttle's pace
    • the randomized property test
    • the existing throttle tests (one bound adjusted to the new rule)
  • cmd/egress_proxy_test.go: rendering for idle expiry, deadline first, idle expiry passed and deadline passed, with the issue's 23:42 numbers. Status text and JSON key-set pins are updated.

Revert gate

  • Publisher reverted to origin/main, tests kept:
    --- FAIL: TestActivityPublisherPublishesTheFirstActivityAfterQuietAtOnce
        activitytag_test.go:99: Due(23:39:58, 23:46:46) not due
    --- FAIL: TestActivityPublisherProperties
        activitytag_test.go:189: at 2026-11-03 00:29:00 the tag 2026-11-03T00:18:06Z is 10m54s old but the real last activity is 2026-11-03T00:27:02Z
    
  • Status rendering reverted to the old line, tests kept:
    egress_proxy_test.go:166: status lacks "activity  last at or after 2026-11-03T09:00:00Z (tag 3h old; spored updates it at most every 10m in steady use)"
    egress_proxy_test.go:166: status lacks "expires   no earlier than 2026-11-06T09:00:00Z, in 2d21h (idle period 3d)"
    

Checks (hermetic: AWS env stripped)

  • make check: passes
  • root go test ./...: passes
  • lambda/ttl-reaper go test ./...: passes
  • make test-e2e-tier0: passes
  • semgrep scan --config=auto --error on the changed files: clean. The property test uses a fixed-seed LCG, not math/rand.
  • make gen-docs: docs-gen/egress-proxy.md regenerated, and check-docs passes
  • make api-snapshot: unchanged, because the new fields are unexported

No Lambda change.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/egress_proxy.go 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

scttfrdmn and others added 3 commits November 6, 2026 10:02
…s its bounds (#1528)

spored's ActivityPublisher now writes the first new activity immediately
once the published value is older than the throttle window, and throttles
only the writes that follow. spawn egress-proxy status reports the tag as a
lower bound (last activity at or after, expires no earlier than) and shows
the tag's age; JSON gains expires_at_is_lower_bound and
publish_interval_seconds.

Co-Authored-By: Claude <[email protected]>
@scttfrdmn
scttfrdmn force-pushed the fix/1528-egress-activity-edge branch from d8a1157 to 0ca9382 Compare November 6, 2026 18:02
@scttfrdmn
scttfrdmn merged commit 7e1f76a into main Nov 6, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1528-egress-activity-edge branch November 6, 2026 18:19
@scttfrdmn scttfrdmn mentioned this pull request Nov 6, 2026
4 tasks
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.

egress-proxy status understates remaining idle time by up to 10m (throttled activity tag)

1 participant