mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(autoscaling): match AWS capacity target validation errors (#7344)
* fix(autoscaling): match AWS capacity target validation errors Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * fix(autoscaling): align sparse target error expectation Preserve sparse-index and rejected-update state assertions while matching the capacity-target validation message. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * test: reuse shared clients for capacity target validation Use AwsTestClients for both SDK clients while retaining the account, region, error matrix and rejected-update state assertions. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> --------- Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
1 parent
a93de121ae
commit
e09ca1abe5
5 files changed
+130
-2
No files matched your search
+12
-1
@@ -91,6 +91,13 @@ public class AutoScalingService implements PassedRoleLookup {
|
||||
+ "capacity-reservations-only, capacity-reservations-first, none, default.";
|
||||
static final String CAPACITY_RESERVATION_TARGET_WITH_NONE_MESSAGE =
|
||||
"You cannot specify a CapacityReservationTarget when CapacityReservationPreference is none.";
|
||||
// AWS returns "Resoure" verbatim; retain it for callers that classify service errors by message.
|
||||
static final String MULTIPLE_CAPACITY_RESERVATION_TARGETS_MESSAGE =
|
||||
"Specifying more than one target CapacityReservationIds or CapacityReservationResoureGroupArns "
|
||||
+ "is not supported.";
|
||||
static final String MIXED_CAPACITY_RESERVATION_TARGETS_MESSAGE =
|
||||
"You can't specify CapacityReservationIds and CapacityReservationResourceGroupArns in the same request. "
|
||||
+ "Remove either CapacityReservationIds or CapacityReservationResourceGroupArns.";
|
||||
static final int MAX_SERVICE_LINKED_ROLE_ARN_LENGTH = 1600;
|
||||
static final int MAX_RESOURCE_NAME_LENGTH = 1600;
|
||||
private static final Pattern CAPACITY_RESERVATION_ID_PATTERN = Pattern.compile("^[A-Za-z0-9\\-_/]+$");
|
||||
@@ -1939,9 +1946,13 @@ public class AutoScalingService implements PassedRoleLookup {
|
||||
if ("none".equals(preference) && specification.hasTarget()) {
|
||||
throw new AwsException("ValidationError", CAPACITY_RESERVATION_TARGET_WITH_NONE_MESSAGE, 400);
|
||||
}
|
||||
if (!specification.getCapacityReservationIds().isEmpty()
|
||||
&& !specification.getCapacityReservationResourceGroupArns().isEmpty()) {
|
||||
throw new AwsException("ValidationError", MIXED_CAPACITY_RESERVATION_TARGETS_MESSAGE, 400);
|
||||
}
|
||||
if (specification.getCapacityReservationIds().size()
|
||||
+ specification.getCapacityReservationResourceGroupArns().size() > 1) {
|
||||
throw new AwsException("ValidationError", "Specify only one Capacity Reservation target.", 400);
|
||||
throw new AwsException("ValidationError", MULTIPLE_CAPACITY_RESERVATION_TARGETS_MESSAGE, 400);
|
||||
}
|
||||
for (String id : specification.getCapacityReservationIds()) {
|
||||
if (id == null || id.isEmpty() || id.length() > 255
|
||||
|
||||
Reference in new issue
Block a user