mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ec2): report an unknown subnet id from DescribeSubnets as an error (#4408)
* fix(ec2): report an unknown subnet id from DescribeSubnets as an error A requested SubnetId that does not exist was dropped from the result instead of raising. An empty list tells the caller the subnet is gone when the id may simply be wrong, and a waiter polling for a subnet it just created cannot tell not-yet from never. describeVpcs already reads its own requested ids this way, so this is the same shape applied to subnets. A describe naming no ids still lists the region. * fix(ec2): raise the unknown subnet id from the query handler, not the service describeSubnets is shared with ELB, ELBv2, DMS, ElastiCache, RDS and others, each of which reads an absent id as its own error. ElbV2Service raises SubnetNotFound and DmsService raises InvalidSubnet, and both are the codes those APIs owe their callers. Raising InvalidSubnetID.NotFound in the service replaced them. Move the per-id check to handleDescribeSubnets so only the EC2 query surface changes, and reuse the existing requireSubnet helper. Assertions now read the XML elements rather than the response text. * test(ec2): validate the unknown subnet id with SDK clients AGENTS.md asks for management APIs to be exercised through an SDK client rather than handcrafted requests alone. Ec2Client.describeSubnets raises InvalidSubnetID.NotFound for a missing id, on its own and mixed with a good one, and resolves the known id. The ELBv2 case pins the regression the query handler placement avoids. With the check in describeSubnets, CreateLoadBalancer answers a missing subnet with InvalidSubnetID.NotFound rather than the SubnetNotFound that API owes its callers, and this test fails. * test(ec2): delete the VPC even when subnet creation fails Creating the subnet outside the try meant a failure there left the VPC behind, which accumulates against persistent storage.
This commit is contained in:
1 parent
b0ad799c5c
commit
49f253d0ec
3 files changed
+168
No files matched your search
@@ -2911,6 +2911,18 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeSubnets(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "SubnetId");
|
||||
Map<String, List<String>> filters = getFilters(p);
|
||||
// A requested id that does not exist is an error, not an omission from the result. Returning
|
||||
// an empty list tells a caller the subnet is gone when the id may simply be wrong, and a
|
||||
// waiter polling for a subnet it just created cannot tell "not yet" from "never".
|
||||
//
|
||||
// The check belongs here rather than in describeSubnets because that method is shared with
|
||||
// ELB, ELBv2, DMS, ElastiCache, RDS and others, each of which reads an absent id as its own
|
||||
// error. ElbV2Service raises SubnetNotFound and DmsService raises InvalidSubnet, and both
|
||||
// are the codes those APIs are supposed to return. Raising in the service would replace
|
||||
// them with this one.
|
||||
for (String subnetId : ids) {
|
||||
service.requireSubnet(region, subnetId);
|
||||
}
|
||||
List<Subnet> subnets = service.describeSubnets(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeSubnetsResponse", AwsNamespaces.EC2)
|
||||
|
||||
Reference in new issue
Block a user