Expose backend keep-alive and idle-pool timeout controls while retaining the existing defaults. Preserve target failures without replaying uncertain requests, and document target timeout hints and local transport limits.
Validate negative idle timeouts with a Floci-specific error before creating clients, and attempt every fixture cleanup step while preserving aggregated failures. Cover negative, zero and positive configuration values and real-listener connection behavior.
Closes#7524
test(elbv2): replace timer-dependent backend checks
Match observed HTTP listener DescribeListenerCertificates responses by omitting the absent Certificates list. Preserve configured HTTPS certificates and cover both Java SDK and XML response shape.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): add X-Forwarded headers to ALB requests as AWS does
An ALB forwarded client headers unchanged, so a target never learned the
client address and trusted whatever X-Forwarded-For the client sent. The
routing.http.xff_* attributes were stored but never read.
Apply routing.http.xff_header_processing.mode and
routing.http.xff_client_port.enabled on HTTP, WebSocket and Lambda targets,
and set X-Forwarded-Proto and X-Forwarded-Port from the listener connection.
ModifyLoadBalancerAttributes now rejects invalid values for both attributes.
Keep every line of a repeated request header when proxying, and use the last
value in a Lambda event's headers map, as the ALB guide describes.
Take the HTTP API $context.identity.sourceIp from the TCP connection instead
of the caller's X-Forwarded-For, which let a caller spoof it.
* docs(apigatewayv2): limit the X-Forwarded-For hop note to ALB listeners
An ALB adds or updates X-Amzn-Trace-Id before it sends a request to a target,
but Floci passed through only what the client sent. Generate a Root field when
the header is absent, insert or update a Self field when it is present, keep
other fields, and rewrite to a new Root field above 7 KB of request headers.
* fix(elbv2): relay TCP listeners without HTTP parsing
Forward raw TCP traffic and TLS passthrough to registered targets while preserving per-connection routing. Cover the data plane through AWS SDK integration tests and document dedicated-port limitations.
Refs #5870
* test(elbv2): make TCP data plane test cleanup resilient to partial failures
* refactor(elbv2): share target selection helpers between TCP and HTTP paths
Extract targetCandidates and pickRoundRobin to remove the duplicated
healthy-or-registered fallback and round-robin pick from the TCP relay
and HTTP forwarding paths, unifying both on the floorMod counter that
cannot go negative.
* fix(elbv2): honor listener tcp idle timeout and park colliding listeners
Use tcp.idle_timeout.seconds attribute dynamically in the TCP relay tunnel, and register colliding listeners on in-use ports as parked with a warning, promoting them once the active listener is removed.
* fix(elbv2): validate tcp idle timeout range and reuse timeout parser
* fix(elbv2): unify parse failure and range check in listener attribute validation
* fix(elbv2): admit new targets after one successful health check
Preserve recovery thresholds and verify initial admission against a real HTTP target.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): scope initial health admission to application targets
Preserve network and gateway target-group health thresholds.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): retain initial health checking reason
Preserve the intermediate reason for network and gateway targets below their success threshold.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): preserve TLS handshakes during certificate reloads
Reuse the generation-aware TLS key manager for ELBv2 and publish fully loaded SNI snapshots without replacing the active SSL context. Preserve the previous snapshot on load failure.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): cover TLS resumption and wildcard selection
Verify TLS 1.2 resumption with unchanged material and fresh authentication after certificate replacement or removal. Separate the wildcard certificate from the default and document the full-handshake boundary.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): document retained TLS sessions on reload
Exercise stateful and stateless TLS 1.2 resumption with shared client contexts. Document the retained-session certificate boundary while preserving full-handshake refresh behavior.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix: reject explicit protocols on gateway load balancer listeners
Validate gateway listener Protocol before create publication or modify mutation. Preserve omitted-field updates and cover Query rejection and state preservation.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* test(elbv2): omit protocol in gateway listener fixture
Keep the successful gateway listener lifecycle fixture aligned with the accepted Protocol prohibition. Assert protocol preservation after an action-only update without introducing a default-protocol contract.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(elbv2): preserve gateway listener defaults
Default gateway listener responses to GENEVE and keep omitted protocol and port unset through CloudFormation create and update. Preserve application and network listener defaults. Cover direct Query and stack lifecycle behavior.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Reject explicit gateway listener ports before publication or mutation, preserving listener range validation and omitted-port updates.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* test(elbv2): expect ValidationError for SetSubnets with one ALB subnet
SetSubnets on an Application Load Balancer with one subnet answers
InvalidConfigurationRequest with a message of Floci's own, once the
subnet has been looked up. The SetSubnets API reference states the
rule CreateLoadBalancer states, subnets from at least two Availability
Zones, and since #6098 CreateLoadBalancer answers one subnet with
ValidationError "At least two subnets in two different Availability
Zones must be specified", counted before any subnet is looked up.
- ElbV2ServiceTest, ElbV2IntegrationTest (Query protocol) and the
compatibility suite's ElbV2Test expect that error for SetSubnets
with one subnet, in Subnets or in SubnetMappings, and for one subnet
that does not exist, with the balancer left on its subnets.
- CloudFormationElbV2SubnetUpdateIntegrationTest: an update that keeps
the balancer and names one subnet rolls back with that error.
- A Network or Gateway Load Balancer is still set onto one subnet, and
a move onto no subnets, which a CloudFormation rollback makes for a
balancer an earlier version saved without subnets, is still taken.
- setSubnetsWithMissingSubnetReturnsSubnetNotFound sends an existing
subnet beside the missing one, so it still reaches the lookup.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elbv2): answer SetSubnets with one ALB subnet with ValidationError
SetSubnets on an Application Load Balancer with one subnet now answers
ValidationError (400) "At least two subnets in two different
Availability Zones must be specified", the answer CreateLoadBalancer
gives since #6098, instead of InvalidConfigurationRequest with a
message of Floci's own. setSubnets runs requireSubnets once it has
looked the balancer up for its type and before any subnet is looked
up, so one subnet that does not exist gets the same answer, as on
create. One SubnetMappings entry goes through the same check.
The answer follows the SetSubnets API reference, which states the
two-zone rule for an Application Load Balancer, and the answer AWS
gives CreateLoadBalancer; no public report shows what AWS answers
SetSubnets with one subnet. AWS does give a Network Load Balancer's
SetSubnets with no subnets CreateLoadBalancer's message.
A CloudFormation update that keeps an Application Load Balancer and
names one subnet moves it through setSubnets, so it now fails with
this error and rolls back. A move onto no subnets is not counted,
because a CloudFormation rollback moves a balancer an earlier version
saved without subnets back onto none. A Network or Gateway Load
Balancer can still be set onto one subnet.
resolveSubnetVpcId drops its own one-subnet refusal, which neither
caller reaches any more; its zone check still refuses an Application
Load Balancer whose subnets are all in one Availability Zone.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): say where SetSubnets' one-subnet answer comes from
Review follow-ups to the SetSubnets one-subnet fix:
- The requireSubnets Javadoc scopes what AWS is known to answer to
CreateLoadBalancer, and says SetSubnets gets the create message and
order because no public report shows what AWS answers there.
- The setSubnets comment says an empty list moves the balancer onto no
subnets, rather than that the list is left alone.
- docs/services/elb.md says the same about the SetSubnets answer, and
instead of saying a Gateway Load Balancer can be set onto one subnet,
that Floci does not enforce AWS's rule that SetSubnets keeps every
subnet a Gateway Load Balancer already has.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): keep the SetSubnets tests to answers ELBv2 gives
Review follow-ups to the SetSubnets one-subnet fix:
- ElbV2CfnProvisionerTest: the update with a blank SubnetId keeps a
Network Load Balancer, for which SubnetNotFound is still the answer
ELBv2 gives; an Application Load Balancer now gets the subnet count
error first. The move-and-move-back test moves the kept balancer
onto two subnets, as ELBv2 refuses an Application Load Balancer on
one.
- ElbV2ServiceTest: the move onto no subnets follows the rollback it
stands for, a balancer saved without subnets moved onto subnets and
back onto none. SetSubnets onto one subnet for a balancer that does
not exist reports LoadBalancerNotFound before any subnet is looked
up.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): word the SetSubnets count notes as the rules read
Second review round on the SetSubnets one-subnet fix:
- docs/services/elb.md no longer says Network and Gateway Load
Balancers are not counted: they are, and a list that names a subnet
cannot fail the count for them, while a SetSubnets with neither form
is refused for every type once #6100 lands. It now says a Network
Load Balancer can be set onto one subnet, and that AWS requires a
Gateway Load Balancer's SetSubnets to list every subnet it is
already on, which Floci does not enforce.
- The setSubnets comment says "an earlier Floci version", as the
tests do.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the blank SubnetId update a typed balancer
Second review round on the SetSubnets one-subnet fix: the update with
a blank SubnetId in ElbV2CfnProvisionerTest names a Network Load
Balancer in its template, and the balancer its describe stub returns
is now a network one too, so the template, the stub and the Javadoc
agree. The answer the stub gives, SubnetNotFound, is unchanged.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): scope the Gateway Load Balancer SetSubnets rule to Subnets
Third review round on the SetSubnets one-subnet fix: the SetSubnets API
reference states that a Gateway Load Balancer must include every
subnet it is already on under Subnets only, not under SubnetMappings,
so docs/services/elb.md now says the reference requires it of a
Gateway Load Balancer's Subnets, rather than of its SetSubnets as a
whole. Floci still does not enforce it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* chore(elbv2): tidy what #6100 and the SetSubnets count both added
With #6100 merged, this branch and it each documented and tested the
same SetSubnets paths:
- ElbV2ServiceTest keeps aRollbackOntoNoSubnetsIsNotCounted, which
models the CloudFormation rollback that needs setSubnets to take an
empty list, and drops #6100's aMoveBackOntoNoSubnetsIsStillTaken,
which tested the same call on a balancer that still had subnets. The
two missing-balancer tests now say which path each pins: the
SetSubnets action with neither form, or setSubnets with one subnet.
- The requireSubnets Javadoc names setSubnetsFromRequest beside
setSubnets, and the setSubnets comment no longer repeats the
empty-list reason its Javadoc gives.
- docs/services/elb.md has one SetSubnets bullet instead of two.
No behaviour changes.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): say what requireSubnets checks for SetSubnets
Review of the merge with #6100: the requireSubnets Javadoc gave the
two-zone rule as the reason setSubnetsFromRequest runs it, but that
call refuses a SetSubnets that names no subnets, for every type, and
requireSubnets only counts the list. It now says SetSubnets takes the
same subnets as CreateLoadBalancer, which of the two methods runs the
count on which list, and that the two-zone check comes after the
subnets are looked up. Javadoc only.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): say what the folded SetSubnets bullet counts like
Review of the tidy: once the two SetSubnets bullets in
docs/services/elb.md became one, "counted the same way" followed the
sentence about a SetSubnets with neither form, so it no longer read
as CreateLoadBalancer's count. It now says a SetSubnets that names
subnets is counted as CreateLoadBalancer counts them.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): cover SetSubnets with neither Subnets nor SubnetMappings
SetSubnets takes Subnets or SubnetMappings, and AWS refuses a request
with neither. These tests pin that answer, which Floci does not give
yet: a ValidationError with the CreateLoadBalancer message for the
balancer's type, with the balancer left on its subnets and in its VPC,
whether the two lists are left out or sent empty. They fail until the
fix that follows.
They also pin the paths that must keep working: a balancer that does
not exist is reported first, a CloudFormation update that names
neither leaves its kept balancer alone, and a rollback can still move
a balancer an earlier version saved without subnets back onto none.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elbv2): refuse SetSubnets with neither Subnets nor SubnetMappings
A SetSubnets that named neither Subnets nor SubnetMappings answered
success and left the load balancer in no Availability Zone, still in
its VPC. The API reference says the request takes one or the other,
and AWS answers a Network Load Balancer's with "ValidationError: At
least one subnet must be specified", the message CreateLoadBalancer
gives it.
SetSubnets with neither now answers ValidationError and leaves the
balancer on its subnets, with the message CreateLoadBalancer gives the
balancer's type: "At least two subnets in two different Availability
Zones must be specified" for an Application Load Balancer, "At least
one subnet must be specified" for a Network or Gateway Load Balancer.
A balancer that does not exist is still LoadBalancerNotFound, since
the message depends on its type, and a request that names subnets is
checked as before.
The check runs in the new ElbV2Service.setRequestedSubnets, which the
Query handler calls. ElbV2Service.setSubnets still takes an empty
list: CloudFormation moves a kept balancer through it, never onto none
on an update, and onto none on a rollback only for a balancer an
earlier version saved without subnets, which rolls back as before.
Follow-up to #6087.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* refactor(elbv2): keep the SetSubnets action check in the package
Review follow-ups, no change in behaviour:
- The action's entry point is now the package-private
ElbV2Service.setSubnetsFromRequest, which only the Query handler
calls; setRequestedSubnets read like a property setter. The
CloudFormation provisioner, in another package, cannot reach it and
keeps moving balancers through setSubnets.
- Its Javadoc says why only an empty list is refused there: a request
that names subnets is checked by setSubnets. The setSubnets and test
Javadocs speak of a balancer an earlier Floci version saved without
subnets.
- The provisioner test of an update that names neither says the real
reason the update must not call setSubnets: it would move the
balancer onto none.
- The docs line for SetSubnets gives both messages.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the SetSubnets neither test the class's last order
#6098 adds a test at @Order(79) earlier in ElbV2IntegrationTest, while
this one stays the last method in the file at @Order(78). Once both
land, whoever appends a test would read 78 and pick 79, so this one
takes 80 and the last method keeps the highest order. The two tests
are independent, so the order between them does not matter.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the SetSubnets compat test its own order
setSubnetsWithoutSubnets and createLoadBalancerWithoutSubnets in the
compatibility suite's ElbV2Test both carried @Order(6), so JUnit's
order between them was left to its tie-break. The SetSubnets test now
has @Order(8), the first value not taken once #6098's @Order(7) test
is in the class, so every order in the class is unique. The test stays
where it is in the file: moving it below the create test would edit
the lines #6098 added on main. The two tests create and delete their
own balancers, so neither depends on running before the other.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): expect ValidationError for a single-subnet ALB
AWS answers a CreateLoadBalancer for an Application Load Balancer with
one subnet with ValidationError (400) "At least two subnets in two
different Availability Zones must be specified", the answer it gives
one with none, and it counts the subnets before it looks them up.
Floci answers InvalidConfigurationRequest with a message of its own.
- ElbV2ServiceTest, ElbV2IntegrationTest (Query protocol),
CloudFormationElbV2SubnetMappingsIntegrationTest and the
compatibility suite's ElbV2Test expect that error, and no balancer,
for one subnet in Subnets or SubnetMappings, with or without Type,
and for one subnet that does not exist. A Network or Gateway Load
Balancer on one subnet is still created.
- The tests that sent an Application Load Balancer one missing subnet
to get SubnetNotFound now send it an existing subnet as well, or ask
for a Network Load Balancer, so they still reach the subnet lookup.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elbv2): answer a single-subnet ALB with ValidationError
CreateLoadBalancer for an Application Load Balancer with one subnet
now answers ValidationError (400) "At least two subnets in two
different Availability Zones must be specified", as AWS does, instead
of InvalidConfigurationRequest with a message of Floci's own.
requireSubnets, which already refused a balancer with no subnets this
way, now refuses an Application Load Balancer with fewer than two. It
runs before any subnet is looked up, so one subnet that does not exist
gets the same answer, as on AWS. One SubnetMappings entry goes through
the same check, following the rule the API reference states for both
fields. CloudFormation creates and replacements go through it too.
A Network or Gateway Load Balancer on one subnet is still created.
SetSubnets with one subnet and two subnets in one Availability Zone
keep their InvalidConfigurationRequest answers.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): cover a one-subnet ALB replacement
Review follow-ups:
- CloudFormationElbV2ReplacementIntegrationTest renames an Application
Load Balancer onto one subnet: the update rolls back with
CreateLoadBalancer's ValidationError, no balancer gets the new name,
and the one it was to replace keeps both subnets.
- ElbV2CfnProvisioner's Javadoc no longer says a blank SubnetId is
refused as an unknown subnet, since an Application Load Balancer
with only that mapping now gets the subnet count error first.
- ElbV2ServiceTest says why its one-subnet test stubs a lookup that it
then expects never to happen.
- Ec2DescribeSubnetsNotFoundTest says the missing subnet is sent
alongside an existing one, rather than that its position matters.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the one-subnet NLB and GWLB test its own order
Review follow-up: the test
createLoadBalancerOnOneSubnetIsAllowedForNetworkAndGatewayLoadBalancers
shared @Order(12) with
createLoadBalancerWithOneSubnetIsAValidationError, so JUnit ran the two
in no defined order. It now runs at @Order(78), after the other load
balancer subnet tests. Neither test depends on the other: each uses
its own load balancer names, and the network and gateway one deletes
the balancers it creates.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): move the one-subnet NLB and GWLB test to order 79
The draft #6100 adds
setSubnetsWithNeitherSubnetsNorSubnetMappingsIsRefused at @Order(78)
in the same class, and the two branches merge without a conflict, so
whichever lands second would bring back a shared order. 79 is unused
on main and on both branches; no other order changes.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the tests' subnetless load balancers subnets
CreateLoadBalancer takes Subnets or SubnetMappings for every load
balancer type, and AWS refuses a request with neither. Tests that
created a balancer with neither, to exercise listeners, the data plane,
CodeDeploy, API Gateway or CloudFormation, now give it two default
subnets: the src/test classes through Ec2Service.defaultSubnetId, the
Java compatibility suite through a new TestFixtures.defaultVpcSubnets.
setSubnetsAfterSubnetlessCreateCanAdoptCustomVpc becomes
setSubnetsInAnotherVpcIsRefused, since a balancer created with subnets
keeps its VPC. The adoption it covered still applies to a balancer an
earlier version saved without subnets, and ElbV2ServiceTest now covers
that.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(elbv2): refuse CreateLoadBalancer with neither Subnets nor SubnetMappings
A CreateLoadBalancer that named neither Subnets nor SubnetMappings made
a load balancer with no Availability Zone and no VPC, where the API
reference says every type takes one or the other. It now answers
ValidationError and creates nothing, with the message AWS gives for the
type: "At least two subnets in two different Availability Zones must be
specified" for an Application Load Balancer, "At least one subnet must
be specified" for a Network or Gateway Load Balancer. A CloudFormation
load balancer with neither fails its stack the same way.
The check runs after the duplicate-name check, because a stack update
finds the balancer it keeps through DuplicateLoadBalancerName whatever
subnets its template names. A balancer an earlier version saved without
subnets still works, and its first SetSubnets still gives it a VPC.
Follow-up to the review of #5881.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* refactor(elbv2): take a request's Subnets or SubnetMappings from ElbV2Service
The rule that Subnets and SubnetMappings are alternatives, and its
ValidationError, was written out three times: in the Query handler's
CreateLoadBalancer and SetSubnets, and in the CloudFormation
provisioner. ElbV2Service.requestedSubnets now holds it, and all three
take the request's subnets from there. Valid requests resolve the same
subnets as before, and both together are still refused with the same
error.
A new test pins the SetSubnets path, which had none.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(elbv2): say when CloudFormation refuses a load balancer without subnets
The behaviour note said a CloudFormation load balancer with neither
Subnets nor SubnetMappings fails its stack the same way as the API
does. That holds when the stack creates or replaces the balancer. An
update that keeps the balancer finds it by its taken name before the
subnet check, so it leaves the balancer on its subnets, as before.
The note now says so.
The requireSubnets Javadoc no longer presents the Gateway Load
Balancer message as AWS's own. No public record of it was found; it
is the Network Load Balancer one, since a Gateway Load Balancer takes
subnets the same way.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): give the remaining subnetless test requests subnets
Review follow-ups:
- The two duplicate-name tests, ElbV2IntegrationTest and the
compatibility suite's ElbV2Test, sent a create with no subnets, so
they passed only because the name is checked first. They now name
subnets. The compatibility one also changes the scheme, because AWS
answers a create that repeats a balancer's settings with success.
- ElbV2CfnProvisionerTest's successful creates and replacements now
provision templates with two subnets and match them, rather than a
subnetless create the real service refuses. The kept-balancer
updates keep their subnetless templates.
- The CloudFormation case that leaves both properties out checks that
its template really has no SubnetMappings, so a reformatted template
cannot quietly turn it into the empty-list case.
- TestFixtures.defaultVpcSubnets() fails with a message when the
region has no default VPC or fewer than two default subnets.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(elbv2): say which subnet messages are AWS's in the test docs
Second-round review follow-ups, wording only:
- The ELBv2 unit and Query-protocol tests of a create with neither
Subnets nor SubnetMappings now say the messages are the ones AWS
gives an Application or a Network Load Balancer, and that a Gateway
Load Balancer gets the Network one, as the service's Javadoc does.
- The provisioner test's onTwoSubnets builds its list from TWO_SUBNETS,
the list its stubs match, and its Javadoc no longer reads as two
subnets for every type.
- TestFixtures.defaultVpcSubnets() says an Application Load Balancer
needs two zones, not every load balancer.
- The ELBv2 docs say a CloudFormation update moves a balancer when it
names other subnets, since one that names none leaves it in place.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* feat(elbv2): serve HTTPS listeners with ACM and IAM certificates
Route HTTPS traffic with SNI and refresh certificates when they change.
* fix(elbv2): preserve attached ACM certificates
Refuse revocation while a listener uses the certificate and keep
certificate listings responsive when many listeners are configured.
* fix(elbv2): protect subnets and VPCs that load balancers use
DeleteSubnet and DeleteVpc returned success while an Application or
Network Load Balancer still used the subnet, and DescribeLoadBalancers
went on listing a subnet that no longer existed. EC2 now asks each
VpcDependencyProvider, implemented by ELBv2, before deleting a subnet or
VPC, under the lock CreateLoadBalancer and SetSubnets hold while they
record their subnets, and refuses with DependencyViolation. Covered end to
end through CloudFormation, including updates, rollbacks and stack
deletes that move or delete load balancers, subnets and VPCs.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): record the subnets a load balancer is on
A load balancer's attributes named none of its subnets, so once a
template stopped naming it, the stack walks had nothing to order it by
and deleted it after them, which EC2 now refuses. The provisioner keeps
one hidden uses attribute per subnet, refreshed when an update moves the
balancer and when a rollback moves it back.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): delete removed resources dependents first
The update cleanup deleted removed and condition-disabled resources in
reverse map order, before the replacement cleanup. A subnet an earlier
update added sits after the load balancer it moved onto it, so removing
both deleted the subnet first, and a renamed balancer's old entity still
used a subnet the same update dropped. Both now end DELETE_FAILED, since
EC2 refuses to delete a subnet a load balancer uses.
The removed resources are now walked in dependency order, and a failed
delete is tried once more after the replacement cleanup before it is
reported.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* docs(ec2): name every ELBv2 load balancer type as a subnet dependency
The DeleteSubnet and DeleteVpc rows named only Application and Network
Load Balancers, while the check counts every ELBv2 type. The SDK
lifecycle test now deletes its subnets and VPC even when an assertion
fails.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudformation): pin the order of the removed-resource deletes
The removal test passed through the retry alone, so it now checks that
the load balancer is deleted before its subnet is tried, and that the
replaced balancer's old entity goes before the dropped subnet. The
provisioner attribute test reads only what Fn::GetAtt can see, with the
balancer on subnets.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
The certificate check on ModifyListener runs twice: once outside IAM's
certificate lock, where it keeps the error precedence AWS has, and once under
the lock, where it is atomic with the write. The second one sat behind the port,
protocol and SSL policy setters, so a DeleteServerCertificate landing between
the two answered CertificateNotFound on a listener that had already moved to its
new port. The comment above the first check says no refusal leaves the listener
changed, which only held for the check it sits on.
Every setter now runs inside the guard, behind the re-check, so a refusal either
lands before anything is written or does not land at all. The guard is still
taken for the certificates the request records, which are the only ones a delete
can race: one the listener already holds is a reference DeleteServerCertificate
finds, and it refuses to delete it. The re-check covers the effective list,
which is what a protocol flip putting the stored certificates into service
needs, so that path is checked under the lock too rather than once on the way
in.
The restartDataPlane local is gone, because a lambda cannot assign a local and
portChanges already says the same thing at the one place it was read.
Two unit tests, both of which fail without the change: a refused modify leaves
the port, protocol, policy and certificates alone and does not restart the data
plane, and a protocol flip refused the same way leaves the protocol alone. The
resolver they wire finds the certificate once and not again, which is what a
delete landing between the two checks looks like from inside the call.
docs/services/elb.md records the guarantee next to the lock it comes from.
Follow-up to the review note on #5474.
A listener stored whatever certificate ARN it was given. CreateListener,
ModifyListener and AddListenerCertificates each model CertificateNotFound,
and all three took an ARN naming nothing and answered 200, so a listener
could be left serving a certificate that was never uploaded. Only the other
direction worked: ELBv2 reports its references to IAM, so
DeleteServerCertificate already refused with DeleteConflict while a listener
held one.
The error is the one AWS publishes on those three operations and no others:
botocore gives CertificateNotFoundException the code CertificateNotFound,
400, senderFault, and the API reference lists it under
AddListenerCertificates, CreateListener and ModifyListener with one
sentence, "The specified certificate does not exist." That sentence is the
message rather than one naming the ARN, because it is the one the reference
publishes.
The check covers the listener types the member belongs to and no more. The
reference marks Certificates "[HTTPS and TLS listeners]" on CreateListener
and ModifyListener, and describes AddListenerCertificates as adding to the
list "for the specified HTTPS or TLS listener", so a certificate on a
listener of any other protocol is a configuration it does not describe. What
AWS answers there is not CertificateNotFound on any evidence to hand, so
such a request keeps the behaviour it had rather than being refused with a
code read off the wrong case. A test pins each side of that line. The line
follows the protocol the listener ends the call with, not the one it started
with: ModifyListener takes a protocol without taking certificates, so when
none arrive the certificates checked are the ones already on file. An HTTP
listener holding an ARN that resolves to nothing is left alone, and the
request that turns it into an HTTPS one, which is where those certificates
start being served, is refused.
A blank entry is refused the same way, rather than skipped. Certificates is
the list of certificates the listener serves, an empty value in it names one
no better than a value that is no ARN at all, and the Query parser turns an
empty CertificateArn parameter into exactly that entry, so skipping it
stored a certificate the listener cannot serve.
ELB Classic already answered this question in full, resolving an ARN to an
IAM server certificate or an ACM one and holding IAM's certificate lock
across the write. This is the second caller, so the three private methods it
kept, certificateExists, iamServerCertificate and acmCertificateExists, move
to CertificateReferenceResolver in core.common and Classic reads them from
there. Neither referrer owns the lookup: IAM holds server certificates, ACM
holds the rest, and a listener carries only the ARN. Classic's public
constructors are untouched, so its unit tests still build it the same way.
The check alone is not enough, which is why the lock moves with it. A
certificate can be deleted between the check and the write, and the delete
walks the reference providers under IAM's own lock, so every write that
records an IAM certificate runs inside that lock and re-checks there, while
the fail-fast check outside it keeps the error precedence. That covers
CreateListener as much as the two writes to a listener already published:
until the new listener is in the map, nothing the delete walks can see that
it holds the certificate. A race test drives each of them against
DeleteServerCertificate over the wire, and with the lock removed they leave
a listener holding a deleted certificate in 1 of 30 trials for
AddListenerCertificates and 4 of 30 for CreateListener, so the guarantee is
measured rather than asserted.
Where the check sits in ModifyListener is part of the fix. The listener it
modifies is the stored object, and the port, protocol and SSL policy were
set before anything could refuse the request, so a refusal answered 400 over
a listener already moved to the new port: no later read put it back, and the
data plane was never restarted to match. Every refusal now lands before the
first setter.
An absent resolver leaves the old behaviour in place. ElbV2Service is wired
by hand in its unit tests, with no IAM and no ACM, and a listener write
there is the write it was before any certificate existed to check. The
dependency is a field rather than a constructor parameter because that is
how this class takes all six of its others, and converting it would be a
refactor this change does not need.
docs/services/elb.md said listener certificate ARNs are not validated when
they are added, which was true and is the behaviour this removes, so it now
documents the three operations, the protocols they cover, the empty value,
the protocol change, the error and the lock, as the Classic page already
does.
Sixteen integration tests cover a missing IAM certificate, a missing ACM
one, a blank entry, a value that is no ARN at all and an ARN of a service
that serves no certificates, an uploaded certificate and an ACM certificate
being accepted, a listener carrying no certificate, a TLS listener held to
the same check as an HTTPS one and a listener of a protocol with no
certificates left alone, a protocol change refused over the certificate it
already held and allowed over one that exists, a second certificate being
added, a refused change leaving the port and protocol as they were, and the
two writes that must refuse without changing what the listener already
serves. Every certificate and load balancer they make is registered for
cleanup: the account's certificate quota is 20 and the Quarkus instance is
shared, so one left behind fails an unrelated class's upload instead of
anything here.
Three things the reference states about these operations stay open, each
wanting an error code no source here gives: CreateListener and
ModifyListener take "exactly one certificate" and AddListenerCertificates
"one certificate per call", where Floci accepts a list; TooManyCertificates
is modeled on all three and no quota is enforced; and
DescribeListenerCertificates is documented to report the default certificate
alongside the list, with IsDefault telling them apart, which Floci does not
model.
Driven through the standard hashicorp/aws provider against a local instance
as well, which is how the change was checked against a real client rather
than only against the suite: an aws_iam_server_certificate and an
aws_lb_listener serving it apply clean, and a listener naming a certificate
nobody uploaded fails with CertificateNotFound and the reference's sentence.
That failure arrives at the end of the provider's create timeout rather than
at once, because the provider retries this error on all three calls, the
AddListenerCertificates one against a constant named iamPropagationTimeout:
real AWS is eventually consistent about a certificate just imported, so a
client waits it out. Floci's storage is immediately consistent and nothing
here models a propagation delay, so the retry simply ends in the refusal.
The same contract is pinned at the SDK boundary too, as eight boto3 tests in
compatibility-tests: the refusal on each of the three operations, the
accepted cases, and both protocol edges. They run in under a second, where
driving the same thing through Terraform in CI costs about a minute for the
accepted case and nearly two for the refusal, almost all of it the
provider's waiter and the retry above rather than anything Floci does. The
suite had no ELB coverage at all before this. Each test takes its load
balancer back out before its certificates, which is the order that frees
them, and test_acm.py's private certificate builder moves to a conftest
fixture taking the common name rather than being copied, since the new file
needs the same pair.
* fix(elbv2): scope SetRulePriorities conflicts to the rule's listener
SetRulePriorities rejected a priority held by any rule in the region, so a
rule on one load balancer could not move to a priority used on another. AWS
scopes rule priorities to a listener ("A listener can't have multiple rules
with the same priority"), as CreateRule already did here.
Conflicts are now checked per listener, against that listener's rules that
are not part of the request. Two rules of the same listener given the same
priority in one request now fail with PriorityInUse instead of both being
applied.
* test(elbv2): keep SetRulePriorities compatibility tests in execution order
* fix(elbv2): check SetRulePriorities collisions against the concurrent rule map
The listener index lists are plain ArrayLists that CreateRule and DeleteRule
mutate without a lock, so iterating them could throw
ConcurrentModificationException. Iterate the region's ConcurrentHashMap and
filter by listener instead.
* fix(elbv2): probe the target group's HealthCheckPort instead of always the traffic port
The health checker always probed each target on its traffic port, so a target
group whose HealthCheckPort names a separate port (an app serving traffic on
one port and its health endpoint on another) was marked unhealthy even though
its health endpoint answered. AWS probes HealthCheckPort when it is a port
number and the target's own port when it is traffic-port, the default.
Health state stays keyed by the traffic port either way.
* fix(elbv2): reject a HealthCheckPort that is not traffic-port or a port from 1 to 65535
* fix(elbv2): dispatch a shared listener port by the hostnames rules declare
Two load balancers with a listener on the same port both answered 502.
Floci serves every load balancer from one socket per port, and listener
selection keyed only on the load balancer's own DNS name, so a request
carrying any other Host header matched neither key. With one load balancer
a size-1 fallback covered that up; adding a second removed the fallback and
silently broke both.
Listener selection now also consults the host-header conditions the
listener's rules already declare. A load balancer that names the hostname it
serves, which is the configuration AWS needs anyway, claims that hostname
here too. The DNS-name match and the single-listener fallback are unchanged
and still take precedence in that order.
A port taken by a second load balancer now logs a warning naming both, since
nothing else reported the collision: the targets behind them stay healthy and
no API call fails.
Real AWS has no load-balancer selection step, because every load balancer has
its own DNS name and addresses; host-header rules only choose a rule inside
one listener. Selecting a listener by Host header is a Floci deviation forced
by the shared socket, and is documented as one.
* test(elbv2): pin the AWS host-header matching semantics selection relies on
The AWS docs state that a hostname is not case-sensitive, that * matches 0
or more characters and ? exactly 1, and that the rule *.example.com matches
test.example.com but not example.com. Listener selection now depends on that
matching, so cover it directly: a case-shifted Host still resolves, and a
wildcard rule does not let its listener claim the bare domain.
Also record that HostHeaderConfig.RegexValues is unsupported, so a load
balancer naming itself only through a regex cannot be selected this way.
Reject link-local and cloud instance-metadata addresses in RegisterTargets with InvalidTarget, and resolve target hosts once in the data plane and health checker, connecting to the checked address. Loopback and private ranges stay reachable so a load balancer can front a neighbouring container.
* feat(elb): implement Classic (v1) Elastic Load Balancing
Classic ELB (2012-06-01) and ELBv2 (2015-12-01) share an endpoint host and
an `elasticloadbalancing` credential scope, but they are different APIs. Every
Classic request was reaching the ELBv2 handler, which rejected a well-formed
one with `ValidationError: Name is required for load balancer.` — because the
name arrived as `LoadBalancerName`, the Classic parameter — and answered a
request that guessed `Name` with an ALB object in the 2015-12-01 namespace, a
shape Classic has no concept of.
Route on the API version. Every Query-protocol request carries the version it
speaks as the `Version` form parameter, and both service models declare it, so
that is the discriminator: 2012-06-01 to the new Classic handler, 2015-12-01 to
ELBv2. This is the same in-case split the `rds` scope already uses to separate
RDS, Neptune and DocumentDB. Requests that omit `Version` fall back to their
parameter shape — an action unique to one API, else `LoadBalancerName` /
`LoadBalancerNames` selecting Classic, else ELBv2 as before.
Classic state is its own model, not the v2 one: keyed by name, no ARN, listeners
inline, and one structured attribute record. Responses follow the 2012-06-01
model's wrapper and element names — `CreateLoadBalancerResult` carries `DNSName`
and nothing else.
Scope is what the AWS provider drives for `aws_elb` and for an Auto Scaling
group attached to one: Create/Delete/DescribeLoadBalancers, the listener
operations, ConfigureHealthCheck, Register/DeregisterInstances,
DescribeInstanceHealth, Modify/DescribeLoadBalancerAttributes, the subnet,
availability-zone and security-group operations, and tagging. The stickiness
and backend-server policy operations, and SetLoadBalancerListenerSSLCertificate,
answer `UnsupportedOperation` in the 2012-06-01 namespace rather than a
fabricated result. There is no Classic data plane: listener ports are recorded
but no socket is opened.
Health is checked per instance from the single `HealthCheck.Target` string —
`HTTP:`/`HTTPS:` probed with a request, `TCP:`/`SSL:` by connecting — with the
same counters and thresholds ElbV2HealthChecker uses. An ASG naming Classic load
balancers in `LoadBalancerNames` now registers and deregisters its instances
with them, so a `min_elb_capacity` wait can be satisfied.
* docs(elb): register ElbClassicQueryHandler in services.yaml
Unblocks 'make docs-check', which fails on rebase without this — the
handler was never registered when the Classic ELB feature landed.
* fix(elb): register ElbClassicService for native init, deregister stale ASG instances from Classic ELBs
ElbClassicService's SecureRandom field wasn't declared under
--initialize-at-run-time, which fails GraalVM native image builds
(image-heap Random instances have cached seeds). Registers it
alongside the other services/*.Service entries in application.yml.
Also closes a gap Greptile flagged: removeStaleInstances() pruned an
ASG's dead instance references without deregistering them from target
groups or named Classic load balancers first, unlike the terminating-
and scale-in paths, leaving orphaned registrations visible through
DescribeLoadBalancers/DescribeInstanceHealth.
* fix(elb): return the documented 409 for a Classic multi-VPC subnet set
CreateLoadBalancer's own Errors table puts InvalidConfigurationRequest at HTTP
409; the Classic path raised it at 400. The error code was already right, so a
client that retries on 409 but fails hard on 400 got the wrong signal from the
one place the two can be told apart. Covered by a unit test that asserts the
status, not just the code.
Also from review: the empty-Listeners ValidationError carried a message copied
from an unrelated subnet/AZ check, and the new cross-reference to the Classic
docs page split elb.md's opening sentence mid-paragraph instead of following it.
* docs: fill supported action descriptions
* docs(elb): describe listener default rule as non-deletable, not immutable
The CreateListener row called the default rule "immutable", which contradicts
the ModifyListener row (updates default actions) and the file's own note that
the rule can be changed via ModifyListener. The rule cannot be deleted or
reprioritized, but its action is mutable, so "non-deletable" is accurate.