Skip to content

feat(elb): DescribeAccountLimits answers, with seedable limits (#885) - #899

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/elb-describe-account-limits
Sep 15, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/elb-describe-account-limits

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

ELBPlugin.HandleRequest's action switch had no DescribeAccountLimits arm, so the call fell to unknownActionError — while substrate's own authorization data already carried elasticloadbalancing:DescribeAccountLimits with an empty resource list (emulator/authz_reference_gen.go:1424, verified against the tree). A caller could be authorized for an action substrate then refused to perform. It was also the one shared action name of nine that routed nowhere, correcting #844's claim that all nine reach v2.

Closes #885.

What AWS publishes, per generation

All four API-reference pages fetched successfully; none returned an empty body.

Classic (elasticloadbalancing-2012-06-01) v2 (elasticloadbalancingv2-2015-12-01)
Marker String, not required, "The marker for the next set of results. (You received this marker from a previous call.)" identical wording
PageSize Integer, "Minimum value of 1. Maximum value of 400.", not required identical
Limits.member.N Array of Limit Array of Limit
NextMarker "If there are no additional results, the string is empty." "If there are additional results, this is the marker for the next set of results. Otherwise, this is null."
Errors Common Errors only — no operation-specific error same
Limit.Name enumerates exactly three: classic-listeners, classic-load-balancers, classic-registered-instances enumerates none — "The name of the limit." plus links to three quota user guides
Limit.Max String String

Sources: API_DescribeAccountLimits (v2), API_Limit (v2), API_DescribeAccountLimits (classic), API_Limit (classic).

One handler, v2 shapes, per the issue's note that dispatch generation follows #844. Classic's three names are therefore deliberately absent.

Provenance

This splits three ways and the split is the substance, not a footnote.

From the API model (authoritative): the response shape, Max as a String rather than the integer it looks like, NextMarker's two different documented semantics, PageSize 1–400, and the fact that the Errors section is Common Errors only.

From an AWS-published example, not the model: the 23 v2 limit names. v2's API_Limit enumerates none of them. The three quota user guides it points at were fetched and publish human-readable quota names ("Application Load Balancers per Region"), not the API's Limit.Name tokens — so the user guides do not carry the names either. The tokens were sourced from the example output on the AWS CLI v2 reference page for the operation, the only AWS page found that renders them at all. That page is an illustrative example, and both the source comment and docs/services.md label it as such rather than presenting it as the published API model.

From the quota user guides: the values, since a guide is AWS's normative statement of a default and the CLI example is an illustration AWS does not keep in step with it. ALB, NLB, GWLB. Every entry cites its guide row on its own line in emulator/elb_account_limits.go. Two divergences are recorded rather than hidden:

  • condition-wildcards-per-alb-rule — the ALB guide says 6, the CLI example says 5. The guide wins.
  • target-groups-per-action-on-network-load-balancer — the CLI example says 1; the NLB guide's nearest row is "Target groups per listener rule action" at 5, and whether that row is this token could not be established, so the example's 1 stands and the line says why.

Could not be sourced authoritatively: target-id-registrations-per-application-load-balancer appears in no quota user guide at all; it keeps the CLI example's 1000 and the line says so. That is the one value in the set with no normative source.

Seeding, and the fact that nothing enforces these numbers

Substrate enforces no ELB quota anywhere — no operation counts a load balancer, target group, listener or rule against one, and none is planned to. A bare constant would therefore be a number that does not come from where it appears to, which is the defect class the previous release was spent removing. Per the maintainer's settled decision (option 2), the limits are reported and seedable, with AWS's published defaults as the default seed value:

curl -X POST http://localhost:4566/v1/elb/account-limits \
  -d '{"name":"application-load-balancers","max":"1"}'
curl -X POST http://localhost:4566/v1/elb/account-limits -d '{"name":"*","max":"0"}'
curl -X DELETE 'http://localhost:4566/v1/elb/account-limits?name=application-load-balancers'
curl -X DELETE http://localhost:4566/v1/elb/account-limits

Namespace constant, key builder, resolveAccountLimitMax trying the specific key then "*", and the two control handlers — the ec2FleetShortfall shape (emulator/ec2_fleet_control.go:14-46, verified), registered beside the existing routes in emulator/server.go. max is a string in the seed too, so the seed and the wire stay in the same units as the published member type. A seed with no max is refused rather than stored, since an empty Max resolves to "no seed applies" and would silently do nothing.

docs/services.md states explicitly, in the hand-written region and citing #885 rather than any version: nothing in substrate enforces the number this operation reports, seeded or defaulted. That sentence is what makes choosing option 2 honest rather than merely plausible.

PageSize, and a finding: substrate's paginators disagree

The acceptance criteria say to handle an out-of-range PageSize the way substrate's other ELB paginators handle theirs. ELBv2 has no other paginator — there is no Marker/PageSize handling anywhere in emulator/elb_plugin.go, so there was no ELB precedent to match. Going wider, the tree's paginators do diverge from each other:

  • RDS's and ElastiCache's MaxRecords and CloudWatch's take any positive integer, quietly substitute their default for anything else, and enforce no maximum.
  • EC2's DescribeTags goes the other way: a MaxResults outside 5–1000 is refused with InvalidParameterValue, "not clamped: a caller who asked for 2000 asked for something the operation cannot do" (docs/services.md).

Reported rather than resolved by inventing a third behaviour. This handler follows the first, which is the Query-protocol Marker family it actually belongs to, and the decider is documentary: DescribeAccountLimits publishes no operation-specific error on either generation's page, so refusing would mean inventing a code AWS does not publish for it — a thing EC2's DescribeTags did not have to do. Because the default page size is the documented maximum (400), a PageSize above 400 is answered indistinguishably from a clamp, and an unparameterized call returns the whole set in one page.

Marker is a decimal offset into a fixed, name-ordered set, so a paged walk returns each limit exactly once. An unparseable Marker restarts the walk, an offset past the end answers an empty last page — as RDS's and ElastiCache's cursors do, neither being an error the operation publishes a code for.

NextMarker is absent when exhausted, following v2's documented null rather than classic's documented empty element. The difference is recorded in the source against #844.

Authorization

No authorization-reference change: the action was already present, and make authz-reference-check passes untouched. Worth noting for the reviewer, since the task description expected a p.authorize(...) line — no ELB handler has one. Every ELB request is decided centrally by AuthController.CheckAccess at emulator/server.go:810, before dispatch, so matching the sibling handlers means adding nothing. That central check is also precisely why the gap existed: authorization passed and the switch then refused.

Tests

emulator/elb_account_limits_test.go, package emulator_test, all through the house newELBTestServer(t) helper (a real httptest server over emulator.NewServer, which is what every other ELB test uses and which registers the control-plane routes) with real wire calls — no putTest* direct state writes, no network, no wall-clock dependence.

  • Raw-XML assertions on the wrapper name (<DescribeAccountLimitsResponse xmlns=…>, <DescribeAccountLimitsResult>) and on the whole member — <member><Max>50</Max><Name>application-load-balancers</Name></member> — because botocore looks the wrapper up and raises KeyError on a mismatch, and a decoded struct can neither distinguish an absent member from an empty one nor reject an invented third member. NextMarker's absence is asserted on the bytes for the same reason.
  • Seeds a low limit and reads it back over the wire, plus the "*" wildcard, specific-beats-wildcard resolution, an omitted name resolving to the wildcard, both DELETE forms, and the endpoint's refusals.
  • Marker round-trip walking the set at PageSize=5 and asserting each of the 23 limits is returned exactly once, in order.
  • Table-driven PageSize (absent, 1, 2, 23, 400, 0, -5, 401, non-numeric) and Marker edges (unparseable, negative, past the end, exactly the end).

No pre-existing test asserted the old refusal, so nothing had to be relaxed.

A second commit covers the store-failure paths, following sqsAlwaysFailState. A store failure during the seed lookup propagates rather than being answered as a successful set of defaults: silently falling back would be the worse failure, since a harness that seeded "every limit is 0" to drive its at-quota branch would be handed 50, its assertion would pass vacuously, and the seed would look armed when it was not — the failure mode #413 filed against the SQS consistency seed. The fault double is scoped to the elb-limits-ctrl namespace so it cannot break the server's own per-request bookkeeping and make a request fail for the wrong reason, and it separates a store error from a successful read of bytes that are not a seed (state written by an older substrate, or by hand), which is a JSON error and not the same signal. The sweep case seeds over the wire with only Delete faulted, so no field is mutated once the server is serving — that would be a race the detector would flag. The one branch left uncovered is the json.Marshal guard on a struct of two strings, which cannot fail; it is kept because ec2_fleet_control.go:104-108 keeps the identical guard, and dropping it would mean discarding an error.

Verification

Run from the repo root; all clean.

$ gofmt -l . && go build ./... && go vet ./...
(no output)

$ golangci-lint run ./...
0 issues.

$ make test          # redirected to a file, exit code checked separately
EXIT=0
grep -c FAIL → 0
ok  github.com/scttfrdmn/substrate/emulator                  19.125s
ok  github.com/scttfrdmn/substrate/cmd/substrate              1.797s
ok  github.com/scttfrdmn/substrate/cmd/gen-service-reference  1.471s
ok  github.com/scttfrdmn/substrate/cmd/gen-authz-reference    1.351s

$ make docs-reference
docs/services.md already up to date (67 plugins)

$ make docs-reference-check docs-versions authz-reference-check
(no output — all pass)

npm --prefix docs run build was skipped: docs/node_modules is git-ignored, so it exits 127 in a fresh worktree. CI covers the docs build.

@scttfrdmn
scttfrdmn force-pushed the feat/elb-describe-account-limits branch from e8a1fd9 to b3b8dba Compare September 15, 2026 22:25
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/elb_account_limits.go 97.67% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

The action was authorizable but not dispatched: substrate's generated
authorization reference already carried
`elasticloadbalancing:DescribeAccountLimits` with an empty resource list, while
`ELBPlugin.HandleRequest`'s switch had no arm for it — so a caller could be
granted a permission substrate then answered `InvalidAction` for. It was also
the one shared action name of nine that routed nowhere, correcting #844.

Substrate enforces no ELB quota anywhere, so a bare constant here would be a
number that does not come from where it appears to. The limits are instead
seedable via POST/DELETE /v1/elb/account-limits, keyed by limit name or the "*"
wildcard with specific-then-wildcard resolution, following the
`ec2FleetShortfall` shape. AWS's published defaults become the default seed
value, so the constant becomes the thing a caller polls the operation for.
`docs/services.md` states explicitly that nothing in substrate enforces the
number reported, seeded or defaulted.

Provenance is recorded rather than smoothed over. The shape is the API model's,
with `Max` a String per `API_Limit`. The names are not: classic's 2012-06-01
`API_Limit` enumerates exactly three, v2's enumerates none, so the 23 v2 names
are taken from the AWS CLI v2 reference's example output for the operation and
labelled an example rather than the model. Their values come from the three
quota user guides, which win where they disagree with the example.

`NextMarker` is absent when exhausted, following v2's documented null rather
than classic's documented empty string; the difference is recorded for #844.
`PageSize` outside the documented 1–400 falls back to the default, matching the
Query-protocol paginators (RDS, ElastiCache, CloudWatch) rather than EC2
`DescribeTags`'s refusal, because the operation publishes no
operation-specific error to refuse with.

Closes #885.
A store failure during the seed lookup must propagate rather than be
answered as a successful set of defaults. Falling back silently is the
worse failure: a harness that seeded "every limit is 0" to drive its
at-quota branch would be handed 50, its assertion would pass vacuously,
and the seed would look armed when it was not — the failure mode #413
filed against the SQS consistency seed.

Adds elbLimitFaultState, following sqsAlwaysFailState, scoped to the
elb-limits-ctrl namespace so a fault cannot break the server's own
per-request bookkeeping and make the request fail for the wrong reason.
It also separates a store error from a successful read of bytes that are
not a seed (state written by an older substrate, or by hand), which
decodes to a JSON error and is not the same signal.

The sweep case seeds over the wire with only Delete faulted, so no field
is mutated after the server is serving — that would be a race the
detector would flag.
@scttfrdmn
scttfrdmn force-pushed the feat/elb-describe-account-limits branch from 4509319 to 82af3fa Compare September 15, 2026 22:43
@scttfrdmn
scttfrdmn merged commit 1abf823 into main Sep 15, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/elb-describe-account-limits branch September 15, 2026 22:49
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.

elb: DescribeAccountLimits is authorizable but not dispatched, so it answers unknownActionError

1 participant