Repository navigation
Conversation
When a provider pod behind a public listener shut down, its clients lost about 48 seconds before another pod admitted them. Three things added up: - Shutdown closed the listener's UDP socket before the CONNECT-IP server, so the server had no socket to send CONNECTION_CLOSE on and clients learned of it only at their 30 second idle timeout. Listener.Stop now closes the server after the drain delay and only then the sockets. - Shutdown never retired the grants it held, so the authority kept each authorization until its sweep found it unrenewed. The service now calls Adapter.BeginShutdown before stopping the transports, and from then on each request retires its grant as the server's close ends it. Requests have left the adapter by the time Shutdown runs, so retiring there would find nothing. A grant stays live while a newer request of the connector on the same pod may hold it, since the authority renews a pod's authorization in place. - The authority then refused the connector for RetryWindow after the retirement. That hold exists so a retry of the issuing call finds the authorization, and such a retry is accepted only within RetryWindow of its issue. The authority now records the issue time and holds a retired authorization until the sooner of the two deadlines, so one retired long after issue is not held at all. The 10 second hold had also narrowed a race in reap: core can record an allocation after reap read the service with none, and the delete carried only a UID precondition. The delete is now conditioned on the resourceVersion read as well, so the service is kept for a later pass. Tests that used the time hold to stand in for core holding a pool now set status.allocations, which is what reap checks. Fixes: #1562
|
Both reviewers returned a merge verdict on this head. pr-conventions-reviewer: "VERDICT: merge. No reach or convention problems found. The diff is confined to internal/edge/masque, internal/edge/connectip and docs/edge, with nothing in a deploy path." It ran: gh pr view 1573; git diff base...head (full, plus -U0 comment scan); git log; git diff --stat; gh pr list --state open (no other open PR touches these files); go build ./internal/edge/... (passed); go vet ./internal/edge/masque/... ./internal/edge/connectip/... (passed). It did not run kustomize validation (no manifests), task ci or the unit suite. pr-adversary: "VERDICT: merge. No defect in the changed paths; unit suite passes under -race; retryDeadline bound matches the Authorize acceptance check." It ran: gh pr view; gh api issues/1562; gh pr checks; git diff base...head; go build ./internal/edge/...; go vet ./internal/edge/masque/...; go test -race -count=1 ./internal/edge/masque/ ./internal/edge/connectip/ ./internal/edge/masque/service/ ./internal/edge/masque/authority/ (all passed). No code changes were applied from review. Two decision items were resolved by the author. Acceptance criterion 3 of issue 1562 (a lab test that shuts down one of two listener backends) is an accepted gap, tracked in a follow-up issue. The envtests are confirmed to run in CI, which sets the envtest assets and fails rather than skips when they are missing; locally they failed against main and pass with the fix. One nit about timing in the listener Stop path needs no change. CI: every check on 7b46f25 completed with success or skipped. Auto-merge is enabled with the merge method, the only one the base branch ruleset allows. The ruleset requires one approving review including a code owner, dismisses stale reviews on push, and requires approval of the last push, so the PR waits for a human approval. |
Summary
When a MASQUE provider pod behind a public listener shut down, its clients lost about 48 seconds before a surviving pod took them over.
Shutdown closed the listener's socket before the server could send clients a close, never retired the grants it held, and the grant authority then refused the connector for 10 more seconds.
Now the server closes first, shutdown retires each open grant, and the authority holds a retired grant only while a retry of its issuing call could still arrive. The authority's delete of a released grant also now fails if core recorded an address after the authority read it, a race the old 10 second hold only narrowed.
Test plan
Not covered: shutting down one of two listener backends in the lab.
Fixes #1562