Repository navigation
fix(#1000): the tagging API enforces four services' tag quotas, and two shipped claims are corrected - #1078
Merged
Conversation
…wo shipped claims are corrected TagResources was the one way in substrate to put a resource over its own service's published per-resource tag quota. EC2, ELBv2, IAM and Kinesis each enforce one at fifty on their own tagging operations, and all four are reachable through the tagging API's resolver, whose shared merge consulted none of them — so a caller could tag a resource into a state substrate's own reference says cannot exist, through substrate's own API. API_TagResources states the rule itself. The refusal carries the owning service's own code rather than one of FailureInfo's two enumerated ones, on that member's own prose admitting "any valid error code returned by the AWS service that hosts the resource". The four codes are not unified: IAM answers 409 where the others answer 400, and EC2 and ELBv2 exclude aws:-prefixed keys from the count on their own published statement where IAM and Kinesis publish nothing of the kind. Neither CloudFormation writer enforces it, for two different reasons: the stamp writes only aws: keys, which two of the four exclude, and stack-tag propagation is filed as #1077 because nothing published says what CloudFormation does when propagation would exceed a resource's quota. Corrects two claims #965 shipped: Kinesis was the fourth quota, not the first, and the shared merge covers 23 arms, not sixteen. Closes #1000.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1000.
TagResourceswas the one way in substrate to put a resource over its own service's publishedper-resource tag quota. Four services enforce one on their own tagging operations — EC2, ELBv2, IAM
and Kinesis, all four at fifty — and all four are reachable through
TaggingPlugin.resolveARN, whoseshared merge consulted none of them. So a caller could tag a resource past its quota through one API and
then find the owning service's own operation refusing every further add: a resource in a state
substrate's own reference says cannot exist, reached through substrate's own API.
API_TagResourcesstates the rule itself — "Each resource can have up to 50 tags" — so enforcing ithere needed no borrowing from the four services by analogy, which is the #671 rule.
The issue named one service; it is four
Two of #1000's premises are false, and both were shipped in substrate's own record by #965:
docs/services.md(Kinesis) andCHANGELOG.md(v0.118.0) both said Kinesis was substrate's firstper-resource tag quota for any service. EC2 (
ec2_tags.go), ELBv2 (elb_tags.go) and IAM(
iam_tag_validation.go) each had one already, and all three have a tagging-API arm. Kinesis was thefourth, not the first.
Both statements are corrected in place rather than quietly superseded — the CHANGELOG paragraph keeps its
original text with a bracketed correction naming this issue, since the entry is a historical record of
what shipped, and the
docs/services.mdparagraph is rewritten, since it describes current behaviour.Three readings this makes
1. The refusal carries the owning service's own code, not one of
FailureInfo's two enumerated ones.That member publishes
Valid Values: InternalServiceException | InvalidParameterExceptionand, in thesame member's prose, that it "can also include any valid error code returned by the AWS service that
hosts the resource that the ARN key represents" — offering
AccessDeniedException, which is in neitherenumerated value, as its example. The prose is the half that fits here: neither enumerated code says
this resource is full, and
InternalServiceExceptiontells the caller it is "safe to retry", which isthe same wrong answer #939 moved the not-found case off. Every other failure still reports an enumerated
code, because for those the enumeration loses nothing.
2. The quota is enforced on the RGTA path and on neither CloudFormation path, and the two deployer
sites are skipped for two different reasons:
cfnStampResourceTagswrites onlyaws:cloudformation:*keys, and EC2 and ELBv2 state outright that"[t]ags with the aws: prefix do not count against your tags per resource limit". Counting the stamp
would refuse a deploy on a rule AWS states about something else.
cfnPropagateRecordStackTagswrites the caller's own stack tags, which a quota could legitimatelyrefuse. It is skipped because nothing published says what CloudFormation does when propagation would
exceed a resource's quota — CloudFormation publishes a 50-tag limit on the stack, and the
resource-side interaction is in neither its quotas page nor any operation's Errors section. Refusing
there would also turn a tag overflow into a failed deploy, which is a larger decision than this issue
asks for. Filed as CloudFormation stack-tag propagation can push a resource past its service's tag quota, and nothing published says what AWS does there #1077 rather than guessed.
All three writers go through
mergeResourceTags, which is the point of that function, so the differenceis a
tagQuotaModeparameter rather than a second merge.3. Each service's own checker is called rather than a shared count, because the four disagree in ways
a shared count would have to flatten:
aws:keysTagLimitExceededTooManyTagsLimitExceededLimitExceededExceptionThe reserved-key column is what each service publishes, not a choice — no IAM or Kinesis page says
anything like EC2's and ELB's sentence — so it is recorded rather than unified. It is unobservable
through this API either way, since a reserved key is refused upstream and only the stamp path writes one.
Shape
emulator/tagging_tag_quota.go:tagQuotaMode, the*taggingQuotaErrorcarrier, andtaggingCheckTagQuotawith one arm per service. Each arm does a minimal decode of the storedrecord's tag member alone rather than the arm's own concrete type, so this file needs no knowledge of
which of a namespace's several record shapes a key names; nothing is written back, so it cannot
truncate anything. An undecodable record is passed rather than refused, because the merge arm below
is about to fail on the same bytes with a message naming the actual problem.
mergeResourceTagsimmediately after theraw == nilcheck and before theswitch, so a refused request writes nothing — the rule kinesis: AddTagsToStream enforces no per-stream tag quota, and AWS's reference publishes two different limits #965 established for the service-side quotas
this reuses — and so a service that gains a quota later needs only a case in the checker.
tagMergeFailuregains a first arm thaterrors.As-matches the carrier and renders its code, messageand status into the
FailedResourcesMapentry. The per-resource map already existed.iamTagLimitErrornow derives from a newiamTagLimitAWSError, so IAM's code, message and 409 live inone place across the
*AWSResponseand*AWSErrorshapes;iamCheckTagLimitAWSErroris the secondshape of the same threshold.
MergeResourceTagsForTestis added because both deployer sites passskipTagQuotaand no template inthe tree brings a resource near a quota, so nothing over the wire distinguishes a scoped gate from an
absent one.
Verification
Six new tests in
emulator/tagging_tag_quota_test.go, every one of which writes throughTagResourcesand reads back through the owning service's own call — the #863 both-directions proof,and the only assertion that separates a quota honoured from a code answered beside a completed write:
reports fifty;
len(existing)+len(incoming)count gets wrong);UntagResourcesis never refused, and the slot it frees is usable;TagQueueeither andinventing one here alone would make the two APIs disagree in the opposite direction;
that counts
aws:keys — so it is the case where the two modes give different answers, where on EC2and ELBv2 the test would pass against a gate that had no mode at all.
Short-circuiting
taggingCheckTagQuotatoreturn nilfails seven of them, including all four servicesubtests.
Full gate green:
gofmt/go build/go vet,golangci-lint run ./...(0 issues),go test -race ./...on both toolchains,
test/e2e,scripts/check-discarded-unmarshal.sh,scripts/check-doc-versions.sh,gen-service-reference -check,gen-authz-reference -check, and thedocs site build.