* fix(iot): honour attributePayload.merge, thingTypeName and expectedVersion on things
UpdateThing replaced the attributes with whatever the request carried, so a
merge update dropped the stored attributes and a type-only update wiped them.
It now merges when attributePayload.merge is true, removes an attribute given
an empty value, leaves the attributes alone when the request has none, sets or
removes the thing type, and rejects a missing or deprecated type and a
removeThingType that also names a type. DeleteThing now honours
expectedVersion, and a stale version reports AWS's message.
Closesfloci-io/floci#6655
* fix(iot): serialize UpdateThing and DeleteThing, reject a malformed thingTypeName
A merge is a read-modify-write and expectedVersion is a compare-and-set,
so both now run under one thing write lock. An empty or malformed
thingTypeName on UpdateThing is an InvalidRequestException, as in AWS,
instead of being treated as absent.
* test(iot): race versioned thing updates and deletes, rerun the SDK test on AWS
A race test holds the thing write lock to one winner per expected
version. On AWS the SDK test borrows an active test thing type, as
fleetIndexSearch does, since a deprecated type cannot be deleted for
five minutes and a rerun would fail.
* fix(iot): answer a malformed thingTypeName with AWS's validation message
UpdateThing now builds the refusal with SmithyValidationErrors, listing
the length violation before the pattern one, as measured on AWS.
* fix(route53): reject record sets outside the hosted zone
ChangeResourceRecordSets fails with InvalidChangeBatch when a record set's
name is neither the zone's name nor a name under it, comparing names
without regard to case or a trailing dot. Wildcard names under the zone
still pass.
* fix(route53): match zone names with ASCII folding and accept any name in the root zone
The hosted-zone check uses normalizeRecordName, the same ASCII-only folding
as record identity, so the Kelvin sign in a label stays distinct from the
letter k. The root zone, named with a single dot, contains every record name.
* fix(elb): keep Classic health checks apart between accounts
The Classic health checker kept its instance states and its probe timer
under the region and the load balancer name. A Classic name is unique
only within one account, so when two accounts each had a load balancer
called web they shared one entry. Creating the second web replaced the
first one's periodic check with its own, and deleting it removed the
first account's instance states too: those instances then reported
OutOfService with reason ELB ("Instance registration is still in
progress") and were no longer checked.
The key now includes the load balancer's account, and the checker's
methods take the load balancer itself instead of a region and a name,
so the account always comes with it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elb): restore every account's Classic load balancers at startup
Startup runs outside any request, where the storage-backed map of
Classic load balancers sees only the default account. Restoring through
it restarted health checks for the default account's load balancers
alone: after a restart, the instances registered with another account's
load balancers reported OutOfService with reason ELB and were never
checked. Those accounts' region maps also stayed the plain maps read
from disk, although the name check in CreateLoadBalancer and the
certificate scan rely on concurrent ones, and a load balancer stored
with the old fixed hosted zone kept it unless the default account owned
it.
Startup now walks the stored region maps of every account: it makes
them concurrent, gives each load balancer its region's hosted zone, and
starts its health checks. A load balancer stored before load balancers
recorded their account takes the account it is stored under, so its
health state and instance lookups belong to that account.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elb): restore the default account's Classic load balancers by their own keys
The every-account restore read the default account from a scan of the
whole store as well, and that scan recognizes only 12-digit account
prefixes. The default account id is configurable, through
FLOCI_DEFAULT_ACCOUNT_ID, and need not be 12 digits. With one such as
local, every restart read the key local/us-west-2 as a region of that
name: the default account's load balancers lost their hosted zone, their
region maps stayed plain maps, and each restart wrote nested copies of
the store that a delete never reached.
The region maps that the storage-backed map shows, which at startup are
the default account's, are read through it again, as they were before
the every-account restore, and written back under their own keys. The
scan now supplies only the other accounts' maps. The javadoc no longer
compares this restore with ELBv2's, which still covers the default
account only.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elb): run the Classic account isolation checks every second
The account isolation tests set their health check through
ConfigureHealthCheck, whose 5-second minimum interval made the two tests
take about 20 seconds. They now set a check every second on the stored
load balancer and re-arm the checker directly, and take about 4
seconds. Both still fail on the commit before the per-account key.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elb): restore each Classic region map under the account in its key
The startup restore read the default account through the storage-backed
map, which shows the account of the current request, and every other
account from a scan that recognizes only 12-digit account prefixes.
Neither holds in general. The service is created on its first use, and
that use can come inside another account's request: an IAM
DeleteServerCertificate reaches it even while Classic ELB is disabled
and its lifecycle restore never runs. Account ids need not be 12 digits
either: FLOCI_DEFAULT_ACCOUNT_ID is free-form, and AssumeRole takes the
account from the role ARN. In those cases the restore again nested
copies of a region map and cleared its hosted zone, or left another
account's load balancers unrestored.
Startup now reads every region map by its raw stored key and takes the
account and the region from it. A region never contains a slash, so the
account is everything before the last one.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elb): check which load balancer each restored account holds
The restore test for region maps read by their stored keys checked each
account's keys, map type, hosted zone and health checks, but not which
load balancer its map held. A restore that wrote every map back under
the account of the current request still passed, with one account left
holding another account's load balancer. The test now checks that each
account's stored map holds that account's own load balancer, and that
write-back fails it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elb): run the Classic isolation checks without waiting on timers
The account isolation tests waited on the real one-second health check
timer, so the class took about 5.6 seconds, 3 of them in the second
case. The checker now keeps the load balancer each periodic check
probes next to its timer, and a package-private runArmedChecks() runs
one tick of every armed check at once. The tests set an interval no
timer reaches during a test, settle each check in one probe, and run
the rounds themselves. The class now takes about 1.8 seconds, most of
it the first case's setup, and the timers keep their schedule.
Running what the armed timers would run, rather than probing one load
balancer directly, keeps the second case meaningful: it is about
another account's balancer taking over the periodic check. With the
account left out of the health checker's key, both cases still fail.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elb): make the second Classic isolation case independent of rounds
The case where another account creates a load balancer of the same name
caught a health checker keyed without the account only because it ran
exactly one round: the other account's default TCP:80 check needs two
failures, so a second round would have let it report OutOfService as
well. The case now also checks that the instance recovers once its
backend answers 200 again, which only the first account's own check can
report.
The helper that registers the instance no longer runs a round of its
own. The probe that registration schedules already settles a check with
thresholds of one, and a second probe could still be running when the
case moved on. Each periodic check now stores the tick its timer runs,
and runArmedChecks runs that same tick, so the two cannot drift apart.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* refactor(elb): create the Classic load balancer store in the constructor
The Classic service created its load balancer store and the map over it
in initializeStorage, so neither field could be final, as AGENTS.md asks
of service fields. Both are now created in the constructor, as
CloudFormationService creates its stores, and are final; without a
StorageFactory the map is a plain in-memory map, as before.
initializeStorage keeps the conversion of region maps read from disk, so
the startup order is unchanged: the store is created and loaded during
the bean's construction either way, and nothing in that step calls
another bean. The StorageFactory field, read only there, is removed.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
A RecordSetGroup writes all its record sets into one hosted zone in a
single ChangeResourceRecordSets batch, so a record set that cannot be
written, such as a name another owner already holds, leaves the zone
unchanged and fails the stack. Each record set keeps what a RecordSet
keeps, including the routing-policy fields SetIdentifier, Weight,
Region, Failover and HealthCheckId; entries an Fn::If resolves to
AWS::NoValue are dropped, and two record sets with one name, type and
set identifier are refused. Ref returns the group's logical ID and
Fn::GetAtt Id the change ID that GetChange reads, as AWS documents.
The zone comes from the group's HostedZoneId or HostedZoneName, or from
its record sets when the group names neither. A record set that repeats
the group's HostedZoneId is refused, as AWS documents, and so is one
that names another zone.
An update in the same zone deletes the records the group wrote and
creates the new ones in one batch. HostedZoneId and HostedZoneName are
create-only, so a change set reports a zone change as a replacement:
the records are written into the new zone, and the old ones are deleted
once the update commits, or kept under UpdateReplacePolicy: Retain. A
failed update puts back the records the group had; after a zone change
the group first points at its old records again, then deletes the new
zone's. If that delete fails, ContinueUpdateRollback retries it and
DeleteStack deletes those records while the rollback is unfinished;
anything else leaves them in their zone, since Route 53 cannot tell
them apart from an identical record another writer puts there later.
Deletes name the values the group wrote, so a record changed outside
the stack fails the delete rather than being removed.
The docs say what a record set group's failed rollback leaves behind.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
CreateEnvironment dropped the Monitors it was sent, and StartDeployment
and GetDeployment never reported the deployed profile's name or
location. AWS documents all three on these operations.
- CreateEnvironment stores Monitors and environment reads return them.
They are checked against AWS's limits (at most five; AlarmArn of 1 to
2048 characters; AlarmRoleArn an IAM role ARN in any partition) and
refused with BadRequestException before anything is stored. An
environment created without monitors returns no Monitors member, as
AWS's own example shows.
- StartDeployment records the profile's ConfigurationName and
ConfigurationLocationUri, and GetDeployment returns them.
- Records stored by earlier builds load unchanged: the new members are
omitted when absent, so their responses stay byte-identical.
A configuration profile created without Type still reports none: AWS
documents no default, and its CreateConfigurationProfile example returns
a null Type.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): relocate SAM schemes without auth defaults
Follow the separate postprocessing request in upstream #6638. Relocate declared OpenAPI security schemes independently of Auth defaults, preserving Swagger and operation requirements.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(sam): centralize OpenAPI security scheme relocation
Keep the defaults helper responsible only for generating AWS_IAM and api_key definitions. Relocate the security scheme map exclusively in the shared final OpenAPI phase, including documents without Auth defaults.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(bedrock): list guardrails in the tagging api and route its writes
guardrails were not a ResourceProvider, so GetResources with bedrock:guardrail came back empty, and TagResources had no bedrock handler to forward to. list the draft of each guardrail with its own tags and add a tagging-api-only handler that calls the existing tag methods.
* test(bedrock): cover guardrail discovery and tagging writes with the sdk
* fix(redshift): stay queued for backend ownership until the deadline
runWithBackendOwned waited for the fair backend lock 200 ms at a time,
the length of the pump's idle read. A wait that ran out while a read
was in progress left the queue, and the pump takes the lock back as
soon as it releases it, so the request could miss every handoff until
the 2 s deadline.
Every Simple Query waits for ownership while the Spectrum interceptor
inspects it. When the handoffs were missed, the query stalled for the
full 2 s, and one over an external table then failed. External-table
preparation on Parse and Bind failed with "Unable to prepare external
query", a Simple Query S3 COPY or UNLOAD went to PostgreSQL
unintercepted and failed there, and closing an abandoned Spectrum
cursor kept its temp table until the session ended.
The wait now spans the rest of the deadline in one attempt, as the
Extended Query Execute paths already do, so the request keeps its
place and takes the lock at the pump's next release. The idle check,
the mid-frame backoff and the deadline itself are unchanged.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* refactor(redshift): drop the unreachable retry after a timed-out lock wait
runWithBackendOwned now waits for the backend lock once, for the rest
of the deadline. A timed tryLock returns false only after that whole
budget has elapsed, so the deadline check that followed always held
and its continue could not run. Return false straight away, with the
same warning; behaviour is unchanged.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(redshift): hand the backend lock to the bridge through a constructor
RedshiftBackendOwnershipTest replaced the bridge's private final
backendLock by reflection, which later JDKs warn about. The public
constructors now pass a new fair lock to a private constructor, and a
package-private one for tests takes the lock with no services, so the
test builds its bridge directly. Production bridges get the same fair
lock as before.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(redshift): run the ownership control test on a short budget
The control case in RedshiftBackendOwnershipTest, where the pump never
releases the lock, sat out the real 2 s ownership deadline on every
run. The test constructor now also takes the runWithBackendOwned
budget: the control case uses 100 ms, and the handoff case keeps the
production 2 s. Production bridges still get PUMP_PARK_WAIT_MS, now
package-private so the test can name it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(iot): deliver data-plane publishes to MQTT subscribers
A message sent with the IoT Data Publish API stored its retained copy
and ran the topic rules, but never reached a connected MQTT client. The
data-plane publish now goes through the broker fan-out after the rules,
as an MQTT publish does.
The fan-out delivers at the lower of the message and subscription QoS,
with RETAIN 0, and a retained message sent on subscribe carries RETAIN 1
at the lower of its stored and the subscription QoS, as measured on AWS
IoT Core. Publish refuses a qos other than 0 or 1 with AWS's
InvalidRequestException messages.
Closesfloci-io/floci#6627
* fix(iot): allocate packet identifiers for broker publishes
Vert.x draws the packet identifier of an outbound publish from an
unsynchronized per-endpoint counter. With QoS 1 delivery, two threads
fanning out to one client could send two unacknowledged copies under the
same identifier. The broker now allocates them from one atomic counter.
A retained message stored with a negative qos, which Publish accepted
before it validated qos, is sent on subscribe at QoS 0 instead of
aborting the replay.
* fix(iot): keep MQTT packet identifiers per session
One broker-wide counter let copies sent to other clients, QoS 0 included,
wrap a client's identifiers while its QoS 1 copy was unacknowledged. Each
session now draws QoS 1 identifiers from its own counter, and a QoS 0
copy carries none.
* test(iot): share the IoT Data client builder
Both IoT Data integration tests now build their IotDataPlaneClient
through IotDataRequests.iotDataClient(accessKey), as review asked. The
IoT limitations also list that a QoS 1 copy is never retried and has no
in-flight limit, where AWS holds further copies at 100 unacknowledged.
* test(iot): drive the packet identifier isolation test at QoS 1
QoS 0 copies carry no packet identifier, so the other client's 65,534
copies must be QoS 1 for the test to catch a counter shared by every
client. The IoT limitations also say that a data-plane Publish reaches
subscribers in every account and region, as the broker has none.
* feat(redshift): execute automated snapshot schedules
* fix(redshift): address automated snapshot review findings
Flush snapshot metadata before deleting an expired dump, pause the
snapshot scheduler across emulator reset, run retention even when the
next dump fails, and remove checkpoints of deleted clusters.
* fix(redshift): retake an automated snapshot whose metadata was lost
The checkpoint is a separate store, so it can persist while the snapshot
metadata never reached disk. Skip a completed occurrence only when its
snapshot still exists.
* test(redshift): restore the automated snapshot on the shared interceptor cluster
Run the Docker restore scenario in RedshiftInterceptorIntegrationTest
against the cluster it already starts, so only the restore pays for a
container, and drop the hand-rolled Docker probe.
* fix(ec2): keep key pair names unique under concurrent requests
CreateKeyPair and ImportKeyPair checked that a name was free and stored
the new key pair as two separate steps, so two requests for one name at
the same moment could both pass the check and both store a key pair.
Both got a key pair back, DescribeKeyPairs listed the name twice, and
RunInstances injected whichever record it found first, so the other
caller's private key did not open the instance. CreateKeyPair generates
its key between the two steps, which keeps that window open for as long
as key generation takes.
Both actions now store through one method that checks the name again
and writes under the EC2 service's striped lock for the region and
name, so the second request is refused with InvalidKeyPair.Duplicate
and the same message as before. The first check stays where it was, so
a single request is answered as before, and a taken name is still
refused before a key is generated for it.
Follow-up to the review of #6112.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): keep a tag write from restoring a deleted key pair
A CreateTags on a key pair reads the record and writes it back with its
new tags while holding the key pair's lock, but DeleteKeyPair deleted
without that lock. A delete landing between the read and the write was
undone: the key pair came back, and if a CreateKeyPair had taken the
freed name in between, the name then had two key pairs.
DeleteKeyPair now deletes each matching key pair under the lock tag
writes take on it, as DeleteEgressOnlyInternetGateway does, so a tag
write either finishes before the delete or finds the key pair gone.
The EC2 docs now say what CreateKeyPair and ImportKeyPair do with a
taken name rather than promising one key pair per name outright.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(ec2): pin where the key pair race tests wait, and clean up the SDK test
The race tests now let the held write go early only when the waiting
request is blocked in storeNewKeyPair or deleteKeyPair on a monitor the
held request owns, and otherwise wait for that request to finish, so a
change that made it wait anywhere else fails the test instead of
quietly skipping the check under the lock.
The SDK test waits up to 60 s for its requests to finish before it
deletes the name, so a slow request is not left to store a key pair
after the cleanup, and it checks the refused requests' error code and
status but not their message, which AWS words differently from Floci.
The storeNewKeyPair Javadoc also says that the store's own locks, taken
inside the name lock, never lead back to an EC2 lock.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(ec2): name what the key pair race tests wait for
A race test whose request comes to wait anywhere other than the named
Ec2Service method now fails with a timeout that says what it waited
for, and the helper says why the method is named. The DeleteKeyPair
comment says that scan returns a new list rather than copies, and the
SDK test's cleanup comment says it waits up to 60 s.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(ec2): say what pinning the waiting method guards against
The race tests' helper Javadoc no longer says that a wait elsewhere
always skips the code under the lock: such a wait may not be at the
lock under test, so the tests time out rather than pass without
exercising it, and moving that lock into another method means updating
the name the tests give.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(ec2): park the key pair race tests' writes with ParkingStore
Both race tests held a write on a latch in an anonymous store of their
own. They now wrap the shared testing ParkingStore in
AccountAwareStorageBackend, as the Config tagging tests do, and arm its
next write: before the first request in the name race test, and after
the key pair is created in the delete test, so the write it parks is
the tag write's. The name race test creates ED25519 keys so that key
generation stays well inside ParkingStore's two-second wait. Main code
is unchanged.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* feat(dynamodb): read PartiQL's FROM-first form of UPDATE
DynamoDB accepts FROM "T" WHERE key SET ... REMOVE ..., the clauses in
PartiQL's order, and runs it as the same update as UPDATE "T" SET ...
WHERE key, under the same dynamodb:PartiQLUpdate action. Without a SET
or REMOVE the statement is not well formed, and a WHERE after them is a
token left over. Floci refused the form as not well formed.
* fix(dynamodb): refuse an UPDATE whose SET or REMOVE does not follow the table
DynamoDB answers UPDATE "T" WHERE pk = 'x' and UPDATE "T" WHERE pk = 'x'
SET c = 1 with "Statement wasn't well formed, can't be processed:
Expected data manipulation", the same as the FROM-first form with no SET
or REMOVE. The shared clause parser now makes that check for both forms.
Follow the separate whole-map replacement requested in upstream #6632. Preserve Swagger, no-default behavior, operation requirements and unrelated OpenAPI components.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* feat(rds): DescribeCertificates, ModifyCertificates and an instance's CA certificate
DescribeCertificates lists the Region's RDS certificate authorities with the
thumbprint and validity AWS reports, vendored from the certificate bundles AWS
publishes by tools/aws/regen_rds_ca_certificates.py, and pages them.
ModifyCertificates sets or removes the account's default for new instances.
CreateDBInstance, ModifyDBInstance, the two instance restores and
CreateDBInstanceReadReplica take CACertificateIdentifier, and instances report
it with CertificateDetails. AWS::RDS::DBInstance takes the property and
resolves the two CertificateDetails attributes. The identifier is metadata:
the auth proxy keeps presenting Floci's own CA.
Closes#5806
* fix(rds): follow the user guide on CAs and leave a blank CA alone
- An instance stored without a CA reports rds-ca-rsa2048-g1, since an
override applies only to instances created after it.
- ap-south-1, ap-southeast-4, ca-west-1, eu-central-2, eu-south-2 and
il-central-1 offer only rds-ca-rsa2048-g1, as the user guide says.
- A blank CACertificateIdentifier on modify leaves the instance's CA.
- --download skips a Region only on 403 or 404 and exits 1 on other
failures.
- Reuse regionFromArn, add a createDbInstance stub helper and import
Executable in the tests.
* feat(lambdamicrovms): version network connectors as AWS does
* fix(lambda): lock connector versions and refresh them after a CFN rollback
Updates, deletes and version reads hold one lock, so two updates cannot
take the same version number.
A CloudFormation rollback restores the connector through an update. On
AWS that makes the next version, and a later Fn::GetAtt returns it. The
resource now keeps that version in LatestVersion and LatestVersionArn.
Read the connector ARN through AwsArnUtils.parse.
AWS refuses LatestVersion, an integer, as a string Output, so the stack
test reads LatestVersionArn only.
* fix(lambda): type the connector LatestVersion attribute as an integer
AWS::Lambda::NetworkConnector declares LatestVersion as an integer. On AWS
a stack whose string Output reads it fails with "Template format error:
Every Value member must be a string.", and Fn::Sub refuses it with
"variable Connector.LatestVersion in Fn::Sub expression does not resolve
to a string".
* chore(lambda): share the connector version ARN and integer attribute helpers
AssociateAccessPolicy, ListAssociatedAccessPolicies and
DisassociateAccessPolicy had no route, so their requests fell through to
S3's path-style catch-all and came back as an S3 XML error. Terraform's
aws_eks_access_policy_association could not be created.
The three operations follow access entries: they are management
metadata, stored and returned but not enforced in Kubernetes. Each
association is kept on its access entry, so deleting the entry or the
cluster removes it, and entries persisted before this change load with
no policies. ListAccessEntries now honours associatedPolicyArn.
Validation follows the EKS user guide: only STANDARD entries take access
policies, the scope is cluster (no namespaces) or namespace (one or more
names, wildcards kept, a repeated name stored once), and associating a
policy again replaces its scope and keeps its associatedAt. policyArn
must be an EKS cluster access policy ARN in the cluster's partition; the
name is not checked against AWS's list. Listing pages from 1 to 100,
with tokens bound to the entry they came from. Disassociating a policy
the entry does not hold succeeds, since EKS documents no error for it;
a missing entry is still ResourceNotFoundException, and an ARN that
associate would refuse is InvalidParameterException. ListAccessEntries
now pages through the shared Pagination helper too, so a token issued
before this change is refused.
Under IAM enforcement the list and disassociate routes were checked as
DescribeAccessEntry and DeleteAccessEntry, and all three against a
principal ending in /access-policies, so a grant scoped to the entry
never matched. They are now checked as their own actions, against the
entry's ARN.
A DELETE is a disassociate only when a cluster access policy ARN
follows access-policies, in the route, the IAM rule and the resource,
so an entry whose IAM path holds an access-policies segment can still
be deleted. The router matches the encoded path, so a principal sent
URL-encoded, as the SDKs send it, is never split.
Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
* fix(cloudwatch): accept the CloudWatchVersion20130116 JSON target
The CloudWatch console's API sends JSON 1.0 requests to the monitoring
endpoint with X-Amz-Target CloudWatchVersion20130116.<Operation>, signed
for the monitoring service. Floci knew only the GraniteServiceVersion20100801
prefix the SDKs send, so every such request got HTTP 404
UnknownOperationException.
Register the prefix on the monitoring descriptor as a JSON-only target,
the mechanism the DynamoDB_20111205 prefix already uses. A request naming
it now reaches the CloudWatch JSON handler and the same metrics and alarms,
after the same signature validation, unsigned-call refusal and
cloudwatch:<Operation> IAM check as the current prefix. CBOR and Smithy
RPC v2 requests that name it stay unknown, as do other CloudWatchVersion
dates.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudwatch): serve only shared operations on the console JSON target
The CloudWatch console's API names its operations with the
CloudWatchVersion20130116 target, and several of them take shapes the
current API does not: its GetMetricData takes Defaults and Metrics
instead of MetricDataQueries, and its PutMetricAlarm and DescribeAlarms
describe metric queries with Alias, Namespace and MetricName items
instead of Id and MetricStat. The CloudWatch JSON handler ignores members
it does not know, so through that target a console GetMetricData answered
HTTP 200 with no results, and a console PutMetricAlarm stored an alarm
without its metric.
Route the target through a handleLegacy entry, as DynamoDB_20111205 is
routed, and serve there only the operations whose shapes the two APIs
share: ListMetrics, DescribeAlarms, GetMetricStatistics and DeleteAlarms.
Every other operation, and a request that sets a member only the
console's API defines (CountOnlyRequest, SegmentId, TotalSegments,
ExcludeAutoscalingAlarms, ExcludeManagedAlarms), gets HTTP 400
UnsupportedOperation, the error Floci gives an operation it does not
implement.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudwatch): refuse unshared members and math alarms on the console target
Two gaps were left on the CloudWatchVersion20130116 target. Its
DescribeAlarms listed a metric math alarm's Metrics as the current API's
Id and MetricStat items, which the console's API does not define, so a
client parsing the answer with that API's model sees metrics with no
namespace, name or statistic. And only the five console-only members
known today were refused, so a member the console's API adds later would
again be ignored.
Refuse a DescribeAlarms answer that would list a metric math alarm, and
check request members against the ones the current API defines for each
served operation, as botocore's cloudwatch 2010-08-01 model lists them,
instead of against a list of console-only names. A null or false value
still counts as unset.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudwatch): serve only honoured members on the console target
The console target accepted every request member botocore's model
defines for its four operations, but the CloudWatch JSON handler ignores
several of them: StateValue, AlarmTypes, ActionPrefix, ChildrenOfAlarmName
and ParentsOfAlarmName on DescribeAlarms, ExtendedStatistics on
GetMetricStatistics, and RecentlyActive, OwningAccount and
IncludeLinkedAccounts on ListMetrics. A request using one got HTTP 200 as
if the member were unset. A null member also reached the handler, which
read it as the string "null".
Accept on the console target only the members the handler honours, plus
NextToken and MaxRecords, which change nothing because every result comes
back at once. Refuse any other member that is set with HTTP 400
UnsupportedOperation, and drop null members before handling. The four
operations are served under these member checks and the DescribeAlarms
check, which now names an alarm defined with Metrics rather than a metric
math alarm, since it also covers a single metric query.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudwatch): cover presigned console-target calls and align naming
Call the CloudWatchVersion20130116 target the console target in the
tests, as the docs and comments do, and say why handleLegacy keeps the
name of DynamoDB's JSON-only entry point. Cover presigned requests on
both prefixes, and keep the DescribeAlarms rows within what AWS accepts
by sending AlarmNames and AlarmNamePrefix apart. State in the docs that
only the bare prefix over application/x-amz-json-1.0 is accepted, and in
the comments that only top-level null members count as unset.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudwatch): pin the console target's other wire forms as unknown
The docs say only the bare CloudWatchVersion20130116 prefix over
application/x-amz-json-1.0 reaches CloudWatch. Pin that: the bare
prefix over application/json or JSON 1.1, and the fully qualified
com.amazonaws.cloudwatch.v2013_01_16 form, answer HTTP 404
UnknownOperationException. Name the presigned test for what it checks,
a wrong secret, and wrap the new comments at 100 columns.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudwatch): share the signed IAM user setup between signature tests
CloudWatchJsonTargetSignatureIntegrationTest and
CloudWatchQueryGetSignatureIntegrationTest each carried their own copy
of a helper that signs IAM Query calls with the root test key, and of the
setup that creates a user with an access key and an inline policy and
then removes them. Move both into SignedIamUsers under the testing
package and call it from the two classes. It uses real SigV4 signatures,
which the classes need because signature validation is on;
EnforcementFixtures' placeholder signatures would be refused.
The returned user is AutoCloseable, so each test holds it in a
try-with-resources block; if creating the key or the policy fails, the
parts already made are removed. Test behaviour is unchanged: both classes
run the same 13 tests and pass before and after.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(dynamodb): lift the PartiQL overlap refusal when a branch tests a key outside a range
DynamoDB refuses a SELECT whose OR branches overlap on the sort key, but
not once a branch tests a key in a way no key condition can hold, such as
sk <> 'a', attribute_exists(sk) or NOT sk = 'a'. Every branch then runs
and the statement returns the union, each item once. A NOT lifts the
refusal only when it sits right on the test, and a NOT over size() never
does. Floci refused all of these as overlapping.
* chore(dynamodb): walk PartiQL condition leaves through one helper
The key plan had two walks over And, Or and Not that differed only in
the test on each leaf.
CreateNodegroup on a cluster whose node runs a different instance type
replaces the k3s node while holding the cluster's capacity lock.
DeleteCluster did not take that lock. A delete during the swap found no
container to stop, so the replacement node kept running, and the swap
then wrote the deleted cluster back to storage, stuck in DELETING.
DeleteCluster now takes the capacity lock before it reads the cluster
and marks it DELETING, so it waits for the swap and then stops the node
the swap started. A second delete that waited behind the first finds the
cluster gone and answers ResourceNotFoundException. The lock is taken
before the clustersBeingDeleted monitor, the order the swap already uses.
Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
* fix(cloudformation): pass IntegrationMethod and RequestParameters for AWS::ApiGatewayV2::Integration
AWS::ApiGatewayV2::Integration dropped IntegrationMethod and RequestParameters on create
and update, so GetIntegration returned null for both. Also pass RequestTemplates,
TemplateSelectionExpression and TimeoutInMillis, which the integration model already stores,
and count them as changes when deciding whether a connection rollback is complete.
Closes#6135
* fix(cloudformation): replace ApiGatewayV2 integration fields on stack update
UpdateIntegration keeps a field the request leaves out, so removing IntegrationMethod,
TemplateSelectionExpression, TimeoutInMillis, RequestParameters or RequestTemplates from a
template left the old value stored and still reaching the backend. Set them as the template says,
null included, the way replaceIntegrationConnection does, and restore them on a stack rollback.
A selected AWS::NoValue, as a mapping entry or as a whole property, now leaves the entry or the
field out instead of storing an empty string or failing the TimeoutInMillis parse.
* test(cloudformation): share ApiGatewayV2 stack test helpers
* fix(cloudformation): provision a usage plan's throttle, quota and stage throttles
* fix(cloudformation): roll back a usage plan when its stack update fails
* fix(cloudformation): keep a failed usage plan update for its rollback retry
* fix(cloudformation): snapshot a usage plan under its patch lock
* fix(cloudformation): restore a usage plan without a lock-free comparison
* refactor(cloudformation): share the API key and usage plan update rollback through CfnRollback
Preserve standalone ENI validation before address allocation and the existing ECS network error translation. Keep RunInstances and cross-VPC errors unchanged.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* perf(core): keep long polls off the shared request workers
SQS ReceiveMessage and Step Functions GetActivityTask hold their request
for up to 20 and 60 seconds while they wait for work, and Step Functions
StartSyncExecution holds it until its express execution ends. The AWS
JSON 1.0, CBOR and Query entry points ran them on the shared Quarkus
worker pool (by default the larger of 200 threads and eight per CPU), so
once that many polls were waiting, every other blocking request queued
behind them, /health included. On a JVM build limited to two CPUs, 220
idle ReceiveMessage polls kept DynamoDB, SQS, EC2, SSM, S3 and health
requests waiting about 17 seconds, until the first polls returned.
Run those entry points on virtual threads. Quarkus REST builds the same
handler chain for a @RunOnVirtualThread method as for any blocking one,
request filters and request scope included; only the executor that runs
it changes. Routing, signature and IAM checks, the account and Region a
request runs in, and the responses stay as they were.
The regression test shrinks the pool to four workers and holds four
ReceiveMessage polls, one per account and Region, on each of the five
entry points SQS is served through. While they wait, ListQueues in each
account and Region must list only that scope's queue, and an invalid
receive, EC2 DescribeRegions, SSM DescribeParameters and /health must be
answered. Each poll must still return the message later sent to it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* perf(lambda): keep Invoke and function URL calls off the shared workers
A RequestResponse Invoke and every function URL request wait for the
function to finish, up to its timeout. Both ran on the shared Quarkus
worker pool, so as many slow invocations as the pool has threads left
every other blocking request, /health included, queued until one of
them returned.
Run the Invoke entry point and the five function URL methods on virtual
threads, as the AWS JSON 1.0, CBOR and Query entry points now do. The
request filters, the account and Region the invocation runs in, and the
responses are unchanged. Lambda calls that other services make, such as
API Gateway integrations, ALB targets and AppSync resolvers, still wait
on a worker.
The regression test shrinks the pool to four workers and holds four
invocations, one per account and Region, at the LambdaService boundary,
for Invoke and for each function URL method. While they wait, /health
and SSM DescribeParameters, which still use the worker pool, and
DynamoDB ListTables and EC2 DescribeRegions must be answered, and each
invocation must then return its own function's result.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(core): bound the wait for virtual threads at shutdown to 10 seconds
Quarkus interrupts worker threads still running 10 seconds into its
final shutdown tasks, but by default waits up to a minute for virtual
threads. With every AWS JSON 1.0, CBOR, Query, Invoke and function URL
request now on a virtual thread, a SIGTERM with long polls parked kept
the process alive until they ended: 16 seconds for 20 second
ReceiveMessage polls and 56 seconds for GetActivityTask polls, against
10 seconds before.
Set quarkus.virtual-threads.shutdown-timeout to 10s, the interval
Quarkus uses for worker threads. With 50 parked ReceiveMessage or
GetActivityTask polls the process now stops in 10.2 seconds, as on
main. The key is fixed at build time, so it lives in application.yml.
Storage is still flushed and the HTTP server closed before this wait,
and dev mode, which stops virtual threads at once, is unaffected.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test: share the held-worker probes and send them together
AwsProtocolLongPollIntegrationTest and
LambdaSynchronousInvokeDispatchIntegrationTest each held one request per
worker and then copied the same harness: the four account and Region
scopes, the request signing, a five second wait per request, and the
health, SSM and EC2 DescribeRegions probes. Move that into
HeldWorkerProbes, next to FourWorkerThreadsProfile, so each class keeps
only its own held requests and its own probes: ListQueues and an
invalid receive for SQS, DynamoDB ListTables for Lambda.
The probes used to run one after another, five seconds each, while the
held requests wait 20 seconds. On a slow enough runner the probes could
outlast the holds and fail a test whose dispatch was correct. They are
now sent together and share one five second deadline. With the ten
seconds allowed for the held requests to arrive, the probes end at most
15 seconds after those requests were sent, inside their 20 seconds. Under 32 busy loops on two CPUs the sequential
probes took up to 2.1 seconds and the concurrent ones up to 0.6.
The assertions are unchanged, and a probe that is not answered is
named in the failure. Both classes still fail on main, and the Lambda
class still fails with only the protocol commit applied.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test: tie the held-worker probe deadline to the hold time
HeldWorkerProbes promised that its probes finish before a held request
is released, but the 20 second hold and the 10 second wait for the
held requests to arrive were literals repeated in each test. Move both
into the helper as HOLD_SECONDS and ARRIVAL_SECONDS, use them in both
tests, and check when the class loads that the arrival wait plus the
probe deadline stays under the hold.
A probe check that throws something other than an assertion now fails
with the probe's name, and the worker-count check reports both counts.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
AppSyncVtlEngine registered ReturnDirective with Velocity by a literal
class name, and RequestBodyReader keyed its buffered-body request
property with one. Both now come from the class, so they follow it when
the package moves to io.floci.aws. The values are unchanged today.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
Seven tests read Floci's own sources through paths written out as
src/main/java/io/github/hectorvent/floci/..., and
PersistedModelReflectionTest named the root package as a string. A new
MainSources helper derives them from classes instead (the root package
from its own package), so they keep pointing at the right files when
the package moves to io.floci.aws. PersistedModelReflectionTest also
imports File instead of qualifying it inline.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>