Files
floci/docs
Jackson Price d173d65eb4 fix(ec2): honor CopyImageTags on CopyImage (#7097)
* fix(ec2): tag an AMI with the tags RegisterImage is given

RegisterImage never read TagSpecification, so an AMI registered with
image tags came back from DescribeImages untagged: its tag filters
matched nothing and DescribeTags listed nothing for it. A tag
specification for another resource type was accepted as well, although
AWS fails that request.

RegisterImage now reads its image tag specifications and refuses any
other resource type with InvalidParameterValue. It checks the tags as
CreateTags does (no aws: prefix, the key and value lengths, at most 50
tags) before registering anything, so a refused request leaves no AMI
behind. The tags are stored before the AMI is, so DescribeImages never
lists it without them, and a key given twice keeps its last value, as
Floci's CreateTags keeps it.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): copy an AMI's tags when CopyImage sets CopyImageTags

CopyImage never read CopyImageTags, so a copy asked to carry its
source's tags came out untagged, and DescribeImages could not find it
by them.

With CopyImageTags=true the copy now gets the caller's tags on the
source, read in the source region, less the aws: system tags, which
AWS does not copy either. Without it, or with false, no tags are
copied, which is AWS's default. The source keeps its tags, and the
copy's are stored in the destination region only. The tags are read
under the source AMI's own id, so a catalog AMI's tags on that id are
copied too, while tags put on one of its aliases are not. Floci keeps
each account's tags apart, so another account's tags never reach the
copy.

CopyImage still neither checks nor applies TagSpecification, and the
docs now say so.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): stub the CopyImage overload the handler calls

Upstream's handler test for CopyImage tag specifications stubbed the
five-argument copyImage. On this branch the handler passes
CopyImageTags as well, so the stub never matched, the mock returned
null and the test failed with a NullPointerException. It now stubs the
six-argument call with CopyImageTags false, which is what a request
without it sends.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(ec2): leave RegisterImage tag specifications to upstream's handling

Upstream now reads RegisterImage's TagSpecification in the Query
handler, refuses other resource types and checks the tags before the
AMI is registered, so this branch's own path for the same thing is a
duplicate. The seven-argument registerImage overload and the tag code
in registerImageLocked are removed, and RegisterImage goes back to
upstream's code. CopyImage stores the tags it copies straight after it
registers the copy instead.

The branch's RegisterImage tests go too: upstream's
Ec2CreateTagSpecificationIntegrationTest and Ec2QueryHandlerTest cover
the same behaviour. What the branch adds is CopyImageTags alone.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): pin a TagSpecification tag over a copied tag of the same key

With CopyImageTags=true and an image TagSpecification on the same
request, the copy carries both sets. When both name the same key, the
TagSpecification value is the one the copy keeps, since the handler
applies the specification after the service copies the source's tags.
The docs row says so; this test holds it.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse a CopyImage over the tag limit before creating the copy

With CopyImageTags=true and an image TagSpecification, the copied and
the specified tags were each checked against the 50-tag limit on their
own. The service then created the AMI and its snapshots and stored the
copied tags, and only the handler's CreateTags of the specification saw
the combined set: past 50 it answered TagLimitExceeded while the copy
it had just made stayed behind, so a retry under the same Name failed
with InvalidAMIName.Duplicate.

The handler now passes the requested image tags to the service, which
checks the union of copied and requested keys before it registers
anything. The upstream handler test stubs the new signature.

The docs and the test of a key given both ways now say that the
TagSpecification value winning is Floci's behaviour: the public
CopyImage reference does not say how AWS settles that.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(ec2): keep one CopyImage service signature

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-31 15:02:38 -04:00
..
2026-03-15 17:43:56 -05:00