mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(rds,docdb): answer DescribeGlobalClusters (#2402)
* feat(rds,docdb): answer DescribeGlobalClusters aws_docdb_cluster reads global cluster information as part of every cluster read, so a cluster that created successfully failed its apply on UnsupportedOperation — created, but not readable. DocumentDB's signing name is rds and the action carries no engine or cluster identifier to route on, so the request reaches RdsQueryHandler whichever service the caller has in mind; the docdb scope Floci also accepts is answered the same way. Global clusters are not modelled, so the list is empty, which is what a live account with none answers. Behaviour follows a live account: MaxRecords outside 20-100 is rejected before the identifier is looked up, a named identifier that does not exist is GlobalClusterNotFoundFault, and a marker is rejected after the identifier. The response is in the RDS namespace, which is the namespace DocumentDB answers in. Filters are accepted without validation: every name AWS accepts answers empty here, and a partial list of accepted names would refuse filters a live account allows. * fix(rds): infer rds for DescribeGlobalClusters on unsigned requests Without a credential scope the service is inferred from the action name, and an action the RDS handler serves but the inference list does not name is dispatched to SQS, which answers UnsupportedOperation for it. * fix(rds): infer rds for every action the RDS handler serves The inference list that routes unsigned Query requests named 32 of the 43 actions RdsQueryHandler dispatches. The other eleven — the cluster parameter groups, the option groups, and both snapshot describes — were dispatched to SQS, which answers UnsupportedOperation for them. The two sets now match exactly: every dispatched action is inferable, and nothing inferable is undispatched. None of the added names appear in another service's inference list, so no existing routing changes.
This commit is contained in:
1 parent
6b628179f3
commit
29b0d600c6
9 files changed
+353
-1
No files matched your search
@@ -367,11 +367,17 @@ public class AwsQueryController {
|
||||
"CreateDBSubnetGroup", "DescribeDBSubnetGroups", "ModifyDBSubnetGroup", "DeleteDBSubnetGroup",
|
||||
"AddTagsToResource", "ListTagsForResource", "RemoveTagsFromResource",
|
||||
"CreateDBCluster", "DescribeDBClusters", "DeleteDBCluster", "ModifyDBCluster",
|
||||
"DescribeGlobalClusters",
|
||||
"CreateDBParameterGroup", "DescribeDBParameterGroups",
|
||||
"DeleteDBParameterGroup", "ModifyDBParameterGroup", "DescribeDBParameters",
|
||||
"DescribeDBProxies", "CreateDBProxy", "ModifyDBProxy", "DeleteDBProxy",
|
||||
"RegisterDBProxyTargets", "DeregisterDBProxyTargets",
|
||||
"DescribeDBProxyTargetGroups", "ModifyDBProxyTargetGroup", "DescribeDBProxyTargets"
|
||||
"DescribeDBProxyTargetGroups", "ModifyDBProxyTargetGroup", "DescribeDBProxyTargets",
|
||||
"CreateDBClusterParameterGroup", "DescribeDBClusterParameterGroups",
|
||||
"ModifyDBClusterParameterGroup", "DeleteDBClusterParameterGroup",
|
||||
"DescribeDBClusterParameters",
|
||||
"CreateOptionGroup", "DescribeOptionGroups", "ModifyOptionGroup", "DeleteOptionGroup",
|
||||
"DescribeDBSnapshots", "DescribeDBClusterSnapshots"
|
||||
);
|
||||
|
||||
private static final Set<String> CLOUDFORMATION_ACTIONS = Set.of(
|
||||
|
||||
@@ -36,6 +36,7 @@ public class DocDbQueryHandler {
|
||||
case "CreateDBCluster" -> handleCreateDbCluster(params);
|
||||
case "DescribeDBClusters" -> handleDescribeDbClusters(params);
|
||||
case "DescribeDBClusterSnapshots" -> handleDescribeDbClusterSnapshots(params);
|
||||
case "DescribeGlobalClusters" -> handleDescribeGlobalClusters(params);
|
||||
case "DeleteDBCluster" -> handleDeleteDbCluster(params);
|
||||
case "ModifyDBCluster" -> handleModifyDbCluster(params);
|
||||
case "CreateDBInstance" -> handleCreateDbInstance(params);
|
||||
@@ -98,6 +99,42 @@ public class DocDbQueryHandler {
|
||||
return Response.ok(AwsQueryResponse.envelope("DescribeDBClusters", AwsNamespaces.RDS, xml.build())).build();
|
||||
}
|
||||
|
||||
private Response handleDescribeGlobalClusters(MultivaluedMap<String, String> params) {
|
||||
// Global clusters are not modeled; an empty list is what completes the provider's read.
|
||||
// Real SDKs sign DocumentDB with the "rds" scope and land on RdsQueryHandler instead;
|
||||
// this serves the "docdb" scope Floci also accepts, and must answer the same way.
|
||||
// MaxRecords is rejected before the identifier is looked up, and a marker after it —
|
||||
// the order a live account applies them in.
|
||||
String maxRecords = params.getFirst("MaxRecords");
|
||||
if (maxRecords != null && !maxRecords.isBlank()) {
|
||||
int max = -1;
|
||||
try {
|
||||
max = Integer.parseInt(maxRecords.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.debugv("Non-numeric MaxRecords {0} on DescribeGlobalClusters", maxRecords);
|
||||
}
|
||||
if (max < 20 || max > 100) {
|
||||
throw new AwsException("InvalidParameterValue",
|
||||
"Invalid value " + maxRecords + " for MaxRecords. Must be between 20 and 100", 400);
|
||||
}
|
||||
}
|
||||
String identifier = params.getFirst("GlobalClusterIdentifier");
|
||||
if (identifier != null && !identifier.isBlank()) {
|
||||
// Naming one is a different question from listing none, and AWS errors on it.
|
||||
throw new AwsException("GlobalClusterNotFoundFault",
|
||||
"Global cluster '" + identifier + "' not found", 404);
|
||||
}
|
||||
// No page is ever handed out, so any marker a caller presents came from somewhere else.
|
||||
String marker = params.getFirst("Marker");
|
||||
if (marker != null && !marker.isBlank()) {
|
||||
throw new AwsException("InvalidParameterValue", "The request token is invalid.", 400);
|
||||
}
|
||||
// Filters are not validated: the answer is empty for every name AWS accepts, and a partial
|
||||
// list of accepted names would reject filters a live account allows.
|
||||
XmlBuilder xml = new XmlBuilder().start("GlobalClusters").end("GlobalClusters");
|
||||
return Response.ok(AwsQueryResponse.envelope("DescribeGlobalClusters", AwsNamespaces.RDS, xml.build())).build();
|
||||
}
|
||||
|
||||
private Response handleDescribeDbClusterSnapshots(MultivaluedMap<String, String> params) {
|
||||
// Snapshots are not modeled by the emulator; return the wire-accurate empty result
|
||||
// the DocDB/RDS Query API uses (empty <DBClusterSnapshots/>, no <Marker>) so SDK
|
||||
|
||||
@@ -95,6 +95,7 @@ public class RdsQueryHandler {
|
||||
case "ModifyDBProxyTargetGroup" -> handleModifyDbProxyTargetGroup(params, region);
|
||||
case "DescribeDBProxyTargets" -> handleDescribeDbProxyTargets(params, region);
|
||||
case "DescribeDBClusterSnapshots" -> handleDescribeDbClusterSnapshots(params);
|
||||
case "DescribeGlobalClusters" -> handleDescribeGlobalClusters(params);
|
||||
case "AddTagsToResource" -> handleAddTagsToResource(params, region);
|
||||
case "ListTagsForResource" -> handleListTagsForResource(params, region);
|
||||
case "RemoveTagsFromResource" -> handleRemoveTagsFromResource(params, region);
|
||||
@@ -1096,6 +1097,41 @@ public class RdsQueryHandler {
|
||||
return xml.build();
|
||||
}
|
||||
|
||||
private Response handleDescribeGlobalClusters(MultivaluedMap<String, String> params) {
|
||||
// Global clusters are not modeled. Both providers read this on every cluster read, and
|
||||
// DocumentDB signs with the "rds" scope, so this handler answers for either service.
|
||||
// MaxRecords is rejected before the identifier is looked up, and a marker after it —
|
||||
// the order a live account applies them in.
|
||||
String maxRecords = params.getFirst("MaxRecords");
|
||||
if (maxRecords != null && !maxRecords.isBlank()) {
|
||||
int max = -1;
|
||||
try {
|
||||
max = Integer.parseInt(maxRecords.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
LOG.debugv("Non-numeric MaxRecords {0} on DescribeGlobalClusters", maxRecords);
|
||||
}
|
||||
if (max < 20 || max > 100) {
|
||||
throw new AwsException("InvalidParameterValue",
|
||||
"Invalid value " + maxRecords + " for MaxRecords. Must be between 20 and 100", 400);
|
||||
}
|
||||
}
|
||||
String identifier = params.getFirst("GlobalClusterIdentifier");
|
||||
if (identifier != null && !identifier.isBlank()) {
|
||||
// Naming one is a different question from listing none, and AWS errors on it.
|
||||
throw new AwsException("GlobalClusterNotFoundFault",
|
||||
"Global cluster '" + identifier + "' not found", 404);
|
||||
}
|
||||
// No page is ever handed out, so any marker a caller presents came from somewhere else.
|
||||
String marker = params.getFirst("Marker");
|
||||
if (marker != null && !marker.isBlank()) {
|
||||
throw new AwsException("InvalidParameterValue", "The request token is invalid.", 400);
|
||||
}
|
||||
// Filters are not validated: the answer is empty for every name AWS accepts, and a partial
|
||||
// list of accepted names would reject filters a live account allows.
|
||||
String result = new XmlBuilder().start("GlobalClusters").end("GlobalClusters").build();
|
||||
return Response.ok(AwsQueryResponse.envelope("DescribeGlobalClusters", AwsNamespaces.RDS, result)).build();
|
||||
}
|
||||
|
||||
private Response handleDescribeDbClusterSnapshots(MultivaluedMap<String, String> params) {
|
||||
// DB cluster snapshots are not modeled; return the RDS Query API's wire-accurate
|
||||
// empty result (empty <DBClusterSnapshots> wrapper, no <Marker>) so SDK clients
|
||||
|
||||
Reference in new issue
Block a user