mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(ecs): complete the operations outside the launch path (#4019)
The operations that are not part of launching a task were the ones ECS answered least like AWS: a listing returned everything at once, a describe dropped what it could not resolve, and several stored less than the request carried. Clusters. CreateCluster and UpdateCluster carry configuration and serviceConnectDefaults, UpdateCluster replaces only the members the request named, and DescribeClusters gates settings, tags, statistics, attachments and configuration on include, reporting the eight documented statistics split by launch type. DeleteCluster refuses a cluster that still has services, container instances or running tasks, with the exception AWS reports for each. Pagination. Every listing pages with maxResults and nextToken behind one shared helper: a hundred per page, ten for ListServices, ten for ListAccountSettings. ListTaskDefinitions lists only ACTIVE revisions by default and orders by family then numeric revision; ListTasks defaults to the running tasks and filters by launch type, container instance and startedBy, which has to be the only filter alongside the cluster scope. Container instances. RegisterContainerInstance keeps what the agent sent, deregistration leaves the instance describable as INACTIVE, UpdateContainerInstancesState moves only between ACTIVE and DRAINING, and DescribeContainerInstances gates tags and health on include. Account settings and attributes. A setting is validated per name, carries its principal and type, and falls back from the principal's own value to the account default to the built-in default under effectiveSettings. An attribute belongs to a cluster and must name a container instance it has. Task sets. A task set needs an EXTERNAL or CODE_DEPLOY service, computes its desired count from the service's, round-trips its networking and load balancers, and needs force to delete before it is scaled to zero. CodeDeploy's call site reports the CODE_DEPLOY startedBy ECS reports. Service deployments and revisions. A deployment is recorded with the revision it targets, the two point at each other, and the service reports the deployment and revision it is currently on. Verified against the AWS SDK for Java v2 and the AWS ECS API reference.
This commit is contained in:
1 parent
cebdc6f2bb
commit
7b29fdcf83
24 files changed
+2761
-195
No files matched your search
@@ -12,15 +12,20 @@ import software.amazon.awssdk.services.ec2.model.DescribeSubnetsRequest;
|
||||
import software.amazon.awssdk.services.ecs.EcsClient;
|
||||
import software.amazon.awssdk.services.ecs.model.AwsVpcConfiguration;
|
||||
import software.amazon.awssdk.services.ecs.model.CapacityProviderStrategyItem;
|
||||
import software.amazon.awssdk.services.ecs.model.Cluster;
|
||||
import software.amazon.awssdk.services.ecs.model.ClusterField;
|
||||
import software.amazon.awssdk.services.ecs.model.Compatibility;
|
||||
import software.amazon.awssdk.services.ecs.model.ContainerDefinition;
|
||||
import software.amazon.awssdk.services.ecs.model.CreateClusterRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DeleteTaskDefinitionsRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DeregisterTaskDefinitionRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DescribeClustersRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DescribeClustersResponse;
|
||||
import software.amazon.awssdk.services.ecs.model.DescribeTaskDefinitionRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DescribeTasksRequest;
|
||||
import software.amazon.awssdk.services.ecs.model.DescribeTasksResponse;
|
||||
import software.amazon.awssdk.services.ecs.model.EcsException;
|
||||
import software.amazon.awssdk.services.ecs.model.KeyValuePair;
|
||||
import software.amazon.awssdk.services.ecs.model.EphemeralStorage;
|
||||
import software.amazon.awssdk.services.ecs.model.LaunchType;
|
||||
import software.amazon.awssdk.services.ecs.model.NetworkConfiguration;
|
||||
@@ -208,8 +213,36 @@ class EcsFargateTest {
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
@DisplayName("DescribeTasks - an unknown reference comes back as MISSING")
|
||||
@DisplayName("DescribeClusters - include gates the optional members and statistics deserialize")
|
||||
void describeClustersHonoursInclude() {
|
||||
Cluster bare = ecs.describeClusters(DescribeClustersRequest.builder()
|
||||
.clusters(clusterName).build()).clusters().get(0);
|
||||
assertThat(bare.statistics()).isEmpty();
|
||||
assertThat(bare.hasStatistics()).isFalse();
|
||||
assertThat(bare.hasTags()).isFalse();
|
||||
|
||||
Cluster full = ecs.describeClusters(DescribeClustersRequest.builder()
|
||||
.clusters(clusterName)
|
||||
.include(ClusterField.STATISTICS, ClusterField.SETTINGS, ClusterField.TAGS,
|
||||
ClusterField.ATTACHMENTS, ClusterField.CONFIGURATIONS)
|
||||
.build()).clusters().get(0);
|
||||
assertThat(full.hasStatistics()).isTrue();
|
||||
assertThat(full.statistics()).extracting(KeyValuePair::name)
|
||||
.contains("runningFargateTasksCount", "runningEC2TasksCount",
|
||||
"activeFargateServiceCount", "drainingEC2ServiceCount");
|
||||
assertThat(full.hasAttachments()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
@DisplayName("DescribeClusters and DescribeTasks - an unknown reference comes back as MISSING")
|
||||
void describeReportsMissingRatherThanDroppingTheReference() {
|
||||
DescribeClustersResponse clusters = ecs.describeClusters(DescribeClustersRequest.builder()
|
||||
.clusters(clusterName, "sdk-no-such-cluster").build());
|
||||
assertThat(clusters.clusters()).hasSize(1);
|
||||
assertThat(clusters.failures()).singleElement()
|
||||
.satisfies(failure -> assertThat(failure.reason()).isEqualTo("MISSING"));
|
||||
|
||||
DescribeTasksResponse tasks = ecs.describeTasks(DescribeTasksRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.tasks("00000000000000000000000000000000")
|
||||
|
||||
@@ -508,7 +508,11 @@ class EcsTests {
|
||||
@Order(25)
|
||||
@DisplayName("PutAttributes - set attributes")
|
||||
void putAttributes() {
|
||||
String targetId = cluster.clusterArn();
|
||||
// An attribute targets a container instance of the cluster; ECS rejects anything else with
|
||||
// a TargetNotFoundException, so this test registers one rather than aiming at the cluster.
|
||||
String targetId = ecs.registerContainerInstance(RegisterContainerInstanceRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.build()).containerInstance().containerInstanceArn();
|
||||
List<Attribute> stored = ecs.putAttributes(PutAttributesRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.attributes(
|
||||
@@ -534,6 +538,14 @@ class EcsTests {
|
||||
.build()).attributes();
|
||||
|
||||
assertThat(deleted).isNotEmpty();
|
||||
|
||||
// The instance existed only as an attribute target. Deregister it, because ECS refuses to
|
||||
// delete a cluster that still has one and the delete-cluster tests below rely on that.
|
||||
ecs.deregisterContainerInstance(DeregisterContainerInstanceRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.containerInstance(targetId)
|
||||
.force(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -919,12 +931,24 @@ class EcsTests {
|
||||
|
||||
@Test
|
||||
@Order(50)
|
||||
@DisplayName("CreateTaskSet - create task set")
|
||||
@DisplayName("CreateTaskSet - the full lifecycle on an EXTERNAL-controller service")
|
||||
void createTaskSet() {
|
||||
// Task sets only exist on a service that uses the EXTERNAL or CODE_DEPLOY deployment
|
||||
// controller; the rolling service the rest of this class uses cannot hold one.
|
||||
String externalService = serviceName + "-external";
|
||||
ecs.createService(CreateServiceRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.serviceName(externalService)
|
||||
.taskDefinition(family + ":1")
|
||||
.desiredCount(3)
|
||||
.deploymentController(dc -> dc.type(DeploymentControllerType.EXTERNAL))
|
||||
.launchType(LaunchType.FARGATE)
|
||||
.build());
|
||||
|
||||
software.amazon.awssdk.services.ecs.model.TaskSet ts =
|
||||
ecs.createTaskSet(CreateTaskSetRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(serviceName)
|
||||
.service(externalService)
|
||||
.taskDefinition(family + ":1")
|
||||
.launchType(LaunchType.FARGATE)
|
||||
.scale(Scale.builder().value(50.0).unit(ScaleUnit.PERCENT).build())
|
||||
@@ -933,6 +957,13 @@ class EcsTests {
|
||||
assertThat(ts).isNotNull();
|
||||
assertThat(ts.taskSetArn()).isNotNull();
|
||||
assertThat(ts.status()).isEqualTo("ACTIVE");
|
||||
// 3 desired at 50 percent is 1.5, which ECS rounds up.
|
||||
assertThat(ts.computedDesiredCount()).isEqualTo(2);
|
||||
// Floci places no tasks for a task set, so it reports steady rather than stabilising
|
||||
// towards a count nothing will reach: a client waiting for stability would never return.
|
||||
assertThat(ts.stabilityStatus()).isEqualTo(StabilityStatus.STEADY_STATE);
|
||||
assertThat(ts.stabilityStatusAt()).isNotNull();
|
||||
assertThat(ts.platformVersion()).isNotBlank();
|
||||
|
||||
String taskSetArn = ts.taskSetArn();
|
||||
|
||||
@@ -940,45 +971,68 @@ class EcsTests {
|
||||
List<software.amazon.awssdk.services.ecs.model.TaskSet> sets =
|
||||
ecs.describeTaskSets(DescribeTaskSetsRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(serviceName)
|
||||
.service(externalService)
|
||||
.taskSets(taskSetArn)
|
||||
.build()).taskSets();
|
||||
|
||||
assertThat(sets).hasSize(1);
|
||||
assertThat(sets.get(0).taskSetArn()).isEqualTo(taskSetArn);
|
||||
|
||||
// An unknown task set is a MISSING failure, not a dropped reference.
|
||||
DescribeTaskSetsResponse missing = ecs.describeTaskSets(DescribeTaskSetsRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(externalService)
|
||||
.taskSets("ecs-svc/does-not-exist")
|
||||
.build());
|
||||
assertThat(missing.taskSets()).isEmpty();
|
||||
assertThat(missing.failures()).singleElement()
|
||||
.satisfies(failure -> assertThat(failure.reason()).isEqualTo("MISSING"));
|
||||
|
||||
// Update task set
|
||||
software.amazon.awssdk.services.ecs.model.TaskSet updated =
|
||||
ecs.updateTaskSet(UpdateTaskSetRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(serviceName)
|
||||
.service(externalService)
|
||||
.taskSet(taskSetArn)
|
||||
.scale(Scale.builder().value(100.0).unit(ScaleUnit.PERCENT).build())
|
||||
.build()).taskSet();
|
||||
|
||||
assertThat(updated).isNotNull();
|
||||
assertThat(updated.scale().value()).isEqualTo(100.0);
|
||||
assertThat(updated.computedDesiredCount()).isEqualTo(3);
|
||||
|
||||
// Update primary task set
|
||||
software.amazon.awssdk.services.ecs.model.TaskSet primary =
|
||||
ecs.updateServicePrimaryTaskSet(UpdateServicePrimaryTaskSetRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(serviceName)
|
||||
.service(externalService)
|
||||
.primaryTaskSet(taskSetArn)
|
||||
.build()).taskSet();
|
||||
|
||||
assertThat(primary).isNotNull();
|
||||
assertThat(primary.status()).isEqualTo("PRIMARY");
|
||||
|
||||
// Delete task set
|
||||
// A task set that has not been scaled down to zero needs force to delete.
|
||||
assertThatThrownBy(() -> ecs.deleteTaskSet(DeleteTaskSetRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(externalService)
|
||||
.taskSet(taskSetArn)
|
||||
.build()))
|
||||
.isInstanceOf(EcsException.class)
|
||||
.hasMessageContaining("scaled down to zero");
|
||||
|
||||
software.amazon.awssdk.services.ecs.model.TaskSet deleted =
|
||||
ecs.deleteTaskSet(DeleteTaskSetRequest.builder()
|
||||
.cluster(clusterName)
|
||||
.service(serviceName)
|
||||
.service(externalService)
|
||||
.taskSet(taskSetArn)
|
||||
.force(true)
|
||||
.build()).taskSet();
|
||||
|
||||
assertThat(deleted).isNotNull();
|
||||
assertThat(deleted.status()).isEqualTo("DRAINING");
|
||||
|
||||
ecs.deleteService(DeleteServiceRequest.builder()
|
||||
.cluster(clusterName).service(externalService).force(true).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,33 @@ what the caller asked for nor what AWS answers.
|
||||
| `PutClusterCapacityProviders` | Associate capacity providers with a cluster |
|
||||
| `DeleteCluster` | Delete an empty cluster |
|
||||
|
||||
A cluster round-trips what it was created with: `settings`, `tags`, `configuration`,
|
||||
`serviceConnectDefaults`, `capacityProviders` and `defaultCapacityProviderStrategy` are all
|
||||
accepted on `CreateCluster` and returned as sent. `UpdateCluster` replaces only the members the
|
||||
request named, leaving the ones it omits alone; `UpdateClusterSettings` replaces `settings`
|
||||
outright.
|
||||
|
||||
`DescribeClusters` returns `settings`, `tags`, `statistics`, `attachments` and `configuration`
|
||||
only when `include` asks for them, one of `SETTINGS`, `TAGS`, `STATISTICS`, `ATTACHMENTS` and
|
||||
`CONFIGURATIONS`; any other value is rejected. A member that was asked for is returned even when
|
||||
it is empty, so a client can tell an empty answer from a withheld one. `STATISTICS` reports the
|
||||
eight documented counts split by launch type (`runningEC2TasksCount`, `runningFargateTasksCount`,
|
||||
`pendingEC2TasksCount`, `pendingFargateTasksCount`, `activeEC2ServiceCount`,
|
||||
`activeFargateServiceCount`, `drainingEC2ServiceCount`, `drainingFargateServiceCount`) as
|
||||
name/value strings. The API reference spells one of those names `RunningFargateTasksCount`; Floci
|
||||
follows the wire, which is lower camel case like the other seven. `ATTACHMENTS` is always an empty
|
||||
list, because Floci creates no managed scaling policies to attach.
|
||||
|
||||
`DescribeClusters` reports a cluster it cannot resolve as a `MISSING` entry in `failures` rather
|
||||
than dropping it, as `DescribeServices` and `DescribeTasks` do. `ListClusters` pages with
|
||||
`maxResults` (1 to 100) and `nextToken`, returning up to 100 ARNs when the request names neither.
|
||||
|
||||
`DeleteCluster` only deletes an empty cluster, and says which way it is not empty:
|
||||
`ClusterContainsServicesException` while a service is still `ACTIVE`,
|
||||
`ClusterContainsContainerInstancesException` while a container instance is still registered, and
|
||||
`ClusterContainsTasksException` while a task is still running. Delete the services, deregister the
|
||||
instances and stop the tasks first, as on AWS.
|
||||
|
||||
### Task Definitions
|
||||
|
||||
| Operation | Description |
|
||||
@@ -78,6 +105,15 @@ call. A deleted revision is not dropped, because AWS keeps describing it and the
|
||||
it keep running; it just cannot start anything new, so `RunTask`, `CreateService` and
|
||||
`UpdateService` refuse it.
|
||||
|
||||
`ListTaskDefinitions` lists only `ACTIVE` revisions unless another `status` is asked for, orders
|
||||
them lexicographically by family and then numerically by revision (`sort: DESC` reverses it, so
|
||||
revision 11 sorts after revision 2 rather than before it), and pages with `maxResults` and
|
||||
`nextToken`.
|
||||
|
||||
`ListTaskDefinitionFamilies` filters on `familyPrefix` and on `status`, where `ACTIVE` keeps the
|
||||
families with at least one ACTIVE revision, `INACTIVE` the families with none, and `ALL` (the
|
||||
default) keeps both. It pages with `maxResults` and `nextToken` the same way.
|
||||
|
||||
At launch, a container's `dependsOn` decides the start order, and a `COMPLETE`, `SUCCESS` or
|
||||
`HEALTHY` condition holds the dependent container until the dependency gets there. The wait is
|
||||
bounded by the dependent container's `startTimeout`, defaulting to 60 seconds rather than AWS's
|
||||
@@ -199,10 +235,26 @@ A created service reports the documented defaults: `propagateTags` is `NONE` and
|
||||
a load-balanced service whose task definition does not use `awsvpc`, which is the only case AWS
|
||||
permits it in.
|
||||
|
||||
A described service always carries `events` and `taskSets`, empty list and all, so a client can
|
||||
tell an empty answer from a member Floci never wrote. `taskSets` holds the service's task sets, the
|
||||
same ones `DescribeTaskSets` returns, which is where a blue/green deploy tool reads them from.
|
||||
`events` is derived from the service's current state rather than replayed from a rollout, the same
|
||||
way `deployments` is: a service that has converged reports the one event tools poll for,
|
||||
`(service <name>) has reached a steady state.`, with an id stable across calls; one still
|
||||
converging reports none. Each `deployments` entry carries the placement it runs under, its
|
||||
`launchType` or `capacityProviderStrategy`, `platformVersion`, `platformFamily` and
|
||||
`networkConfiguration`, not only its id and counts.
|
||||
|
||||
`RunTask` places at most 10 tasks per call and rejects `propagateTags: SERVICE`, which is a
|
||||
service-only option; `TASK_DEFINITION` copies the task definition's tags onto each task.
|
||||
`StartTask` requires the `containerInstances` it places onto, at most 10 of them.
|
||||
|
||||
`ListTasks` filters by `cluster`, `family`, `desiredStatus`, `launchType`, `containerInstance`,
|
||||
`serviceName` and `startedBy`, and pages with `maxResults` and `nextToken` (100 per page by
|
||||
default). The default filter is a desired status of `RUNNING`, so a listing that has not asked for
|
||||
stopped tasks does not get them, `PENDING` matches nothing (ECS never sets that desired status),
|
||||
and `startedBy` has to be the only filter in the request.
|
||||
|
||||
On `UpdateService`, the changes that start new tasks roll the deployment: the task definition, the
|
||||
network configuration, the load balancers, the service registries, the Service Connect
|
||||
configuration, `platformVersion` and `forceNewDeployment`. The ones AWS documents as not
|
||||
@@ -256,6 +308,10 @@ local cluster has no container instances, so an EC2 default would have nowhere t
|
||||
| `ListServices` | List service ARNs in a cluster |
|
||||
| `ListServicesByNamespace` | List services filtered by Cloud Map namespace |
|
||||
|
||||
`ListServices` filters on `launchType` and `schedulingStrategy` as well as `cluster`, and pages
|
||||
with `maxResults` and `nextToken`. Unlike every other ECS listing, which pages a hundred at a
|
||||
time, a request that names no `maxResults` gets ten ARNs and a `nextToken`.
|
||||
|
||||
#### Service deployments
|
||||
|
||||
An `ACTIVE` service reports exactly one `PRIMARY` entry in `services[].deployments`,
|
||||
@@ -297,6 +353,7 @@ Known differences from AWS:
|
||||
given, so a client that reads them back sees no drift, but the reconciler does not act on them:
|
||||
it converges to `desiredCount` without a maximum or minimum percent, registers nothing in Cloud
|
||||
Map, and places tasks without evaluating constraints.
|
||||
- `StopServiceDeployment` is not implemented.
|
||||
|
||||
#### ECS EventBridge events
|
||||
|
||||
@@ -342,6 +399,30 @@ unchanged.
|
||||
| `DescribeTaskSets` | Describe task sets for a service |
|
||||
| `UpdateServicePrimaryTaskSet` | Promote a task set to primary |
|
||||
|
||||
A task set can only be created in a service whose deployment controller is `EXTERNAL` or
|
||||
`CODE_DEPLOY`; a rolling service runs its own deployments, and AWS refuses the call rather than
|
||||
creating a task set nothing will place. `launchType` and `capacityProviderStrategy` are mutually
|
||||
exclusive, and a request naming neither takes the cluster's `defaultCapacityProviderStrategy`,
|
||||
falling back to `EC2`. `scale` accepts only the `PERCENT` unit.
|
||||
|
||||
The task set round-trips `networkConfiguration` (defaulting to the service's), `loadBalancers`,
|
||||
`serviceRegistries`, `platformVersion` and `tags`, and reports `platformFamily`, `startedBy`
|
||||
(`CODE_DEPLOY` for a task set Floci's CodeDeploy created, unset for an external one) and
|
||||
`stabilityStatusAt`. `computedDesiredCount` is the service's `desiredCount` times the task set's
|
||||
scale percentage, always rounded up: 3 desired at 50 percent is 2 tasks, not 1. `UpdateTaskSet`
|
||||
recomputes it.
|
||||
|
||||
Floci places no tasks for a task set, so `runningCount` and `pendingCount` stay at 0 and
|
||||
`stabilityStatus` is always `STEADY_STATE`. On AWS the status reaches `STEADY_STATE` once the
|
||||
running count matches the computed one; reporting `STABILIZING` here would hang anything that
|
||||
waits for the set to stabilise, since no count ever moves.
|
||||
|
||||
`DeleteTaskSet` refuses a task set that has not been scaled down to zero unless `force` is set.
|
||||
`DescribeTaskSets` returns tags only for `include: ["TAGS"]` and reports a reference naming no
|
||||
task set of that service as a `MISSING` failure. A task set reference that resolves to nothing is
|
||||
a `TaskSetNotFoundException`, and task sets are scoped to one cluster and service: another
|
||||
service's task set is not visible through this one.
|
||||
|
||||
### Container Instances
|
||||
|
||||
| Operation | Description |
|
||||
@@ -353,6 +434,32 @@ unchanged.
|
||||
| `UpdateContainerAgent` | Trigger agent update (stub) |
|
||||
| `UpdateContainerInstancesState` | Drain or activate container instances |
|
||||
|
||||
`RegisterContainerInstance` keeps what the agent sent: `totalResources` comes back as both
|
||||
`registeredResources` and `remainingResources`, and `versionInfo`, `attributes`, `tags` and a
|
||||
re-registered `containerInstanceArn` all round-trip. The agent version is reported inside
|
||||
`versionInfo`, which is where the `ContainerInstance` shape puts it, not as a top-level
|
||||
`agentVersion`. An instance also reports `registeredAt` and a `version` counter that each state
|
||||
change increments.
|
||||
|
||||
`DeregisterContainerInstance` leaves the instance in the cluster as `INACTIVE` rather than
|
||||
dropping it, so a later `DescribeContainerInstances` still answers for it, as on AWS. A cluster's
|
||||
`registeredContainerInstancesCount` counts only the `ACTIVE` and `DRAINING` instances.
|
||||
|
||||
`ListContainerInstances` defaults to every instance other than the `INACTIVE` ones, validates
|
||||
`status` against the five documented values, and pages with `maxResults` (1 to 100) and
|
||||
`nextToken`. The cluster query language `filter` is accepted and ignored.
|
||||
|
||||
`UpdateContainerInstancesState` sets only `ACTIVE` or `DRAINING`, takes at most 10 instances per
|
||||
call, and refuses to drain an instance that is not `ACTIVE` first. It and
|
||||
`DescribeContainerInstances` report an instance the cluster does not have as a `MISSING` failure
|
||||
rather than dropping it.
|
||||
|
||||
`DescribeContainerInstances` withholds two members until the request asks for them, and rejects an
|
||||
`include` value that is neither: `TAGS` for the instance's tags, and `CONTAINER_INSTANCE_HEALTH`
|
||||
for its `healthStatus`. Floci runs no agent health checks of its own, so the one check it reports
|
||||
is `AGENT_CONNECTIVITY`, taken from the registration state the instance already tracks, and
|
||||
`overallStatus` follows it.
|
||||
|
||||
### Capacity Providers
|
||||
|
||||
| Operation | Description |
|
||||
@@ -388,6 +495,23 @@ one of the four values `CapacityProviderStatus` takes.
|
||||
| `ListServiceDeployments` | List service deployment ARNs |
|
||||
| `DescribeServiceRevisions` | Describe service revisions |
|
||||
|
||||
A deployment is recorded on `CreateService` and on every `UpdateService` that rolls one, together
|
||||
with the service revision it targets. The two are linked the way AWS links them: a deployment
|
||||
reports `targetServiceRevision` (its ARN and the task counts) and `sourceServiceRevisions`, and
|
||||
the service itself reports `currentServiceDeployment` and `currentServiceRevisions`, so a caller
|
||||
gets from `DescribeServices` to the deployment without listing first. A service deployment carries
|
||||
no `taskDefinition` member, because AWS's `ServiceDeployment` shape has none: the revision names
|
||||
it.
|
||||
|
||||
A service revision is the snapshot of the service's configuration at that moment, copied rather
|
||||
than referenced, so it keeps reporting what the service looked like then: `taskDefinition`, the
|
||||
`launchType` or `capacityProviderStrategy`, `platformVersion`, `platformFamily`,
|
||||
`networkConfiguration`, `loadBalancers`, `serviceRegistries`, `serviceConnectConfiguration` and
|
||||
one `containerImages` entry per container definition. `guardDutyEnabled` is always `false`: Floci
|
||||
runs no runtime monitoring. Floci applies a change in place rather than rolling it, so a
|
||||
deployment is `SUCCESSFUL` with the same `startedAt` and `finishedAt` from the moment it is
|
||||
recorded. Both describes report an ARN that resolves to nothing as a `MISSING` failure.
|
||||
|
||||
### Tags
|
||||
|
||||
| Operation | Description |
|
||||
@@ -412,6 +536,32 @@ parsed map, so 51 entries that collapse to fewer distinct keys are still rejecte
|
||||
| `DeleteAttributes` | Remove attributes from resources |
|
||||
| `ListAttributes` | List resources with a given attribute |
|
||||
|
||||
An account setting name must be one of the eleven ECS accepts, and its value is checked against
|
||||
what that name allows: `0`, `7` or `14` for `fargateTaskRetirementWaitPeriod`, `blocking` or
|
||||
`non-blocking` for `defaultLogDriverMode`, `enhanced` on top of the usual flags for
|
||||
`containerInsights`, and `enabled`/`disabled`/`on`/`off` for the rest. A `Setting` reports its
|
||||
`principalArn` and its `type`, which is `user` except for `guardDutyActivate`, the setting
|
||||
GuardDuty owns on the account's behalf.
|
||||
|
||||
A request that names no `principalArn` acts for the account root, since Floci does not
|
||||
authenticate a separate user, and `PutAccountSettingDefault` writes that same root row: AWS
|
||||
describes the effective value as "the account settings for the root user or the default setting".
|
||||
`ListAccountSettings` returns only the settings the principal explicitly set, which is why an
|
||||
untouched account lists nothing; with `effectiveSettings: true` it returns all eleven at the value
|
||||
that principal actually reads, falling back from its own setting to the root default to the
|
||||
setting's built-in default. It pages with `maxResults` (1 to 10) and `nextToken`, ten at a time.
|
||||
|
||||
A setting is persisted under `<principalArn>::<name>` rather than the name alone, so settings
|
||||
written by an earlier Floci version are ignored after upgrading: delete
|
||||
`ecs-account-settings.json` from the persistence directory, or write the settings again.
|
||||
|
||||
Attributes belong to a cluster, not to a target id alone, so the same container instance id in two
|
||||
clusters is two targets. An attribute must name a container instance the cluster has, or the call
|
||||
is a `TargetNotFoundException`, and a target holds at most 10 custom attributes
|
||||
(`AttributeLimitExceededException` past that, and for a single call carrying more than 10).
|
||||
`ListAttributes` requires `targetType`, whose only valid value is `container-instance`, and pages
|
||||
with `maxResults` (1 to 100) and `nextToken`.
|
||||
|
||||
### Agent / State Change Stubs
|
||||
|
||||
| Operation | Description |
|
||||
|
||||
@@ -1363,8 +1363,10 @@ public class CodeDeployService {
|
||||
createTaskSet.setService(serviceName);
|
||||
createTaskSet.setTaskDefinition(appSpec.taskDefinition);
|
||||
createTaskSet.setScaleValue(100.0);
|
||||
createTaskSet.setScaleUnit("PERCENT");
|
||||
// ECS reports the deployment id as the task set's externalId, and CODE_DEPLOY as
|
||||
// its startedBy, which is how a client tells a CodeDeploy set from an external one.
|
||||
createTaskSet.setExternalId(deploymentId);
|
||||
createTaskSet.setStartedBy("CODE_DEPLOY");
|
||||
greenTaskSet = ecsService.createTaskSet(createTaskSet, region);
|
||||
appendTaskSetInfo(ecsTargetMap, greenTaskSet, greenTgArn, 0.0);
|
||||
finishLifecycleEvent(installEvent, "Succeeded");
|
||||
|
||||
@@ -15,7 +15,9 @@ import io.github.hectorvent.floci.services.ecs.model.ContainerOverride;
|
||||
import io.github.hectorvent.floci.services.ecs.model.CreateClusterRequest;
|
||||
import io.github.hectorvent.floci.services.ecs.model.CreateServiceRequest;
|
||||
import io.github.hectorvent.floci.services.ecs.model.CreateTaskSetRequest;
|
||||
import io.github.hectorvent.floci.services.ecs.model.RegisterContainerInstanceRequest;
|
||||
import io.github.hectorvent.floci.services.ecs.model.EnvironmentFile;
|
||||
import io.github.hectorvent.floci.services.ecs.model.Failure;
|
||||
import io.github.hectorvent.floci.services.ecs.model.EphemeralStorage;
|
||||
import io.github.hectorvent.floci.services.ecs.model.FirelensConfiguration;
|
||||
import io.github.hectorvent.floci.services.ecs.model.HealthCheck;
|
||||
@@ -171,6 +173,8 @@ public class EcsJsonHandler {
|
||||
request.setClusterName(req.has("clusterName") ? req.path("clusterName").asText() : null);
|
||||
request.setTags(parseTagMap(req.path("tags")));
|
||||
request.setSettings(parseClusterSettings(req.path("settings")));
|
||||
request.setConfiguration(parseRawObject(req.path("configuration")));
|
||||
request.setServiceConnectDefaults(parseRawObject(req.path("serviceConnectDefaults")));
|
||||
if (req.has("capacityProviders")) {
|
||||
request.setCapacityProviders(jsonArrayToList(req.path("capacityProviders")));
|
||||
}
|
||||
@@ -185,22 +189,50 @@ public class EcsJsonHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeClusters(JsonNode req, String region) {
|
||||
List<String> ids = jsonArrayToList(req.path("clusters"));
|
||||
List<EcsCluster> found = service.describeClusters(ids, region);
|
||||
List<String> clusterIds = jsonArrayToList(req.path("clusters"));
|
||||
Set<String> include = parseClusterIncludes(req.path("include"));
|
||||
EcsService.DescribeClustersResult found = service.describeClustersDetailed(clusterIds, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
found.forEach(c -> arr.add(writer.clusterNode(c)));
|
||||
found.clusters().forEach(c -> arr.add(writer.clusterNode(c, include)));
|
||||
resp.set("clusters", arr);
|
||||
resp.set("failures", objectMapper.createArrayNode());
|
||||
ArrayNode failures = objectMapper.createArrayNode();
|
||||
found.failures().forEach(f -> failures.add(writer.failureNode(f)));
|
||||
resp.set("failures", failures);
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
/** Rejects an unknown include the way ECS does, rather than silently returning less. */
|
||||
private Set<String> parseClusterIncludes(JsonNode node) {
|
||||
List<String> requested = jsonArrayToList(node);
|
||||
validateIncludes(requested, EcsResponseWriter.ALL_CLUSTER_INCLUDES);
|
||||
return Set.copyOf(requested);
|
||||
}
|
||||
|
||||
/** The two fields DescribeContainerInstances withholds unless the request asks for them. */
|
||||
private static final Set<String> CONTAINER_INSTANCE_INCLUDES =
|
||||
Set.of("TAGS", "CONTAINER_INSTANCE_HEALTH");
|
||||
|
||||
private static void validateIncludes(List<String> requested, Set<String> allowed) {
|
||||
for (String value : requested) {
|
||||
if (!allowed.contains(value)) {
|
||||
throw new AwsException("InvalidParameterException",
|
||||
"Invalid include value: " + value, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Response handleListClusters(JsonNode req, String region) {
|
||||
List<String> arns = service.listClusters(region);
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
EcsService.ListPage page = service.listClusters(maxResults, nextToken, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
arns.forEach(arr::add);
|
||||
page.arns().forEach(arr::add);
|
||||
resp.set("clusterArns", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -215,7 +247,9 @@ public class EcsJsonHandler {
|
||||
private Response handleUpdateCluster(JsonNode req, String region) {
|
||||
String clusterId = req.path("cluster").asText();
|
||||
List<ClusterSetting> settings = parseClusterSettings(req.path("settings"));
|
||||
EcsCluster cluster = service.updateCluster(clusterId, settings, region);
|
||||
EcsCluster cluster = service.updateCluster(clusterId, settings,
|
||||
parseRawObject(req.path("configuration")),
|
||||
parseRawObject(req.path("serviceConnectDefaults")), region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("cluster", writer.clusterNode(cluster));
|
||||
return Response.ok(resp).build();
|
||||
@@ -292,22 +326,40 @@ public class EcsJsonHandler {
|
||||
|
||||
private Response handleListTaskDefinitions(JsonNode req, String region) {
|
||||
String familyPrefix = req.has("familyPrefix") ? req.path("familyPrefix").asText() : null;
|
||||
String status = req.has("status") ? req.path("status").asText() : null;
|
||||
List<String> arns = service.listTaskDefinitions(familyPrefix, status);
|
||||
String status = parseChoice(req, "status", TASK_DEFINITION_STATUSES);
|
||||
String sort = parseChoice(req, "sort", SORT_ORDERS);
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
|
||||
EcsService.ListPage page = service.listTaskDefinitions(familyPrefix, status, sort,
|
||||
maxResults, nextToken);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
arns.forEach(arr::add);
|
||||
page.arns().forEach(arr::add);
|
||||
resp.set("taskDefinitionArns", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private Response handleListTaskDefinitionFamilies(JsonNode req, String region) {
|
||||
String familyPrefix = req.has("familyPrefix") ? req.path("familyPrefix").asText() : null;
|
||||
List<String> families = service.listTaskDefinitionFamilies(familyPrefix);
|
||||
String status = parseChoice(req, "status", FAMILY_STATUSES);
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
|
||||
EcsService.ListPage page = service.listTaskDefinitionFamilies(familyPrefix, status,
|
||||
maxResults, nextToken);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
families.forEach(arr::add);
|
||||
page.arns().forEach(arr::add);
|
||||
resp.set("families", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -409,16 +461,25 @@ public class EcsJsonHandler {
|
||||
private Response handleListTasks(JsonNode req, String region) {
|
||||
ListTasksRequest request = new ListTasksRequest();
|
||||
request.setCluster(req.has("cluster") ? req.path("cluster").asText() : null);
|
||||
request.setContainerInstance(req.hasNonNull("containerInstance")
|
||||
? req.path("containerInstance").asText() : null);
|
||||
request.setDesiredStatus(parseChoice(req, "desiredStatus", DESIRED_STATUSES));
|
||||
request.setFamily(req.has("family") ? req.path("family").asText() : null);
|
||||
request.setDesiredStatus(req.has("desiredStatus") ? req.path("desiredStatus").asText() : null);
|
||||
request.setLaunchType(parseEnum(req, "launchType", LaunchType.class));
|
||||
request.setServiceName(req.has("serviceName") ? req.path("serviceName").asText() : null);
|
||||
request.setStartedBy(req.hasNonNull("startedBy") ? req.path("startedBy").asText() : null);
|
||||
request.setMaxResults(req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null);
|
||||
request.setNextToken(req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null);
|
||||
|
||||
List<String> arns = service.listTasks(request, region);
|
||||
EcsService.ListPage result = service.listTasks(request, region);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
arns.forEach(arr::add);
|
||||
result.arns().forEach(arr::add);
|
||||
resp.set("taskArns", arr);
|
||||
if (result.nextToken() != null) {
|
||||
resp.put("nextToken", result.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -635,12 +696,21 @@ public class EcsJsonHandler {
|
||||
|
||||
private Response handleListServices(JsonNode req, String region) {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
List<String> arns = service.listServices(cluster, region);
|
||||
LaunchType launchType = parseEnum(req, "launchType", LaunchType.class);
|
||||
String schedulingStrategy = parseChoice(req, "schedulingStrategy", SCHEDULING_STRATEGIES);
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
|
||||
EcsService.ListPage page = service.listServices(cluster, launchType, schedulingStrategy,
|
||||
maxResults, nextToken, region);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
arns.forEach(arr::add);
|
||||
page.arns().forEach(arr::add);
|
||||
resp.set("serviceArns", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -682,42 +752,51 @@ public class EcsJsonHandler {
|
||||
// ── Account Settings ──────────────────────────────────────────────────────
|
||||
|
||||
private Response handlePutAccountSetting(JsonNode req, String region) {
|
||||
String name = req.path("name").asText();
|
||||
String value = req.path("value").asText();
|
||||
var entry = service.putAccountSetting(name, value);
|
||||
EcsService.AccountSetting setting = service.putAccountSetting(
|
||||
req.path("name").asText(), req.path("value").asText(), principalArn(req));
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("setting", writer.settingNode(entry.getKey(), entry.getValue()));
|
||||
resp.set("setting", writer.settingNode(setting));
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private Response handlePutAccountSettingDefault(JsonNode req, String region) {
|
||||
String name = req.path("name").asText();
|
||||
String value = req.path("value").asText();
|
||||
var entry = service.putAccountSettingDefault(name, value);
|
||||
EcsService.AccountSetting setting = service.putAccountSettingDefault(
|
||||
req.path("name").asText(), req.path("value").asText());
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("setting", writer.settingNode(entry.getKey(), entry.getValue()));
|
||||
resp.set("setting", writer.settingNode(setting));
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private Response handleDeleteAccountSetting(JsonNode req, String region) {
|
||||
String name = req.path("name").asText();
|
||||
var entry = service.deleteAccountSetting(name);
|
||||
EcsService.AccountSetting setting =
|
||||
service.deleteAccountSetting(req.path("name").asText(), principalArn(req));
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("setting", writer.settingNode(entry.getKey(), entry.getValue()));
|
||||
resp.set("setting", writer.settingNode(setting));
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private Response handleListAccountSettings(JsonNode req, String region) {
|
||||
String filterName = req.has("name") ? req.path("name").asText() : null;
|
||||
String filterValue = req.has("value") ? req.path("value").asText() : null;
|
||||
var settings = service.listAccountSettings(filterName, filterValue);
|
||||
EcsService.AccountSettingPage page = service.listAccountSettings(
|
||||
req.hasNonNull("name") ? req.path("name").asText() : null,
|
||||
req.hasNonNull("value") ? req.path("value").asText() : null,
|
||||
principalArn(req),
|
||||
req.path("effectiveSettings").asBoolean(false),
|
||||
req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null,
|
||||
req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
settings.forEach(e -> arr.add(writer.settingNode(e.getKey(), e.getValue())));
|
||||
page.settings().forEach(s -> arr.add(writer.settingNode(s)));
|
||||
resp.set("settings", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private static String principalArn(JsonNode req) {
|
||||
return req.hasNonNull("principalArn") ? req.path("principalArn").asText() : null;
|
||||
}
|
||||
|
||||
// ── Attributes ────────────────────────────────────────────────────────────
|
||||
|
||||
private Response handlePutAttributes(JsonNode req, String region) {
|
||||
@@ -744,25 +823,44 @@ public class EcsJsonHandler {
|
||||
|
||||
private Response handleListAttributes(JsonNode req, String region) {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
String targetType = req.has("targetType") ? req.path("targetType").asText() : null;
|
||||
String attributeName = req.has("attributeName") ? req.path("attributeName").asText() : null;
|
||||
String attributeValue = req.has("attributeValue") ? req.path("attributeValue").asText() : null;
|
||||
List<Attribute> result = service.listAttributes(cluster, targetType, attributeName, attributeValue, region);
|
||||
String targetType = req.hasNonNull("targetType") ? req.path("targetType").asText() : null;
|
||||
String attributeName = req.hasNonNull("attributeName") ? req.path("attributeName").asText() : null;
|
||||
String attributeValue = req.hasNonNull("attributeValue") ? req.path("attributeValue").asText() : null;
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
|
||||
EcsService.ListAttributesPage page = service.listAttributes(cluster, targetType,
|
||||
attributeName, attributeValue, maxResults, nextToken, region);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
result.forEach(a -> arr.add(writer.attributeNode(a)));
|
||||
page.attributes().forEach(a -> arr.add(writer.attributeNode(a)));
|
||||
resp.set("attributes", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
// ── Container Instances ───────────────────────────────────────────────────
|
||||
|
||||
private Response handleRegisterContainerInstance(JsonNode req, String region) {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
String instanceIdentityDocument = req.has("instanceIdentityDocument")
|
||||
? req.path("instanceIdentityDocument").asText() : null;
|
||||
List<Attribute> attrs = parseAttributes(req.path("attributes"));
|
||||
ContainerInstance instance = service.registerContainerInstance(cluster, instanceIdentityDocument, attrs, region);
|
||||
RegisterContainerInstanceRequest request = new RegisterContainerInstanceRequest();
|
||||
request.setCluster(req.has("cluster") ? req.path("cluster").asText() : null);
|
||||
request.setContainerInstanceArn(req.hasNonNull("containerInstanceArn")
|
||||
? req.path("containerInstanceArn").asText() : null);
|
||||
request.setInstanceIdentityDocument(req.hasNonNull("instanceIdentityDocument")
|
||||
? req.path("instanceIdentityDocument").asText() : null);
|
||||
request.setAttributes(parseAttributes(req.path("attributes")));
|
||||
if (req.has("totalResources")) {
|
||||
request.setTotalResources(parseRawObjectList(req.path("totalResources")));
|
||||
}
|
||||
request.setVersionInfo(parseRawObject(req.path("versionInfo")));
|
||||
if (req.has("platformDevices")) {
|
||||
request.setPlatformDevices(parseRawObjectList(req.path("platformDevices")));
|
||||
}
|
||||
request.setTags(parseTagMap(req.path("tags")));
|
||||
ContainerInstance instance = service.registerContainerInstance(request, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
resp.set("containerInstance", writer.containerInstanceNode(instance));
|
||||
return Response.ok(resp).build();
|
||||
@@ -781,23 +879,37 @@ public class EcsJsonHandler {
|
||||
private Response handleDescribeContainerInstances(JsonNode req, String region) {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
List<String> instanceRefs = jsonArrayToList(req.path("containerInstances"));
|
||||
List<ContainerInstance> found = service.describeContainerInstances(cluster, instanceRefs, region);
|
||||
List<String> include = jsonArrayToList(req.path("include"));
|
||||
validateIncludes(include, CONTAINER_INSTANCE_INCLUDES);
|
||||
boolean includeTags = include.contains("TAGS");
|
||||
boolean includeHealth = include.contains("CONTAINER_INSTANCE_HEALTH");
|
||||
EcsService.DescribeContainerInstancesResult found =
|
||||
service.describeContainerInstancesDetailed(cluster, instanceRefs, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
found.forEach(ci -> arr.add(writer.containerInstanceNode(ci)));
|
||||
found.instances().forEach(ci ->
|
||||
arr.add(writer.containerInstanceNode(ci, includeTags, includeHealth)));
|
||||
resp.set("containerInstances", arr);
|
||||
resp.set("failures", objectMapper.createArrayNode());
|
||||
ArrayNode failures = objectMapper.createArrayNode();
|
||||
found.failures().forEach(f -> failures.add(writer.failureNode(f)));
|
||||
resp.set("failures", failures);
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
private Response handleListContainerInstances(JsonNode req, String region) {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
String status = req.has("status") ? req.path("status").asText() : null;
|
||||
List<String> arns = service.listContainerInstances(cluster, status, region);
|
||||
String status = parseChoice(req, "status", CONTAINER_INSTANCE_STATUSES);
|
||||
Integer maxResults = req.hasNonNull("maxResults") ? req.path("maxResults").asInt() : null;
|
||||
String nextToken = req.hasNonNull("nextToken") ? req.path("nextToken").asText() : null;
|
||||
EcsService.ListPage page =
|
||||
service.listContainerInstances(cluster, status, maxResults, nextToken, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
arns.forEach(arr::add);
|
||||
page.arns().forEach(arr::add);
|
||||
resp.set("containerInstanceArns", arr);
|
||||
if (page.nextToken() != null) {
|
||||
resp.put("nextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -814,12 +926,15 @@ public class EcsJsonHandler {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
List<String> instanceRefs = jsonArrayToList(req.path("containerInstances"));
|
||||
String status = req.path("status").asText();
|
||||
List<ContainerInstance> updated = service.updateContainerInstancesState(cluster, instanceRefs, status, region);
|
||||
EcsService.UpdateContainerInstancesStateResult updated =
|
||||
service.updateContainerInstancesState(cluster, instanceRefs, status, region);
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
updated.forEach(ci -> arr.add(writer.containerInstanceNode(ci)));
|
||||
updated.instances().forEach(ci -> arr.add(writer.containerInstanceNode(ci)));
|
||||
resp.set("containerInstances", arr);
|
||||
resp.set("failures", objectMapper.createArrayNode());
|
||||
ArrayNode failures = objectMapper.createArrayNode();
|
||||
updated.failures().forEach(f -> failures.add(writer.failureNode(f)));
|
||||
resp.set("failures", failures);
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -875,9 +990,21 @@ public class EcsJsonHandler {
|
||||
request.setService(req.path("service").asText());
|
||||
request.setTaskDefinition(req.path("taskDefinition").asText());
|
||||
request.setLaunchType(parseEnum(req, "launchType", LaunchType.class));
|
||||
request.setScaleValue(req.path("scale").path("value").asDouble(100.0));
|
||||
request.setScaleUnit(req.path("scale").path("unit").asText("PERCENT"));
|
||||
request.setCapacityProviderStrategy(
|
||||
parseCapacityProviderStrategy(req.path("capacityProviderStrategy")));
|
||||
request.setPlatformVersion(req.hasNonNull("platformVersion")
|
||||
? req.path("platformVersion").asText() : null);
|
||||
if (req.hasNonNull("scale")) {
|
||||
request.setScaleValue(req.path("scale").path("value").asDouble(100.0));
|
||||
request.setScaleUnit(req.path("scale").hasNonNull("unit")
|
||||
? req.path("scale").path("unit").asText() : null);
|
||||
}
|
||||
request.setExternalId(req.has("externalId") ? req.path("externalId").asText() : null);
|
||||
request.setNetworkConfiguration(parseNetworkConfiguration(req.path("networkConfiguration")));
|
||||
request.setLoadBalancers(parseLoadBalancers(req.path("loadBalancers")));
|
||||
request.setServiceRegistries(req.has("serviceRegistries")
|
||||
? parseRawObjectList(req.path("serviceRegistries")) : null);
|
||||
request.setTags(parseTagMap(req.path("tags")));
|
||||
|
||||
TaskSet ts = service.createTaskSet(request, region);
|
||||
|
||||
@@ -891,7 +1018,8 @@ public class EcsJsonHandler {
|
||||
String svc = req.path("service").asText();
|
||||
String taskSet = req.path("taskSet").asText();
|
||||
double scaleValue = req.path("scale").path("value").asDouble(100.0);
|
||||
String scaleUnit = req.path("scale").path("unit").asText("PERCENT");
|
||||
String scaleUnit = req.path("scale").hasNonNull("unit")
|
||||
? req.path("scale").path("unit").asText() : null;
|
||||
|
||||
TaskSet ts = service.updateTaskSet(cluster, svc, taskSet, scaleValue, scaleUnit, region);
|
||||
|
||||
@@ -917,13 +1045,18 @@ public class EcsJsonHandler {
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
String svc = req.path("service").asText();
|
||||
List<String> taskSetRefs = req.has("taskSets") ? jsonArrayToList(req.path("taskSets")) : null;
|
||||
boolean includeTags = jsonArrayToList(req.path("include")).contains("TAGS");
|
||||
|
||||
List<TaskSet> found = service.describeTaskSets(cluster, svc, taskSetRefs, region);
|
||||
EcsService.DescribeTaskSetsResult found =
|
||||
service.describeTaskSetsDetailed(cluster, svc, taskSetRefs, region);
|
||||
|
||||
ObjectNode resp = objectMapper.createObjectNode();
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
found.forEach(ts -> arr.add(writer.taskSetNode(ts)));
|
||||
found.taskSets().forEach(ts -> arr.add(writer.taskSetNode(ts, includeTags)));
|
||||
resp.set("taskSets", arr);
|
||||
ArrayNode failures = objectMapper.createArrayNode();
|
||||
found.failures().forEach(f -> failures.add(writer.failureNode(f)));
|
||||
resp.set("failures", failures);
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -948,9 +1081,20 @@ public class EcsJsonHandler {
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
found.forEach(d -> arr.add(writer.serviceDeploymentNode(d)));
|
||||
resp.set("serviceDeployments", arr);
|
||||
resp.set("failures", missingFailures(arns,
|
||||
found.stream().map(ServiceDeployment::getServiceDeploymentArn).toList()));
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
/** The references that resolved to nothing, reported as ECS reports them rather than dropped. */
|
||||
private ArrayNode missingFailures(List<String> requested, List<String> resolved) {
|
||||
ArrayNode failures = objectMapper.createArrayNode();
|
||||
requested.stream()
|
||||
.filter(arn -> !resolved.contains(arn))
|
||||
.forEach(arn -> failures.add(writer.failureNode(Failure.missing(arn))));
|
||||
return failures;
|
||||
}
|
||||
|
||||
private Response handleListServiceDeployments(JsonNode req, String region) {
|
||||
String svc = req.path("service").asText();
|
||||
String cluster = req.has("cluster") ? req.path("cluster").asText() : null;
|
||||
@@ -967,7 +1111,11 @@ public class EcsJsonHandler {
|
||||
brief.put("clusterArn", d.getClusterArn());
|
||||
brief.put("status", d.getStatus());
|
||||
if (d.getCreatedAt() != null) { brief.put("createdAt", d.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getUpdatedAt() != null) { brief.put("finishedAt", d.getUpdatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getStartedAt() != null) { brief.put("startedAt", d.getStartedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getFinishedAt() != null) { brief.put("finishedAt", d.getFinishedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getTargetServiceRevisionArn() != null) {
|
||||
brief.put("targetServiceRevisionArn", d.getTargetServiceRevisionArn());
|
||||
}
|
||||
arr.add(brief);
|
||||
});
|
||||
resp.set("serviceDeployments", arr);
|
||||
@@ -981,6 +1129,8 @@ public class EcsJsonHandler {
|
||||
ArrayNode arr = objectMapper.createArrayNode();
|
||||
found.forEach(r -> arr.add(writer.serviceRevisionNode(r)));
|
||||
resp.set("serviceRevisions", arr);
|
||||
resp.set("failures", missingFailures(arns,
|
||||
found.stream().map(ServiceRevision::getServiceRevisionArn).toList()));
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
@@ -1540,10 +1690,17 @@ public class EcsJsonHandler {
|
||||
Set.of("EC2", "FARGATE", "EXTERNAL", "MANAGED_INSTANCES");
|
||||
private static final Set<String> PID_MODES = Set.of("host", "task");
|
||||
private static final Set<String> IPC_MODES = Set.of("host", "task", "none");
|
||||
private static final Set<String> CONTAINER_INSTANCE_STATUSES =
|
||||
Set.of("ACTIVE", "DRAINING", "REGISTERING", "DEREGISTERING", "REGISTRATION_FAILED");
|
||||
private static final Set<String> SCHEDULING_STRATEGIES = Set.of("REPLICA", "DAEMON");
|
||||
private static final Set<String> DEPLOYMENT_CONTROLLER_TYPES = Set.of("ECS", "CODE_DEPLOY", "EXTERNAL");
|
||||
private static final Set<String> AZ_REBALANCING = Set.of("ENABLED", "DISABLED");
|
||||
private static final Set<String> PROPAGATE_TAGS = Set.of("TASK_DEFINITION", "SERVICE", "NONE");
|
||||
private static final Set<String> DESIRED_STATUSES = Set.of("RUNNING", "PENDING", "STOPPED");
|
||||
private static final Set<String> TASK_DEFINITION_STATUSES =
|
||||
Set.of("ACTIVE", "INACTIVE", "DELETE_IN_PROGRESS");
|
||||
private static final Set<String> SORT_ORDERS = Set.of("ASC", "DESC");
|
||||
private static final Set<String> FAMILY_STATUSES = Set.of("ACTIVE", "INACTIVE", "ALL");
|
||||
private static final Set<String> DEPENDENCY_CONDITIONS = Set.of(
|
||||
ContainerDependency.START, ContainerDependency.COMPLETE,
|
||||
ContainerDependency.SUCCESS, ContainerDependency.HEALTHY);
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.services.ecs.model.CapacityProviderStrategyIte
|
||||
import io.github.hectorvent.floci.services.ecs.model.Container;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ContainerDefinition;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ContainerDependency;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ContainerImage;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ContainerInstance;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ContainerOverride;
|
||||
import io.github.hectorvent.floci.services.ecs.model.Deployment;
|
||||
@@ -30,6 +31,7 @@ import io.github.hectorvent.floci.services.ecs.model.ProtectedTask;
|
||||
import io.github.hectorvent.floci.services.ecs.model.RuntimePlatform;
|
||||
import io.github.hectorvent.floci.services.ecs.model.Secret;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ServiceDeployment;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ServiceEvent;
|
||||
import io.github.hectorvent.floci.services.ecs.model.ServiceRevision;
|
||||
import io.github.hectorvent.floci.services.ecs.model.TaskDefinition;
|
||||
import io.github.hectorvent.floci.services.ecs.model.TaskNetworkInterface;
|
||||
@@ -47,6 +49,7 @@ import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Renders ECS domain objects to the JSON 1.1 shapes the data plane returns.
|
||||
@@ -69,7 +72,25 @@ public class EcsResponseWriter {
|
||||
|
||||
// ── Clusters ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* The include values DescribeClusters understands. Every operation other than DescribeClusters
|
||||
* returns the cluster whole, so {@link #clusterNode(EcsCluster)} passes all of them.
|
||||
*/
|
||||
public static final Set<String> ALL_CLUSTER_INCLUDES =
|
||||
Set.of("ATTACHMENTS", "CONFIGURATIONS", "SETTINGS", "STATISTICS", "TAGS");
|
||||
|
||||
public ObjectNode clusterNode(EcsCluster c) {
|
||||
return clusterNode(c, ALL_CLUSTER_INCLUDES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a cluster, holding back the members DescribeClusters only returns when the request
|
||||
* asked for them: "If this field is omitted, this information isn't included."
|
||||
*
|
||||
* <p>The gated members are emitted whenever they are asked for, empty array and all, so a
|
||||
* client can tell an empty answer from a withheld one.
|
||||
*/
|
||||
public ObjectNode clusterNode(EcsCluster c, Set<String> include) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("clusterArn", c.getClusterArn());
|
||||
n.put("clusterName", c.getClusterName());
|
||||
@@ -78,7 +99,7 @@ public class EcsResponseWriter {
|
||||
n.put("runningTasksCount", c.getRunningTasksCount());
|
||||
n.put("pendingTasksCount", c.getPendingTasksCount());
|
||||
n.put("activeServicesCount", c.getActiveServicesCount());
|
||||
if (c.getSettings() != null && !c.getSettings().isEmpty()) {
|
||||
if (include.contains("SETTINGS") && c.getSettings() != null && !c.getSettings().isEmpty()) {
|
||||
ArrayNode settings = objectMapper.createArrayNode();
|
||||
c.getSettings().forEach(s -> {
|
||||
ObjectNode sn = objectMapper.createObjectNode();
|
||||
@@ -88,12 +109,36 @@ public class EcsResponseWriter {
|
||||
});
|
||||
n.set("settings", settings);
|
||||
}
|
||||
if (include.contains("STATISTICS")) {
|
||||
ArrayNode statistics = objectMapper.createArrayNode();
|
||||
service.clusterStatistics(c).forEach(kv -> {
|
||||
ObjectNode sn = objectMapper.createObjectNode();
|
||||
sn.put("name", kv.name());
|
||||
sn.put("value", kv.value());
|
||||
statistics.add(sn);
|
||||
});
|
||||
n.set("statistics", statistics);
|
||||
}
|
||||
if (include.contains("ATTACHMENTS")) {
|
||||
// Floci creates no managed scaling policies, so a cluster never has attachments.
|
||||
n.set("attachments", objectMapper.createArrayNode());
|
||||
}
|
||||
if (include.contains("CONFIGURATIONS") && c.getConfiguration() != null) {
|
||||
n.set("configuration", objectMapper.valueToTree(c.getConfiguration()));
|
||||
}
|
||||
if (c.getCapacityProviders() != null) {
|
||||
ArrayNode cp = objectMapper.createArrayNode();
|
||||
c.getCapacityProviders().forEach(cp::add);
|
||||
n.set("capacityProviders", cp);
|
||||
}
|
||||
if (c.getTags() != null && !c.getTags().isEmpty()) {
|
||||
if (c.getDefaultCapacityProviderStrategy() != null) {
|
||||
n.set("defaultCapacityProviderStrategy",
|
||||
objectMapper.valueToTree(c.getDefaultCapacityProviderStrategy()));
|
||||
}
|
||||
if (c.getServiceConnectDefaults() != null) {
|
||||
n.set("serviceConnectDefaults", objectMapper.valueToTree(c.getServiceConnectDefaults()));
|
||||
}
|
||||
if (include.contains("TAGS") && c.getTags() != null && !c.getTags().isEmpty()) {
|
||||
n.set("tags", tagsNode(c.getTags()));
|
||||
}
|
||||
return n;
|
||||
@@ -652,10 +697,41 @@ public class EcsResponseWriter {
|
||||
ArrayNode deployments = objectMapper.createArrayNode();
|
||||
service.deploymentsFor(s).forEach(d -> deployments.add(deploymentNode(d)));
|
||||
n.set("deployments", deployments);
|
||||
// Both are always reported, empty and all: a service under the ECS controller has no task
|
||||
// sets, and one that has not converged yet has no events, and a client has to be able to
|
||||
// tell that from a member the emulator simply never writes.
|
||||
ArrayNode taskSets = objectMapper.createArrayNode();
|
||||
service.taskSetsFor(s).forEach(ts -> taskSets.add(taskSetNode(ts)));
|
||||
n.set("taskSets", taskSets);
|
||||
ArrayNode events = objectMapper.createArrayNode();
|
||||
service.eventsFor(s).forEach(e -> events.add(serviceEventNode(e)));
|
||||
n.set("events", events);
|
||||
// The service points at the deployment and revision it is currently on, which is how a
|
||||
// caller gets from DescribeServices to DescribeServiceDeployments without listing first.
|
||||
ServiceDeployment current = service.currentServiceDeployment(s);
|
||||
if (current != null) {
|
||||
n.put("currentServiceDeployment", current.getServiceDeploymentArn());
|
||||
if (current.getTargetServiceRevisionArn() != null) {
|
||||
ObjectNode revision = objectMapper.createObjectNode();
|
||||
revision.put("arn", current.getTargetServiceRevisionArn());
|
||||
revision.put("requestedTaskCount", s.getDesiredCount());
|
||||
revision.put("runningTaskCount", s.getRunningCount());
|
||||
revision.put("pendingTaskCount", s.getPendingCount());
|
||||
n.set("currentServiceRevisions", objectMapper.createArrayNode().add(revision));
|
||||
}
|
||||
}
|
||||
EcsJsonPassthrough.write(n, s.getUnparsed(), objectMapper);
|
||||
return n;
|
||||
}
|
||||
|
||||
private ObjectNode serviceEventNode(ServiceEvent event) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("id", event.id());
|
||||
putInstant(n, "createdAt", event.createdAt());
|
||||
n.put("message", event.message());
|
||||
return n;
|
||||
}
|
||||
|
||||
private ObjectNode loadBalancerNode(EcsLoadBalancer lb) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
if (lb.getTargetGroupArn() != null) { n.put("targetGroupArn", lb.getTargetGroupArn()); }
|
||||
@@ -691,15 +767,29 @@ public class EcsResponseWriter {
|
||||
n.put("failedTasks", d.getFailedTasks());
|
||||
n.put("rolloutState", d.getRolloutState());
|
||||
n.put("rolloutStateReason", d.getRolloutStateReason());
|
||||
if (d.getLaunchType() != null) { n.put("launchType", d.getLaunchType().name()); }
|
||||
if (d.getCreatedAt() != null) { n.put("createdAt", d.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getUpdatedAt() != null) { n.put("updatedAt", d.getUpdatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getCapacityProviderStrategy() != null && !d.getCapacityProviderStrategy().isEmpty()) {
|
||||
n.set("capacityProviderStrategy",
|
||||
capacityProviderStrategyNode(d.getCapacityProviderStrategy()));
|
||||
} else if (d.getLaunchType() != null) {
|
||||
n.put("launchType", d.getLaunchType().name());
|
||||
}
|
||||
if (d.getPlatformVersion() != null) { n.put("platformVersion", d.getPlatformVersion()); }
|
||||
if (d.getPlatformFamily() != null) { n.put("platformFamily", d.getPlatformFamily()); }
|
||||
if (d.getNetworkConfiguration() != null
|
||||
&& d.getNetworkConfiguration().getAwsvpcConfiguration() != null) {
|
||||
n.set("networkConfiguration",
|
||||
networkConfigurationNode(d.getNetworkConfiguration().getAwsvpcConfiguration()));
|
||||
}
|
||||
putInstant(n, "createdAt", d.getCreatedAt());
|
||||
putInstant(n, "updatedAt", d.getUpdatedAt());
|
||||
if (d.getServiceConnectConfiguration() != null) {
|
||||
n.set("serviceConnectConfiguration", objectMapper.valueToTree(d.getServiceConnectConfiguration()));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// ── Everything else ───────────────────────────────────────────────────────
|
||||
|
||||
public ObjectNode failureNode(Failure f) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("arn", f.arn());
|
||||
@@ -709,25 +799,73 @@ public class EcsResponseWriter {
|
||||
}
|
||||
|
||||
public ObjectNode containerInstanceNode(ContainerInstance ci) {
|
||||
return containerInstanceNode(ci, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param includeTags DescribeContainerInstances returns tags only for {@code include: ["TAGS"]}
|
||||
* @param includeHealth and the health status only for
|
||||
* {@code include: ["CONTAINER_INSTANCE_HEALTH"]}: "If this field is
|
||||
* omitted, tags and container instance health status aren't included in
|
||||
* the response."
|
||||
*/
|
||||
public ObjectNode containerInstanceNode(ContainerInstance ci, boolean includeTags,
|
||||
boolean includeHealth) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("containerInstanceArn", ci.getContainerInstanceArn());
|
||||
n.put("ec2InstanceId", ci.getEc2InstanceId());
|
||||
n.put("status", ci.getStatus());
|
||||
if (ci.getStatusReason() != null) { n.put("statusReason", ci.getStatusReason()); }
|
||||
n.put("runningTasksCount", ci.getRunningTasksCount());
|
||||
n.put("pendingTasksCount", ci.getPendingTasksCount());
|
||||
n.put("agentVersion", ci.getAgentVersion());
|
||||
n.put("agentConnected", ci.isAgentConnected());
|
||||
if (ci.getAgentUpdateStatus() != null) { n.put("agentUpdateStatus", ci.getAgentUpdateStatus()); }
|
||||
if (ci.getCapacityProviderName() != null) {
|
||||
n.put("capacityProviderName", ci.getCapacityProviderName());
|
||||
}
|
||||
n.put("version", ci.getVersion());
|
||||
putInstant(n, "registeredAt", ci.getRegisteredAt());
|
||||
if (ci.getVersionInfo() != null) {
|
||||
n.set("versionInfo", objectMapper.valueToTree(ci.getVersionInfo()));
|
||||
}
|
||||
if (ci.getRegisteredResources() != null) {
|
||||
n.set("registeredResources", objectMapper.valueToTree(ci.getRegisteredResources()));
|
||||
}
|
||||
if (ci.getRemainingResources() != null) {
|
||||
n.set("remainingResources", objectMapper.valueToTree(ci.getRemainingResources()));
|
||||
}
|
||||
if (ci.getAttributes() != null && !ci.getAttributes().isEmpty()) {
|
||||
ArrayNode attrs = objectMapper.createArrayNode();
|
||||
ci.getAttributes().forEach(a -> attrs.add(attributeNode(a)));
|
||||
n.set("attributes", attrs);
|
||||
}
|
||||
if (ci.getTags() != null && !ci.getTags().isEmpty()) {
|
||||
if (includeHealth) {
|
||||
n.set("healthStatus", containerInstanceHealthNode(ci));
|
||||
}
|
||||
if (includeTags && ci.getTags() != null && !ci.getTags().isEmpty()) {
|
||||
n.set("tags", tagsNode(ci.getTags()));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance's health. Floci runs no agent health checks of its own, so the one check it can
|
||||
* answer honestly is {@code AGENT_CONNECTIVITY}, taken from the registration state the
|
||||
* instance already tracks, and the overall status follows it.
|
||||
*/
|
||||
private ObjectNode containerInstanceHealthNode(ContainerInstance ci) {
|
||||
String status = ci.isAgentConnected() ? "OK" : "IMPAIRED";
|
||||
ObjectNode health = objectMapper.createObjectNode();
|
||||
health.put("overallStatus", status);
|
||||
ObjectNode connectivity = objectMapper.createObjectNode();
|
||||
connectivity.put("type", "AGENT_CONNECTIVITY");
|
||||
connectivity.put("status", status);
|
||||
putInstant(connectivity, "lastUpdated", ci.getRegisteredAt());
|
||||
putInstant(connectivity, "lastStatusChange", ci.getRegisteredAt());
|
||||
health.set("details", objectMapper.createArrayNode().add(connectivity));
|
||||
return health;
|
||||
}
|
||||
|
||||
/** @param includeTags DescribeCapacityProviders returns tags only for {@code include: ["TAGS"]}. */
|
||||
public ObjectNode capacityProviderNode(CapacityProvider cp, boolean includeTags) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
@@ -752,6 +890,11 @@ public class EcsResponseWriter {
|
||||
}
|
||||
|
||||
public ObjectNode taskSetNode(TaskSet ts) {
|
||||
return taskSetNode(ts, true);
|
||||
}
|
||||
|
||||
/** @param includeTags DescribeTaskSets returns tags only for {@code include: ["TAGS"]}. */
|
||||
public ObjectNode taskSetNode(TaskSet ts, boolean includeTags) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("id", ts.getId());
|
||||
n.put("taskSetArn", ts.getTaskSetArn());
|
||||
@@ -763,29 +906,79 @@ public class EcsResponseWriter {
|
||||
n.put("pendingCount", ts.getPendingCount());
|
||||
n.put("runningCount", ts.getRunningCount());
|
||||
n.put("stabilityStatus", ts.getStabilityStatus());
|
||||
putInstant(n, "stabilityStatusAt", ts.getStabilityStatusAt());
|
||||
if (ts.getLaunchType() != null) { n.put("launchType", ts.getLaunchType().name()); }
|
||||
if (ts.getCapacityProviderStrategy() != null && !ts.getCapacityProviderStrategy().isEmpty()) {
|
||||
n.set("capacityProviderStrategy",
|
||||
capacityProviderStrategyNode(ts.getCapacityProviderStrategy()));
|
||||
}
|
||||
if (ts.getPlatformVersion() != null) { n.put("platformVersion", ts.getPlatformVersion()); }
|
||||
if (ts.getPlatformFamily() != null) { n.put("platformFamily", ts.getPlatformFamily()); }
|
||||
if (ts.getExternalId() != null) { n.put("externalId", ts.getExternalId()); }
|
||||
if (ts.getStartedBy() != null) { n.put("startedBy", ts.getStartedBy()); }
|
||||
if (ts.getNetworkConfiguration() != null
|
||||
&& ts.getNetworkConfiguration().getAwsvpcConfiguration() != null) {
|
||||
n.set("networkConfiguration",
|
||||
networkConfigurationNode(ts.getNetworkConfiguration().getAwsvpcConfiguration()));
|
||||
}
|
||||
if (ts.getLoadBalancers() != null && !ts.getLoadBalancers().isEmpty()) {
|
||||
ArrayNode lbs = objectMapper.createArrayNode();
|
||||
ts.getLoadBalancers().forEach(lb -> lbs.add(loadBalancerNode(lb)));
|
||||
n.set("loadBalancers", lbs);
|
||||
}
|
||||
if (ts.getServiceRegistries() != null && !ts.getServiceRegistries().isEmpty()) {
|
||||
n.set("serviceRegistries", objectMapper.valueToTree(ts.getServiceRegistries()));
|
||||
}
|
||||
ObjectNode scale = objectMapper.createObjectNode();
|
||||
scale.put("value", ts.getScaleValue());
|
||||
scale.put("unit", ts.getScaleUnit());
|
||||
n.set("scale", scale);
|
||||
if (ts.getCreatedAt() != null) { n.put("createdAt", ts.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (ts.getUpdatedAt() != null) { n.put("updatedAt", ts.getUpdatedAt().toEpochMilli() / 1000.0); }
|
||||
if (ts.getTags() != null && !ts.getTags().isEmpty()) {
|
||||
putInstant(n, "createdAt", ts.getCreatedAt());
|
||||
putInstant(n, "updatedAt", ts.getUpdatedAt());
|
||||
if (includeTags && ts.getTags() != null && !ts.getTags().isEmpty()) {
|
||||
n.set("tags", tagsNode(ts.getTags()));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* A service deployment. AWS's {@code ServiceDeployment} shape carries no
|
||||
* {@code taskDefinition}: the deployment points at the revision it targets, and the revision
|
||||
* names the task definition, so that is the only route reported here.
|
||||
*/
|
||||
public ObjectNode serviceDeploymentNode(ServiceDeployment d) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("serviceDeploymentArn", d.getServiceDeploymentArn());
|
||||
n.put("serviceArn", d.getServiceArn());
|
||||
n.put("clusterArn", d.getClusterArn());
|
||||
n.put("taskDefinition", d.getTaskDefinition());
|
||||
n.put("status", d.getStatus());
|
||||
if (d.getCreatedAt() != null) { n.put("createdAt", d.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getUpdatedAt() != null) { n.put("updatedAt", d.getUpdatedAt().toEpochMilli() / 1000.0); }
|
||||
putInstant(n, "createdAt", d.getCreatedAt());
|
||||
putInstant(n, "startedAt", d.getStartedAt());
|
||||
putInstant(n, "finishedAt", d.getFinishedAt());
|
||||
putInstant(n, "updatedAt", d.getUpdatedAt());
|
||||
if (d.getTargetServiceRevisionArn() != null) {
|
||||
n.set("targetServiceRevision",
|
||||
serviceRevisionSummaryNode(d.getTargetServiceRevisionArn(), d.getServiceArn()));
|
||||
}
|
||||
ArrayNode sources = objectMapper.createArrayNode();
|
||||
if (d.getSourceServiceRevisionArns() != null) {
|
||||
d.getSourceServiceRevisionArns()
|
||||
.forEach(arn -> sources.add(serviceRevisionSummaryNode(arn, d.getServiceArn())));
|
||||
}
|
||||
n.set("sourceServiceRevisions", sources);
|
||||
return n;
|
||||
}
|
||||
|
||||
/** The counts a revision summary reports track the service the revision belongs to. */
|
||||
private ObjectNode serviceRevisionSummaryNode(String revisionArn, String serviceArn) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("arn", revisionArn);
|
||||
EcsServiceModel svc = service.serviceByArn(serviceArn);
|
||||
if (svc != null) {
|
||||
n.put("requestedTaskCount", svc.getDesiredCount());
|
||||
n.put("runningTaskCount", svc.getRunningCount());
|
||||
n.put("pendingTaskCount", svc.getPendingCount());
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -795,8 +988,45 @@ public class EcsResponseWriter {
|
||||
n.put("serviceArn", r.getServiceArn());
|
||||
n.put("clusterArn", r.getClusterArn());
|
||||
n.put("taskDefinition", r.getTaskDefinition());
|
||||
if (r.getLaunchType() != null) { n.put("launchType", r.getLaunchType().name()); }
|
||||
if (r.getCreatedAt() != null) { n.put("createdAt", r.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (r.getCapacityProviderStrategy() != null && !r.getCapacityProviderStrategy().isEmpty()) {
|
||||
n.set("capacityProviderStrategy",
|
||||
capacityProviderStrategyNode(r.getCapacityProviderStrategy()));
|
||||
} else if (r.getLaunchType() != null) {
|
||||
n.put("launchType", r.getLaunchType().name());
|
||||
}
|
||||
if (r.getPlatformVersion() != null) { n.put("platformVersion", r.getPlatformVersion()); }
|
||||
if (r.getPlatformFamily() != null) { n.put("platformFamily", r.getPlatformFamily()); }
|
||||
if (r.getLoadBalancers() != null && !r.getLoadBalancers().isEmpty()) {
|
||||
ArrayNode lbs = objectMapper.createArrayNode();
|
||||
r.getLoadBalancers().forEach(lb -> lbs.add(loadBalancerNode(lb)));
|
||||
n.set("loadBalancers", lbs);
|
||||
}
|
||||
if (r.getServiceRegistries() != null && !r.getServiceRegistries().isEmpty()) {
|
||||
n.set("serviceRegistries", objectMapper.valueToTree(r.getServiceRegistries()));
|
||||
}
|
||||
if (r.getNetworkConfiguration() != null
|
||||
&& r.getNetworkConfiguration().getAwsvpcConfiguration() != null) {
|
||||
n.set("networkConfiguration",
|
||||
networkConfigurationNode(r.getNetworkConfiguration().getAwsvpcConfiguration()));
|
||||
}
|
||||
if (r.getServiceConnectConfiguration() != null) {
|
||||
n.set("serviceConnectConfiguration",
|
||||
objectMapper.valueToTree(r.getServiceConnectConfiguration()));
|
||||
}
|
||||
if (r.getContainerImages() != null && !r.getContainerImages().isEmpty()) {
|
||||
ArrayNode images = objectMapper.createArrayNode();
|
||||
for (ContainerImage image : r.getContainerImages()) {
|
||||
ObjectNode imageNode = objectMapper.createObjectNode();
|
||||
imageNode.put("containerName", image.containerName());
|
||||
imageNode.put("image", image.image());
|
||||
if (image.imageDigest() != null) { imageNode.put("imageDigest", image.imageDigest()); }
|
||||
images.add(imageNode);
|
||||
}
|
||||
n.set("containerImages", images);
|
||||
}
|
||||
// Floci runs no GuardDuty runtime monitoring, which is what this reports.
|
||||
n.put("guardDutyEnabled", false);
|
||||
putInstant(n, "createdAt", r.getCreatedAt());
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -817,10 +1047,12 @@ public class EcsResponseWriter {
|
||||
return n;
|
||||
}
|
||||
|
||||
public ObjectNode settingNode(String name, String value) {
|
||||
public ObjectNode settingNode(EcsService.AccountSetting setting) {
|
||||
ObjectNode n = objectMapper.createObjectNode();
|
||||
n.put("name", name);
|
||||
n.put("value", value);
|
||||
n.put("name", setting.name());
|
||||
n.put("value", setting.value());
|
||||
if (setting.principalArn() != null) { n.put("principalArn", setting.principalArn()); }
|
||||
if (setting.type() != null) { n.put("type", setting.type()); }
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* One container image a service revision pins. {@code imageDigest} is the digest the image
|
||||
* resolved to; a revision Floci minted from a task definition alone has not pulled anything yet
|
||||
* and reports none.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public record ContainerImage(String containerName, String image, String imageDigest) {
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -15,8 +16,16 @@ public class ContainerInstance {
|
||||
private String status;
|
||||
private int runningTasksCount;
|
||||
private int pendingTasksCount;
|
||||
private String agentVersion;
|
||||
private String statusReason;
|
||||
private boolean agentConnected;
|
||||
private String agentUpdateStatus;
|
||||
private String capacityProviderName;
|
||||
private long version;
|
||||
private Instant registeredAt;
|
||||
/** The agent's own {@code versionInfo}: agentHash, agentVersion and dockerVersion. */
|
||||
private Map<String, Object> versionInfo;
|
||||
private List<Map<String, Object>> registeredResources;
|
||||
private List<Map<String, Object>> remainingResources;
|
||||
private List<Attribute> attributes = new ArrayList<>();
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
|
||||
@@ -35,12 +44,33 @@ public class ContainerInstance {
|
||||
public int getPendingTasksCount() { return pendingTasksCount; }
|
||||
public void setPendingTasksCount(int pendingTasksCount) { this.pendingTasksCount = pendingTasksCount; }
|
||||
|
||||
public String getAgentVersion() { return agentVersion; }
|
||||
public void setAgentVersion(String agentVersion) { this.agentVersion = agentVersion; }
|
||||
public String getStatusReason() { return statusReason; }
|
||||
public void setStatusReason(String statusReason) { this.statusReason = statusReason; }
|
||||
|
||||
public boolean isAgentConnected() { return agentConnected; }
|
||||
public void setAgentConnected(boolean agentConnected) { this.agentConnected = agentConnected; }
|
||||
|
||||
public String getAgentUpdateStatus() { return agentUpdateStatus; }
|
||||
public void setAgentUpdateStatus(String agentUpdateStatus) { this.agentUpdateStatus = agentUpdateStatus; }
|
||||
|
||||
public String getCapacityProviderName() { return capacityProviderName; }
|
||||
public void setCapacityProviderName(String capacityProviderName) { this.capacityProviderName = capacityProviderName; }
|
||||
|
||||
public long getVersion() { return version; }
|
||||
public void setVersion(long version) { this.version = version; }
|
||||
|
||||
public Instant getRegisteredAt() { return registeredAt; }
|
||||
public void setRegisteredAt(Instant registeredAt) { this.registeredAt = registeredAt; }
|
||||
|
||||
public Map<String, Object> getVersionInfo() { return versionInfo; }
|
||||
public void setVersionInfo(Map<String, Object> versionInfo) { this.versionInfo = versionInfo; }
|
||||
|
||||
public List<Map<String, Object>> getRegisteredResources() { return registeredResources; }
|
||||
public void setRegisteredResources(List<Map<String, Object>> resources) { this.registeredResources = resources; }
|
||||
|
||||
public List<Map<String, Object>> getRemainingResources() { return remainingResources; }
|
||||
public void setRemainingResources(List<Map<String, Object>> resources) { this.remainingResources = resources; }
|
||||
|
||||
public List<Attribute> getAttributes() { return attributes; }
|
||||
public void setAttributes(List<Attribute> attributes) { this.attributes = attributes; }
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ public class CreateClusterRequest {
|
||||
private String clusterName;
|
||||
private Map<String, String> tags;
|
||||
private List<ClusterSetting> settings;
|
||||
private Map<String, Object> configuration;
|
||||
private Map<String, Object> serviceConnectDefaults;
|
||||
private List<String> capacityProviders;
|
||||
private List<Map<String, Object>> defaultCapacityProviderStrategy;
|
||||
|
||||
@@ -24,6 +26,12 @@ public class CreateClusterRequest {
|
||||
public List<ClusterSetting> getSettings() { return settings; }
|
||||
public void setSettings(List<ClusterSetting> settings) { this.settings = settings; }
|
||||
|
||||
public Map<String, Object> getConfiguration() { return configuration; }
|
||||
public void setConfiguration(Map<String, Object> configuration) { this.configuration = configuration; }
|
||||
|
||||
public Map<String, Object> getServiceConnectDefaults() { return serviceConnectDefaults; }
|
||||
public void setServiceConnectDefaults(Map<String, Object> defaults) { this.serviceConnectDefaults = defaults; }
|
||||
|
||||
public List<String> getCapacityProviders() { return capacityProviders; }
|
||||
public void setCapacityProviders(List<String> capacityProviders) { this.capacityProviders = capacityProviders; }
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** A parsed {@code CreateTaskSet} request. */
|
||||
@RegisterForReflection
|
||||
public class CreateTaskSetRequest {
|
||||
@@ -10,9 +13,17 @@ public class CreateTaskSetRequest {
|
||||
private String service;
|
||||
private String taskDefinition;
|
||||
private LaunchType launchType;
|
||||
private List<CapacityProviderStrategyItem> capacityProviderStrategy;
|
||||
private String platformVersion;
|
||||
private Double scaleValue;
|
||||
private String scaleUnit;
|
||||
private String externalId;
|
||||
/** Set by Floci's CodeDeploy, which reports {@code CODE_DEPLOY}; an external deployment leaves it unset. */
|
||||
private String startedBy;
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
private List<EcsLoadBalancer> loadBalancers;
|
||||
private List<Map<String, Object>> serviceRegistries;
|
||||
private Map<String, String> tags;
|
||||
|
||||
public String getCluster() { return cluster; }
|
||||
public void setCluster(String cluster) { this.cluster = cluster; }
|
||||
@@ -26,6 +37,14 @@ public class CreateTaskSetRequest {
|
||||
public LaunchType getLaunchType() { return launchType; }
|
||||
public void setLaunchType(LaunchType launchType) { this.launchType = launchType; }
|
||||
|
||||
public List<CapacityProviderStrategyItem> getCapacityProviderStrategy() { return capacityProviderStrategy; }
|
||||
public void setCapacityProviderStrategy(List<CapacityProviderStrategyItem> strategy) {
|
||||
this.capacityProviderStrategy = strategy;
|
||||
}
|
||||
|
||||
public String getPlatformVersion() { return platformVersion; }
|
||||
public void setPlatformVersion(String platformVersion) { this.platformVersion = platformVersion; }
|
||||
|
||||
public Double getScaleValue() { return scaleValue; }
|
||||
public void setScaleValue(Double scaleValue) { this.scaleValue = scaleValue; }
|
||||
|
||||
@@ -34,4 +53,23 @@ public class CreateTaskSetRequest {
|
||||
|
||||
public String getExternalId() { return externalId; }
|
||||
public void setExternalId(String externalId) { this.externalId = externalId; }
|
||||
|
||||
public String getStartedBy() { return startedBy; }
|
||||
public void setStartedBy(String startedBy) { this.startedBy = startedBy; }
|
||||
|
||||
public NetworkConfiguration getNetworkConfiguration() { return networkConfiguration; }
|
||||
public void setNetworkConfiguration(NetworkConfiguration networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
|
||||
public List<EcsLoadBalancer> getLoadBalancers() { return loadBalancers; }
|
||||
public void setLoadBalancers(List<EcsLoadBalancer> loadBalancers) { this.loadBalancers = loadBalancers; }
|
||||
|
||||
public List<Map<String, Object>> getServiceRegistries() { return serviceRegistries; }
|
||||
public void setServiceRegistries(List<Map<String, Object>> serviceRegistries) {
|
||||
this.serviceRegistries = serviceRegistries;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,10 @@ public class Deployment {
|
||||
private String rolloutState;
|
||||
private String rolloutStateReason;
|
||||
private LaunchType launchType;
|
||||
private List<CapacityProviderStrategyItem> capacityProviderStrategy;
|
||||
private String platformVersion;
|
||||
private String platformFamily;
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
private Instant createdAt;
|
||||
private Instant updatedAt;
|
||||
/**
|
||||
@@ -53,6 +58,18 @@ public class Deployment {
|
||||
public void setRolloutStateReason(String rolloutStateReason) { this.rolloutStateReason = rolloutStateReason; }
|
||||
public LaunchType getLaunchType() { return launchType; }
|
||||
public void setLaunchType(LaunchType launchType) { this.launchType = launchType; }
|
||||
public List<CapacityProviderStrategyItem> getCapacityProviderStrategy() { return capacityProviderStrategy; }
|
||||
public void setCapacityProviderStrategy(List<CapacityProviderStrategyItem> capacityProviderStrategy) {
|
||||
this.capacityProviderStrategy = capacityProviderStrategy;
|
||||
}
|
||||
public String getPlatformVersion() { return platformVersion; }
|
||||
public void setPlatformVersion(String platformVersion) { this.platformVersion = platformVersion; }
|
||||
public String getPlatformFamily() { return platformFamily; }
|
||||
public void setPlatformFamily(String platformFamily) { this.platformFamily = platformFamily; }
|
||||
public NetworkConfiguration getNetworkConfiguration() { return networkConfiguration; }
|
||||
public void setNetworkConfiguration(NetworkConfiguration networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public Instant getUpdatedAt() { return updatedAt; }
|
||||
|
||||
@@ -19,6 +19,8 @@ public class EcsCluster {
|
||||
private List<ClusterSetting> settings;
|
||||
private List<String> capacityProviders;
|
||||
private List<Map<String, Object>> defaultCapacityProviderStrategy;
|
||||
private Map<String, Object> configuration;
|
||||
private Map<String, Object> serviceConnectDefaults;
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
|
||||
public String getClusterArn() { return clusterArn; }
|
||||
@@ -51,6 +53,12 @@ public class EcsCluster {
|
||||
public List<Map<String, Object>> getDefaultCapacityProviderStrategy() { return defaultCapacityProviderStrategy; }
|
||||
public void setDefaultCapacityProviderStrategy(List<Map<String, Object>> s) { this.defaultCapacityProviderStrategy = s; }
|
||||
|
||||
public Map<String, Object> getConfiguration() { return configuration; }
|
||||
public void setConfiguration(Map<String, Object> configuration) { this.configuration = configuration; }
|
||||
|
||||
public Map<String, Object> getServiceConnectDefaults() { return serviceConnectDefaults; }
|
||||
public void setServiceConnectDefaults(Map<String, Object> defaults) { this.serviceConnectDefaults = defaults; }
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
@@ -2,24 +2,60 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/** A parsed {@code ListTasks} request. Every member narrows the listing. */
|
||||
/**
|
||||
* A parsed {@code ListTasks} request.
|
||||
*
|
||||
* <p>Every member narrows the listing. {@code startedBy} is the exception: ECS requires it to be
|
||||
* used on its own, which {@link #hasOtherFilters()} is there to check. {@code cluster} is not a
|
||||
* filter for that rule, it is the scope the listing runs in, so it pairs with {@code startedBy}.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class ListTasksRequest {
|
||||
|
||||
private String cluster;
|
||||
private String containerInstance;
|
||||
private String desiredStatus;
|
||||
private String family;
|
||||
private LaunchType launchType;
|
||||
private String serviceName;
|
||||
private String startedBy;
|
||||
private Integer maxResults;
|
||||
private String nextToken;
|
||||
|
||||
public String getCluster() { return cluster; }
|
||||
public void setCluster(String cluster) { this.cluster = cluster; }
|
||||
|
||||
public String getContainerInstance() { return containerInstance; }
|
||||
public void setContainerInstance(String containerInstance) { this.containerInstance = containerInstance; }
|
||||
|
||||
public String getDesiredStatus() { return desiredStatus; }
|
||||
public void setDesiredStatus(String desiredStatus) { this.desiredStatus = desiredStatus; }
|
||||
|
||||
public String getFamily() { return family; }
|
||||
public void setFamily(String family) { this.family = family; }
|
||||
|
||||
public LaunchType getLaunchType() { return launchType; }
|
||||
public void setLaunchType(LaunchType launchType) { this.launchType = launchType; }
|
||||
|
||||
public String getServiceName() { return serviceName; }
|
||||
public void setServiceName(String serviceName) { this.serviceName = serviceName; }
|
||||
|
||||
public String getStartedBy() { return startedBy; }
|
||||
public void setStartedBy(String startedBy) { this.startedBy = startedBy; }
|
||||
|
||||
public Integer getMaxResults() { return maxResults; }
|
||||
public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; }
|
||||
|
||||
public String getNextToken() { return nextToken; }
|
||||
public void setNextToken(String nextToken) { this.nextToken = nextToken; }
|
||||
|
||||
/**
|
||||
* Whether any filter other than {@code startedBy} is set. The cluster and the pagination
|
||||
* members do not count: the cluster scopes the listing rather than narrowing it, and AWS
|
||||
* accepts {@code list-tasks --cluster X --started-by Y}.
|
||||
*/
|
||||
public boolean hasOtherFilters() {
|
||||
return containerInstance != null || desiredStatus != null
|
||||
|| family != null || launchType != null || serviceName != null;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** A parsed {@code RegisterContainerInstance} request, which only the ECS agent sends. */
|
||||
@RegisterForReflection
|
||||
public class RegisterContainerInstanceRequest {
|
||||
|
||||
private String cluster;
|
||||
/** Set when the agent is re-registering an instance it already has an ARN for. */
|
||||
private String containerInstanceArn;
|
||||
private String instanceIdentityDocument;
|
||||
private List<Attribute> attributes;
|
||||
private List<Map<String, Object>> totalResources;
|
||||
private Map<String, Object> versionInfo;
|
||||
private List<Map<String, Object>> platformDevices;
|
||||
private Map<String, String> tags;
|
||||
|
||||
public String getCluster() { return cluster; }
|
||||
public void setCluster(String cluster) { this.cluster = cluster; }
|
||||
|
||||
public String getContainerInstanceArn() { return containerInstanceArn; }
|
||||
public void setContainerInstanceArn(String containerInstanceArn) {
|
||||
this.containerInstanceArn = containerInstanceArn;
|
||||
}
|
||||
|
||||
public String getInstanceIdentityDocument() { return instanceIdentityDocument; }
|
||||
public void setInstanceIdentityDocument(String doc) { this.instanceIdentityDocument = doc; }
|
||||
|
||||
public List<Attribute> getAttributes() { return attributes; }
|
||||
public void setAttributes(List<Attribute> attributes) { this.attributes = attributes; }
|
||||
|
||||
public List<Map<String, Object>> getTotalResources() { return totalResources; }
|
||||
public void setTotalResources(List<Map<String, Object>> totalResources) {
|
||||
this.totalResources = totalResources;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVersionInfo() { return versionInfo; }
|
||||
public void setVersionInfo(Map<String, Object> versionInfo) { this.versionInfo = versionInfo; }
|
||||
|
||||
public List<Map<String, Object>> getPlatformDevices() { return platformDevices; }
|
||||
public void setPlatformDevices(List<Map<String, Object>> platformDevices) {
|
||||
this.platformDevices = platformDevices;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
public class ServiceDeployment {
|
||||
@@ -10,10 +11,35 @@ public class ServiceDeployment {
|
||||
private String serviceDeploymentArn;
|
||||
private String serviceArn;
|
||||
private String clusterArn;
|
||||
/**
|
||||
* Internal only. AWS's {@code ServiceDeployment} shape has no {@code taskDefinition} member:
|
||||
* a caller reaches the task definition through {@link #targetServiceRevisionArn}, so this is
|
||||
* never written to the wire.
|
||||
*/
|
||||
private String taskDefinition;
|
||||
private String status;
|
||||
private Instant createdAt;
|
||||
private Instant startedAt;
|
||||
private Instant finishedAt;
|
||||
private Instant updatedAt;
|
||||
private String targetServiceRevisionArn;
|
||||
private List<String> sourceServiceRevisionArns;
|
||||
|
||||
public Instant getStartedAt() { return startedAt; }
|
||||
public void setStartedAt(Instant startedAt) { this.startedAt = startedAt; }
|
||||
|
||||
public Instant getFinishedAt() { return finishedAt; }
|
||||
public void setFinishedAt(Instant finishedAt) { this.finishedAt = finishedAt; }
|
||||
|
||||
public String getTargetServiceRevisionArn() { return targetServiceRevisionArn; }
|
||||
public void setTargetServiceRevisionArn(String targetServiceRevisionArn) {
|
||||
this.targetServiceRevisionArn = targetServiceRevisionArn;
|
||||
}
|
||||
|
||||
public List<String> getSourceServiceRevisionArns() { return sourceServiceRevisionArns; }
|
||||
public void setSourceServiceRevisionArns(List<String> sourceServiceRevisionArns) {
|
||||
this.sourceServiceRevisionArns = sourceServiceRevisionArns;
|
||||
}
|
||||
|
||||
public String getServiceDeploymentArn() { return serviceDeploymentArn; }
|
||||
public void setServiceDeploymentArn(String serviceDeploymentArn) { this.serviceDeploymentArn = serviceDeploymentArn; }
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.github.hectorvent.floci.services.ecs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* One entry of the event log {@code DescribeServices} reports on {@code services[].events}.
|
||||
* Tools tail it for the "has reached a steady state" message the scheduler emits once a
|
||||
* deployment converges.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public record ServiceEvent(String id, Instant createdAt, String message) {
|
||||
}
|
||||
@@ -3,7 +3,14 @@ package io.github.hectorvent.floci.services.ecs.model;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The immutable snapshot of a service's configuration at the moment a deployment was created.
|
||||
* Everything a revision carries is copied from the service, not referenced, so a revision keeps
|
||||
* reporting what the service looked like then even after the service moves on.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class ServiceRevision {
|
||||
|
||||
@@ -12,8 +19,50 @@ public class ServiceRevision {
|
||||
private String clusterArn;
|
||||
private String taskDefinition;
|
||||
private LaunchType launchType;
|
||||
private List<CapacityProviderStrategyItem> capacityProviderStrategy;
|
||||
private String platformVersion;
|
||||
private String platformFamily;
|
||||
private List<EcsLoadBalancer> loadBalancers;
|
||||
private List<Map<String, Object>> serviceRegistries;
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
private List<ContainerImage> containerImages;
|
||||
private Map<String, Object> serviceConnectConfiguration;
|
||||
private Instant createdAt;
|
||||
|
||||
public List<CapacityProviderStrategyItem> getCapacityProviderStrategy() { return capacityProviderStrategy; }
|
||||
public void setCapacityProviderStrategy(List<CapacityProviderStrategyItem> capacityProviderStrategy) {
|
||||
this.capacityProviderStrategy = capacityProviderStrategy;
|
||||
}
|
||||
|
||||
public String getPlatformVersion() { return platformVersion; }
|
||||
public void setPlatformVersion(String platformVersion) { this.platformVersion = platformVersion; }
|
||||
|
||||
public String getPlatformFamily() { return platformFamily; }
|
||||
public void setPlatformFamily(String platformFamily) { this.platformFamily = platformFamily; }
|
||||
|
||||
public List<EcsLoadBalancer> getLoadBalancers() { return loadBalancers; }
|
||||
public void setLoadBalancers(List<EcsLoadBalancer> loadBalancers) { this.loadBalancers = loadBalancers; }
|
||||
|
||||
public List<Map<String, Object>> getServiceRegistries() { return serviceRegistries; }
|
||||
public void setServiceRegistries(List<Map<String, Object>> serviceRegistries) {
|
||||
this.serviceRegistries = serviceRegistries;
|
||||
}
|
||||
|
||||
public NetworkConfiguration getNetworkConfiguration() { return networkConfiguration; }
|
||||
public void setNetworkConfiguration(NetworkConfiguration networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
|
||||
public List<ContainerImage> getContainerImages() { return containerImages; }
|
||||
public void setContainerImages(List<ContainerImage> containerImages) {
|
||||
this.containerImages = containerImages;
|
||||
}
|
||||
|
||||
public Map<String, Object> getServiceConnectConfiguration() { return serviceConnectConfiguration; }
|
||||
public void setServiceConnectConfiguration(Map<String, Object> serviceConnectConfiguration) {
|
||||
this.serviceConnectConfiguration = serviceConnectConfiguration;
|
||||
}
|
||||
|
||||
public String getServiceRevisionArn() { return serviceRevisionArn; }
|
||||
public void setServiceRevisionArn(String serviceRevisionArn) { this.serviceRevisionArn = serviceRevisionArn; }
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@@ -21,8 +22,16 @@ public class TaskSet {
|
||||
private double scaleValue;
|
||||
private String scaleUnit;
|
||||
private String stabilityStatus;
|
||||
private Instant stabilityStatusAt;
|
||||
private LaunchType launchType;
|
||||
private List<CapacityProviderStrategyItem> capacityProviderStrategy;
|
||||
private String platformVersion;
|
||||
private String platformFamily;
|
||||
private String externalId;
|
||||
private String startedBy;
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
private List<EcsLoadBalancer> loadBalancers;
|
||||
private List<Map<String, Object>> serviceRegistries;
|
||||
private Instant createdAt;
|
||||
private Instant updatedAt;
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
@@ -63,12 +72,42 @@ public class TaskSet {
|
||||
public String getStabilityStatus() { return stabilityStatus; }
|
||||
public void setStabilityStatus(String stabilityStatus) { this.stabilityStatus = stabilityStatus; }
|
||||
|
||||
public Instant getStabilityStatusAt() { return stabilityStatusAt; }
|
||||
public void setStabilityStatusAt(Instant stabilityStatusAt) { this.stabilityStatusAt = stabilityStatusAt; }
|
||||
|
||||
public LaunchType getLaunchType() { return launchType; }
|
||||
public void setLaunchType(LaunchType launchType) { this.launchType = launchType; }
|
||||
|
||||
public List<CapacityProviderStrategyItem> getCapacityProviderStrategy() { return capacityProviderStrategy; }
|
||||
public void setCapacityProviderStrategy(List<CapacityProviderStrategyItem> strategy) {
|
||||
this.capacityProviderStrategy = strategy;
|
||||
}
|
||||
|
||||
public String getPlatformVersion() { return platformVersion; }
|
||||
public void setPlatformVersion(String platformVersion) { this.platformVersion = platformVersion; }
|
||||
|
||||
public String getPlatformFamily() { return platformFamily; }
|
||||
public void setPlatformFamily(String platformFamily) { this.platformFamily = platformFamily; }
|
||||
|
||||
public String getExternalId() { return externalId; }
|
||||
public void setExternalId(String externalId) { this.externalId = externalId; }
|
||||
|
||||
public String getStartedBy() { return startedBy; }
|
||||
public void setStartedBy(String startedBy) { this.startedBy = startedBy; }
|
||||
|
||||
public NetworkConfiguration getNetworkConfiguration() { return networkConfiguration; }
|
||||
public void setNetworkConfiguration(NetworkConfiguration networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
}
|
||||
|
||||
public List<EcsLoadBalancer> getLoadBalancers() { return loadBalancers; }
|
||||
public void setLoadBalancers(List<EcsLoadBalancer> loadBalancers) { this.loadBalancers = loadBalancers; }
|
||||
|
||||
public List<Map<String, Object>> getServiceRegistries() { return serviceRegistries; }
|
||||
public void setServiceRegistries(List<Map<String, Object>> serviceRegistries) {
|
||||
this.serviceRegistries = serviceRegistries;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
|
||||
+3
-2
@@ -53,10 +53,11 @@ class EcsCreateClusterSettingsIntegrationTest {
|
||||
.body("cluster.settings[0].value", equalTo("enabled"));
|
||||
|
||||
// The drift the issue describes is not in the CreateCluster response but in what a later
|
||||
// read reports, which is what a client compares its configuration against.
|
||||
// read reports, which is what a client compares its configuration against. DescribeClusters
|
||||
// only reports settings when the request asks for them, which terraform-provider-aws does.
|
||||
ecs("DescribeClusters")
|
||||
.body("""
|
||||
{"clusters": ["%s"]}
|
||||
{"clusters": ["%s"], "include": ["SETTINGS"]}
|
||||
""".formatted(cluster))
|
||||
.when()
|
||||
.post("/")
|
||||
|
||||
+741
-1
@@ -449,7 +449,80 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
.then().body("message", containsString("role parameter"));
|
||||
}
|
||||
|
||||
// ── Service updates ──────────────────────────────────────────────────────
|
||||
// ── ListTasks filters ─────────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void listTasksDefaultsToTheRunningTasks() {
|
||||
String family = seed("edge-list-default");
|
||||
String running = call("RunTask", "{\"cluster\":\"" + CLUSTER + "\",\"taskDefinition\":\""
|
||||
+ family + "\",\"launchType\":\"FARGATE\"," + NETWORK + "}", 200)
|
||||
.jsonPath().getString("tasks[0].taskArn");
|
||||
String stopped = call("RunTask", "{\"cluster\":\"" + CLUSTER + "\",\"taskDefinition\":\""
|
||||
+ family + "\",\"launchType\":\"FARGATE\"," + NETWORK + "}", 200)
|
||||
.jsonPath().getString("tasks[0].taskArn");
|
||||
call("StopTask", "{\"cluster\":\"" + CLUSTER + "\",\"task\":\"" + stopped + "\"}", 200);
|
||||
|
||||
// Without a desiredStatus the listing is RUNNING only, which is AWS's default filter.
|
||||
List<String> byDefault = call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\""
|
||||
+ family + "\"}", 200).jsonPath().getList("taskArns");
|
||||
assertTrue(byDefault.contains(running), "a running task must be listed by default");
|
||||
assertFalse(byDefault.contains(stopped), "a stopped task must not be listed by default");
|
||||
|
||||
List<String> stoppedOnly = call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\""
|
||||
+ family + "\",\"desiredStatus\":\"STOPPED\"}", 200).jsonPath().getList("taskArns");
|
||||
assertTrue(stoppedOnly.contains(stopped), "STOPPED must list the stopped task");
|
||||
assertFalse(stoppedOnly.contains(running), "STOPPED must not list the running task");
|
||||
|
||||
// ECS never sets a desired status of PENDING, so that filter matches nothing.
|
||||
assertTrue(call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"desiredStatus\":\"PENDING\"}", 200)
|
||||
.jsonPath().getList("taskArns").isEmpty(), "PENDING must match nothing");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTasksFiltersByLaunchTypeAndStartedBy() {
|
||||
String family = seed("edge-list-filters");
|
||||
String tagged = call("RunTask", "{\"cluster\":\"" + CLUSTER + "\",\"taskDefinition\":\""
|
||||
+ family + "\",\"launchType\":\"FARGATE\"," + NETWORK
|
||||
+ ",\"startedBy\":\"edge-batch-7\"}", 200)
|
||||
.jsonPath().getString("tasks[0].taskArn");
|
||||
|
||||
assertTrue(call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"launchType\":\"FARGATE\"}", 200)
|
||||
.jsonPath().getList("taskArns").contains(tagged));
|
||||
assertTrue(call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"launchType\":\"EC2\"}", 200)
|
||||
.jsonPath().getList("taskArns").isEmpty(), "no task here runs on EC2");
|
||||
|
||||
assertTrue(call("ListTasks", "{\"startedBy\":\"edge-batch-7\"}", 200)
|
||||
.jsonPath().getList("taskArns").contains(tagged));
|
||||
// The cluster scopes the listing rather than filtering it, so it pairs with startedBy.
|
||||
assertTrue(call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"startedBy\":\"edge-batch-7\"}", 200)
|
||||
.jsonPath().getList("taskArns").contains(tagged));
|
||||
// Any other filter alongside startedBy is still refused.
|
||||
call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"startedBy\":\"edge-batch-7\"}", 400)
|
||||
.then().body("message", containsString("only filter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTasksPaginates() {
|
||||
String family = seed("edge-list-paging");
|
||||
call("RunTask", "{\"cluster\":\"" + CLUSTER + "\",\"taskDefinition\":\"" + family
|
||||
+ "\",\"count\":3,\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
Response first = call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"maxResults\":2}", 200);
|
||||
first.then().body("taskArns", hasSize(2));
|
||||
String token = first.jsonPath().getString("nextToken");
|
||||
assertTrue(token != null && !token.isBlank(), "a truncated listing must return a token");
|
||||
|
||||
Response second = call("ListTasks", "{\"cluster\":\"" + CLUSTER + "\",\"family\":\"" + family
|
||||
+ "\",\"maxResults\":2,\"nextToken\":\"" + token + "\"}", 200);
|
||||
second.then().body("taskArns", hasSize(1));
|
||||
assertEquals(null, second.jsonPath().getString("nextToken"),
|
||||
"the last page carries no token");
|
||||
}
|
||||
|
||||
@Test
|
||||
void onlyTheDocumentedUpdatesRollTheServiceDeployment() {
|
||||
@@ -553,6 +626,127 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
.then().body("message", containsString("being deleted"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTaskDefinitionsDefaultsToActiveAndOrdersByRevision() {
|
||||
for (int i = 0; i < 11; i++) {
|
||||
registerSize("edge-list-td", "256", "512", 200);
|
||||
}
|
||||
call("DeregisterTaskDefinition", "{\"taskDefinition\":\"edge-list-td:1\"}", 200);
|
||||
|
||||
List<String> active = call("ListTaskDefinitions",
|
||||
"{\"familyPrefix\":\"edge-list-td\"}", 200).jsonPath().getList("taskDefinitionArns");
|
||||
assertFalse(active.stream().anyMatch(arn -> arn.endsWith("edge-list-td:1")),
|
||||
"a deregistered revision is not listed by default");
|
||||
// Ascending by revision, so revision 11 comes after revision 2 rather than before it.
|
||||
assertTrue(active.getFirst().endsWith(":2"), "the lowest active revision comes first: " + active);
|
||||
assertTrue(active.getLast().endsWith(":11"), "the newest revision comes last: " + active);
|
||||
|
||||
List<String> descending = call("ListTaskDefinitions",
|
||||
"{\"familyPrefix\":\"edge-list-td\",\"sort\":\"DESC\"}", 200)
|
||||
.jsonPath().getList("taskDefinitionArns");
|
||||
assertTrue(descending.getFirst().endsWith(":11"), "DESC lists the newest first: " + descending);
|
||||
|
||||
List<String> inactive = call("ListTaskDefinitions",
|
||||
"{\"familyPrefix\":\"edge-list-td\",\"status\":\"INACTIVE\"}", 200)
|
||||
.jsonPath().getList("taskDefinitionArns");
|
||||
assertEquals(1, inactive.size(), "only the deregistered revision is INACTIVE");
|
||||
|
||||
Response firstPage = call("ListTaskDefinitions",
|
||||
"{\"familyPrefix\":\"edge-list-td\",\"maxResults\":3}", 200);
|
||||
firstPage.then().body("taskDefinitionArns", hasSize(3));
|
||||
assertTrue(firstPage.jsonPath().getString("nextToken") != null,
|
||||
"a truncated listing returns a token");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listServicesFiltersAndPagesTheWayAwsDoes() {
|
||||
String family = seed("edge-list-services");
|
||||
for (int i = 0; i < 12; i++) {
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"edge-svc-" + i
|
||||
+ "\",\"taskDefinition\":\"" + family + "\",\"desiredCount\":0,"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
}
|
||||
|
||||
// ListServices pages ten at a time by default, unlike the other listings.
|
||||
Response defaultPage = call("ListServices", "{\"cluster\":\"" + CLUSTER + "\"}", 200);
|
||||
defaultPage.then().body("serviceArns", hasSize(10));
|
||||
assertTrue(defaultPage.jsonPath().getString("nextToken") != null,
|
||||
"a truncated listing returns a token");
|
||||
|
||||
assertTrue(call("ListServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"launchType\":\"EC2\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("serviceArns").isEmpty(), "no service here runs on EC2");
|
||||
assertFalse(call("ListServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"launchType\":\"FARGATE\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("serviceArns").isEmpty(), "the Fargate services are listed");
|
||||
assertTrue(call("ListServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"schedulingStrategy\":\"DAEMON\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("serviceArns").isEmpty(), "none of these are daemons");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTaskDefinitionFamiliesFiltersByWhetherARevisionIsActive() {
|
||||
registerSize("edge-family-active", "256", "512", 200);
|
||||
registerSize("edge-family-gone", "256", "512", 200);
|
||||
call("DeregisterTaskDefinition", "{\"taskDefinition\":\"edge-family-gone:1\"}", 200);
|
||||
|
||||
// Both are listed without a status, which is AWS's default.
|
||||
List<String> all = call("ListTaskDefinitionFamilies",
|
||||
"{\"familyPrefix\":\"edge-family-\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("families");
|
||||
assertTrue(all.containsAll(List.of("edge-family-active", "edge-family-gone")), all.toString());
|
||||
|
||||
assertEquals(List.of("edge-family-active"), call("ListTaskDefinitionFamilies",
|
||||
"{\"familyPrefix\":\"edge-family-\",\"status\":\"ACTIVE\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("families"));
|
||||
assertEquals(List.of("edge-family-gone"), call("ListTaskDefinitionFamilies",
|
||||
"{\"familyPrefix\":\"edge-family-\",\"status\":\"INACTIVE\",\"maxResults\":100}", 200)
|
||||
.jsonPath().getList("families"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeClustersWithholdsEverythingTheIncludeDidNotAskFor() {
|
||||
String cluster = "edge-include-cluster";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\","
|
||||
+ "\"settings\":[{\"name\":\"containerInsights\",\"value\":\"enabled\"}],"
|
||||
+ "\"tags\":[{\"key\":\"team\",\"value\":\"platform\"}],"
|
||||
+ "\"configuration\":{\"executeCommandConfiguration\":{\"logging\":\"DEFAULT\"}}}", 200);
|
||||
|
||||
Response bare = call("DescribeClusters", "{\"clusters\":[\"" + cluster + "\"]}", 200);
|
||||
bare.then()
|
||||
.body("clusters[0].clusterName", equalTo(cluster))
|
||||
.body("clusters[0].settings", nullValue())
|
||||
.body("clusters[0].tags", nullValue())
|
||||
.body("clusters[0].statistics", nullValue())
|
||||
.body("clusters[0].attachments", nullValue())
|
||||
.body("clusters[0].configuration", nullValue());
|
||||
|
||||
call("DescribeClusters", "{\"clusters\":[\"" + cluster + "\"],"
|
||||
+ "\"include\":[\"SETTINGS\",\"TAGS\",\"STATISTICS\",\"ATTACHMENTS\",\"CONFIGURATIONS\"]}", 200)
|
||||
.then()
|
||||
.body("clusters[0].settings", hasSize(1))
|
||||
.body("clusters[0].tags", hasSize(1))
|
||||
.body("clusters[0].attachments", hasSize(0))
|
||||
.body("clusters[0].configuration.executeCommandConfiguration.logging", equalTo("DEFAULT"))
|
||||
.body("clusters[0].statistics", hasSize(8))
|
||||
.body("clusters[0].statistics.find { it.name == 'runningFargateTasksCount' }.value",
|
||||
equalTo("0"));
|
||||
|
||||
call("DescribeClusters", "{\"clusters\":[\"" + cluster + "\"],\"include\":[\"NOPE\"]}", 400);
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeClustersReportsAnUnknownClusterAsMissingRatherThanDroppingIt() {
|
||||
call("CreateCluster", "{\"clusterName\":\"" + CLUSTER + "\"}", 200);
|
||||
|
||||
call("DescribeClusters", "{\"clusters\":[\"" + CLUSTER + "\",\"edge-no-such-cluster\"]}", 200)
|
||||
.then()
|
||||
.body("clusters", hasSize(1))
|
||||
.body("failures", hasSize(1))
|
||||
.body("failures[0].reason", equalTo("MISSING"))
|
||||
.body("failures[0].arn", containsString("cluster/edge-no-such-cluster"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeTasksReportsAnUnknownTaskAsMissingRatherThanDroppingIt() {
|
||||
call("CreateCluster", "{\"clusterName\":\"" + CLUSTER + "\"}", 200);
|
||||
@@ -564,6 +758,399 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
.body("failures[0].reason", equalTo("MISSING"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listClustersPagesTheWayAwsDoes() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
call("CreateCluster", "{\"clusterName\":\"edge-page-cluster-" + i + "\"}", 200);
|
||||
}
|
||||
|
||||
Response first = call("ListClusters", "{\"maxResults\":1}", 200);
|
||||
first.then().body("clusterArns", hasSize(1)).body("nextToken", notNullValue());
|
||||
|
||||
String token = first.jsonPath().getString("nextToken");
|
||||
Response second = call("ListClusters", "{\"maxResults\":1,\"nextToken\":\"" + token + "\"}", 200);
|
||||
second.then().body("clusterArns", hasSize(1));
|
||||
assertNotEquals(first.jsonPath().getString("clusterArns[0]"),
|
||||
second.jsonPath().getString("clusterArns[0]"));
|
||||
|
||||
// No maxResults pages a hundred at a time, so a handful of clusters comes back whole.
|
||||
call("ListClusters", "{}", 200).then().body("nextToken", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clusterStatisticsCountRunningFargateTasks() {
|
||||
String cluster = "edge-stats-cluster";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
registerSize("edge-stats", "256", "512", 200);
|
||||
call("RunTask", "{\"cluster\":\"" + cluster + "\",\"taskDefinition\":\"edge-stats\","
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
List<Map<String, String>> statistics = call("DescribeClusters",
|
||||
"{\"clusters\":[\"" + cluster + "\"],\"include\":[\"STATISTICS\"]}", 200)
|
||||
.jsonPath().getList("clusters[0].statistics");
|
||||
|
||||
assertEquals("1", statistics.stream()
|
||||
.filter(s -> "runningFargateTasksCount".equals(s.get("name")))
|
||||
.findFirst().orElseThrow().get("value"));
|
||||
assertEquals("0", statistics.stream()
|
||||
.filter(s -> "runningEC2TasksCount".equals(s.get("name")))
|
||||
.findFirst().orElseThrow().get("value"));
|
||||
}
|
||||
|
||||
// ── Task sets ─────────────────────────────────────────────────────────────
|
||||
|
||||
/** Creates an EXTERNAL-controller service, which is the only kind that can hold task sets. */
|
||||
private static String seedExternalService(String name) {
|
||||
String family = seed(name + "-td");
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"" + name + "\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"desiredCount\":3,"
|
||||
+ "\"deploymentController\":{\"type\":\"EXTERNAL\"},"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
return family;
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTaskSetNeedsAServiceThatUsesAnExternalDeploymentController() {
|
||||
String family = seed("edge-rolling-td");
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"edge-rolling-svc\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"desiredCount\":1,"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
call("CreateTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-rolling-svc\","
|
||||
+ "\"taskDefinition\":\"" + family + "\"}", 400)
|
||||
.then().body("message", containsString("EXTERNAL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTaskSetRoundTripsItsMembersAndComputesItsDesiredCount() {
|
||||
String family = seedExternalService("edge-taskset-svc");
|
||||
|
||||
Response created = call("CreateTaskSet", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"service\":\"edge-taskset-svc\",\"taskDefinition\":\"" + family + "\","
|
||||
+ "\"launchType\":\"FARGATE\",\"externalId\":\"d-EXAMPLE\","
|
||||
+ "\"scale\":{\"value\":50,\"unit\":\"PERCENT\"},"
|
||||
+ "\"networkConfiguration\":{\"awsvpcConfiguration\":{\"subnets\":"
|
||||
+ "[\"subnet-default-us-east-1-a\"]}},"
|
||||
+ "\"loadBalancers\":[{\"targetGroupArn\":\"arn:aws:elasticloadbalancing:us-east-1:"
|
||||
+ "000000000000:targetgroup/tg/1\",\"containerName\":\"app\",\"containerPort\":80}],"
|
||||
+ "\"tags\":[{\"key\":\"team\",\"value\":\"platform\"}]}", 200);
|
||||
|
||||
created.then()
|
||||
.body("taskSet.status", equalTo("ACTIVE"))
|
||||
.body("taskSet.launchType", equalTo("FARGATE"))
|
||||
.body("taskSet.platformVersion", equalTo("1.4.0"))
|
||||
.body("taskSet.platformFamily", equalTo("Linux"))
|
||||
.body("taskSet.externalId", equalTo("d-EXAMPLE"))
|
||||
.body("taskSet.scale.value", equalTo(50.0f))
|
||||
.body("taskSet.scale.unit", equalTo("PERCENT"))
|
||||
// 3 desired at 50 percent is 1.5, and AWS always rounds the computed count up.
|
||||
.body("taskSet.computedDesiredCount", equalTo(2))
|
||||
// Floci places no tasks for a task set, so it is steady rather than for ever
|
||||
// stabilising towards a count that nothing will ever reach.
|
||||
.body("taskSet.stabilityStatus", equalTo("STEADY_STATE"))
|
||||
.body("taskSet.stabilityStatusAt", notNullValue())
|
||||
.body("taskSet.networkConfiguration.awsvpcConfiguration.subnets", hasSize(1))
|
||||
.body("taskSet.loadBalancers[0].containerPort", equalTo(80));
|
||||
|
||||
String id = created.jsonPath().getString("taskSet.id");
|
||||
|
||||
// Tags come back from DescribeTaskSets only when the request asks for them.
|
||||
call("DescribeTaskSets", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-svc\"}", 200)
|
||||
.then()
|
||||
.body("taskSets[0].tags", nullValue())
|
||||
.body("taskSets[0].stabilityStatus", equalTo("STEADY_STATE"));
|
||||
call("DescribeTaskSets", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-svc\","
|
||||
+ "\"include\":[\"TAGS\"]}", 200)
|
||||
.then().body("taskSets[0].tags", hasSize(1));
|
||||
|
||||
// A scale change recomputes the desired count.
|
||||
call("UpdateTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-svc\","
|
||||
+ "\"taskSet\":\"" + id + "\",\"scale\":{\"value\":100,\"unit\":\"PERCENT\"}}", 200)
|
||||
.then()
|
||||
.body("taskSet.computedDesiredCount", equalTo(3))
|
||||
.body("taskSet.stabilityStatus", equalTo("STEADY_STATE"));
|
||||
|
||||
// Deleting a task set that has not been scaled to zero needs force.
|
||||
call("DeleteTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-svc\","
|
||||
+ "\"taskSet\":\"" + id + "\"}", 400)
|
||||
.then().body("message", containsString("scaled down to zero"));
|
||||
call("DeleteTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-svc\","
|
||||
+ "\"taskSet\":\"" + id + "\",\"force\":true}", 200)
|
||||
.then().body("taskSet.status", equalTo("DRAINING"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeTaskSetsReportsAnUnknownTaskSetAsMissing() {
|
||||
seedExternalService("edge-taskset-missing");
|
||||
|
||||
call("DescribeTaskSets", "{\"cluster\":\"" + CLUSTER + "\","
|
||||
+ "\"service\":\"edge-taskset-missing\",\"taskSets\":[\"ecs-svc/nope\"]}", 200)
|
||||
.then()
|
||||
.body("taskSets", hasSize(0))
|
||||
.body("failures", hasSize(1))
|
||||
.body("failures[0].reason", equalTo("MISSING"));
|
||||
|
||||
call("UpdateTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-missing\","
|
||||
+ "\"taskSet\":\"ecs-svc/nope\",\"scale\":{\"value\":100,\"unit\":\"PERCENT\"}}", 400)
|
||||
.then().body("__type", containsString("TaskSetNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTaskSetCannotNameBothALaunchTypeAndACapacityProviderStrategy() {
|
||||
String family = seedExternalService("edge-taskset-both");
|
||||
|
||||
call("CreateTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-taskset-both\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"launchType\":\"FARGATE\","
|
||||
+ "\"capacityProviderStrategy\":[{\"capacityProvider\":\"FARGATE_SPOT\",\"weight\":1}]}", 400)
|
||||
.then().body("message", containsString("capacity provider strategy"));
|
||||
}
|
||||
|
||||
// ── Account settings and attributes ───────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void accountSettingsAreValidatedPerName() {
|
||||
call("PutAccountSetting", "{\"name\":\"nonsenseSetting\",\"value\":\"enabled\"}", 400)
|
||||
.then().body("message", containsString("Invalid account setting name"));
|
||||
call("PutAccountSetting", "{\"name\":\"containerInsights\",\"value\":\"maybe\"}", 400)
|
||||
.then().body("message", containsString("Invalid value"));
|
||||
|
||||
// Two settings are not opt-in flags: a wait period in days and a log delivery mode.
|
||||
call("PutAccountSetting", "{\"name\":\"fargateTaskRetirementWaitPeriod\",\"value\":\"14\"}", 200);
|
||||
call("PutAccountSetting", "{\"name\":\"fargateTaskRetirementWaitPeriod\",\"value\":\"3\"}", 400);
|
||||
call("PutAccountSetting", "{\"name\":\"defaultLogDriverMode\",\"value\":\"blocking\"}", 200);
|
||||
call("PutAccountSetting", "{\"name\":\"defaultLogDriverMode\",\"value\":\"enabled\"}", 400);
|
||||
// enhanced is a containerInsights value only.
|
||||
call("PutAccountSetting", "{\"name\":\"containerInsights\",\"value\":\"enhanced\"}", 200);
|
||||
call("PutAccountSetting", "{\"name\":\"awsvpcTrunking\",\"value\":\"enhanced\"}", 400);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAccountSettingReportsItsPrincipalAndType() {
|
||||
call("PutAccountSetting", "{\"name\":\"awsvpcTrunking\",\"value\":\"enabled\","
|
||||
+ "\"principalArn\":\"arn:aws:iam::000000000000:user/edge\"}", 200)
|
||||
.then()
|
||||
.body("setting.name", equalTo("awsvpcTrunking"))
|
||||
.body("setting.value", equalTo("enabled"))
|
||||
.body("setting.principalArn", equalTo("arn:aws:iam::000000000000:user/edge"))
|
||||
.body("setting.type", equalTo("user"));
|
||||
|
||||
// A principal sees only what it set; effectiveSettings fills in the rest.
|
||||
call("ListAccountSettings", "{\"principalArn\":\"arn:aws:iam::000000000000:user/edge\","
|
||||
+ "\"name\":\"containerInsights\"}", 200)
|
||||
.then().body("settings", hasSize(0));
|
||||
call("ListAccountSettings", "{\"principalArn\":\"arn:aws:iam::000000000000:user/edge\","
|
||||
+ "\"name\":\"containerInsights\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings", hasSize(1));
|
||||
|
||||
// GuardDuty owns its setting on the account's behalf.
|
||||
call("ListAccountSettings", "{\"name\":\"guardDutyActivate\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings[0].type", equalTo("aws_managed"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void effectiveAccountSettingsFallBackToTheAccountDefaultThenTheBuiltIn() {
|
||||
String principal = "arn:aws:iam::000000000000:user/edge-fallback";
|
||||
|
||||
// Untouched, the built-in default applies.
|
||||
call("ListAccountSettings", "{\"principalArn\":\"" + principal + "\","
|
||||
+ "\"name\":\"awsvpcTrunking\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings[0].value", equalTo("disabled"));
|
||||
|
||||
// The account default lives on the root user, which is where AWS keeps it too.
|
||||
call("PutAccountSettingDefault", "{\"name\":\"awsvpcTrunking\",\"value\":\"enabled\"}", 200)
|
||||
.then().body("setting.principalArn", containsString(":root"));
|
||||
call("ListAccountSettings", "{\"principalArn\":\"" + principal + "\","
|
||||
+ "\"name\":\"awsvpcTrunking\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings[0].value", equalTo("enabled"));
|
||||
|
||||
// The principal's own setting wins over the account default.
|
||||
call("PutAccountSetting", "{\"name\":\"awsvpcTrunking\",\"value\":\"disabled\","
|
||||
+ "\"principalArn\":\"" + principal + "\"}", 200);
|
||||
call("ListAccountSettings", "{\"principalArn\":\"" + principal + "\","
|
||||
+ "\"name\":\"awsvpcTrunking\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings[0].value", equalTo("disabled"));
|
||||
|
||||
// Deleting it falls back to the account default again.
|
||||
call("DeleteAccountSetting", "{\"name\":\"awsvpcTrunking\",\"principalArn\":\""
|
||||
+ principal + "\"}", 200)
|
||||
.then().body("setting.value", equalTo("disabled"));
|
||||
call("ListAccountSettings", "{\"principalArn\":\"" + principal + "\","
|
||||
+ "\"name\":\"awsvpcTrunking\",\"effectiveSettings\":true}", 200)
|
||||
.then().body("settings[0].value", equalTo("enabled"));
|
||||
|
||||
// The full effective listing is eleven settings, which pages ten at a time.
|
||||
Response page = call("ListAccountSettings",
|
||||
"{\"principalArn\":\"" + principal + "\",\"effectiveSettings\":true}", 200);
|
||||
page.then().body("settings", hasSize(10)).body("nextToken", notNullValue());
|
||||
call("ListAccountSettings", "{\"principalArn\":\"" + principal + "\","
|
||||
+ "\"effectiveSettings\":true,\"nextToken\":\"" + page.jsonPath().getString("nextToken")
|
||||
+ "\"}", 200)
|
||||
.then().body("settings", hasSize(1)).body("nextToken", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void attributesAreScopedToTheirClusterAndNeedARegisteredTarget() {
|
||||
String cluster = "edge-attr-cluster";
|
||||
String other = "edge-attr-other";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
call("CreateCluster", "{\"clusterName\":\"" + other + "\"}", 200);
|
||||
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
|
||||
// An attribute on a target the cluster does not have is a TargetNotFoundException.
|
||||
call("PutAttributes", "{\"cluster\":\"" + cluster + "\",\"attributes\":"
|
||||
+ "[{\"name\":\"stack\",\"value\":\"prod\",\"targetType\":\"container-instance\","
|
||||
+ "\"targetId\":\"nope\"}]}", 400)
|
||||
.then().body("__type", containsString("TargetNotFoundException"));
|
||||
|
||||
call("PutAttributes", "{\"cluster\":\"" + cluster + "\",\"attributes\":"
|
||||
+ "[{\"name\":\"stack\",\"value\":\"prod\",\"targetType\":\"container-instance\","
|
||||
+ "\"targetId\":\"" + instance + "\"}]}", 200)
|
||||
.then().body("attributes", hasSize(1));
|
||||
|
||||
// targetType is required, and container-instance is its only value.
|
||||
call("ListAttributes", "{\"cluster\":\"" + cluster + "\"}", 400)
|
||||
.then().body("message", containsString("targetType"));
|
||||
call("ListAttributes", "{\"cluster\":\"" + cluster + "\",\"targetType\":\"task\"}", 400);
|
||||
|
||||
call("ListAttributes", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"targetType\":\"container-instance\"}", 200)
|
||||
.then().body("attributes.find { it.name == 'stack' }.value", equalTo("prod"));
|
||||
|
||||
// The other cluster never sees it.
|
||||
call("ListAttributes", "{\"cluster\":\"" + other + "\","
|
||||
+ "\"targetType\":\"container-instance\"}", 200)
|
||||
.then().body("attributes.findAll { it.name == 'stack' }", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTargetTakesAtMostTenCustomAttributes() {
|
||||
String cluster = "edge-attr-limit";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
|
||||
StringBuilder ten = new StringBuilder();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (i > 0) { ten.append(','); }
|
||||
ten.append("{\"name\":\"a").append(i).append("\",\"value\":\"v\",")
|
||||
.append("\"targetType\":\"container-instance\",\"targetId\":\"")
|
||||
.append(instance).append("\"}");
|
||||
}
|
||||
call("PutAttributes", "{\"cluster\":\"" + cluster + "\",\"attributes\":[" + ten + "]}", 200);
|
||||
|
||||
call("PutAttributes", "{\"cluster\":\"" + cluster + "\",\"attributes\":"
|
||||
+ "[{\"name\":\"a10\",\"value\":\"v\",\"targetType\":\"container-instance\","
|
||||
+ "\"targetId\":\"" + instance + "\"}]}", 400)
|
||||
.then().body("__type", containsString("AttributeLimitExceededException"));
|
||||
}
|
||||
|
||||
// ── Container instances ───────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void aRegisteredContainerInstanceReportsWhatTheAgentSent() {
|
||||
String cluster = "edge-ci-register";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
|
||||
call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"versionInfo\":{\"agentVersion\":\"1.79.0\",\"agentHash\":\"abc1234\","
|
||||
+ "\"dockerVersion\":\"DockerVersion: 24.0.5\"},"
|
||||
+ "\"totalResources\":[{\"name\":\"CPU\",\"type\":\"INTEGER\",\"integerValue\":4096},"
|
||||
+ "{\"name\":\"MEMORY\",\"type\":\"INTEGER\",\"integerValue\":7482}],"
|
||||
+ "\"tags\":[{\"key\":\"fleet\",\"value\":\"batch\"}]}", 200)
|
||||
.then()
|
||||
.body("containerInstance.status", equalTo("ACTIVE"))
|
||||
.body("containerInstance.registeredAt", notNullValue())
|
||||
.body("containerInstance.version", equalTo(1))
|
||||
// versionInfo is where the agent version lives; there is no top-level agentVersion.
|
||||
.body("containerInstance.agentVersion", nullValue())
|
||||
.body("containerInstance.versionInfo.agentVersion", equalTo("1.79.0"))
|
||||
.body("containerInstance.versionInfo.dockerVersion", equalTo("DockerVersion: 24.0.5"))
|
||||
.body("containerInstance.registeredResources", hasSize(2))
|
||||
.body("containerInstance.remainingResources", hasSize(2))
|
||||
.body("containerInstance.tags", hasSize(1));
|
||||
|
||||
call("DescribeClusters", "{\"clusters\":[\"" + cluster + "\"]}", 200)
|
||||
.then().body("clusters[0].registeredContainerInstancesCount", equalTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDeregisteredContainerInstanceStaysDescribableAsInactive() {
|
||||
String cluster = "edge-ci-deregister";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
|
||||
call("DeregisterContainerInstance", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstance\":\"" + instance + "\"}", 200)
|
||||
.then().body("containerInstance.status", equalTo("INACTIVE"));
|
||||
|
||||
// AWS keeps answering a describe for a deregistered instance.
|
||||
call("DescribeContainerInstances", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"" + instance + "\"]}", 200)
|
||||
.then()
|
||||
.body("containerInstances", hasSize(1))
|
||||
.body("containerInstances[0].status", equalTo("INACTIVE"));
|
||||
|
||||
// The default listing excludes it, and only ACTIVE and DRAINING instances are registered.
|
||||
call("ListContainerInstances", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.then().body("containerInstanceArns", hasSize(0));
|
||||
call("DescribeClusters", "{\"clusters\":[\"" + cluster + "\"]}", 200)
|
||||
.then().body("clusters[0].registeredContainerInstancesCount", equalTo(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void containerInstanceStateOnlyMovesBetweenActiveAndDraining() {
|
||||
String cluster = "edge-ci-state";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
|
||||
call("UpdateContainerInstancesState", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"" + instance + "\"],\"status\":\"REGISTERING\"}", 400)
|
||||
.then().body("message", containsString("ACTIVE and DRAINING"));
|
||||
|
||||
call("UpdateContainerInstancesState", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"" + instance + "\"],\"status\":\"DRAINING\"}", 200)
|
||||
.then().body("containerInstances[0].status", equalTo("DRAINING"));
|
||||
|
||||
// A DRAINING instance is not ACTIVE, so it cannot be set to DRAINING again.
|
||||
call("UpdateContainerInstancesState", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"" + instance + "\"],\"status\":\"DRAINING\"}", 400)
|
||||
.then().body("message", containsString("must be ACTIVE"));
|
||||
|
||||
// A DRAINING instance still counts as registered and still lists by default.
|
||||
call("ListContainerInstances", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.then().body("containerInstanceArns", hasSize(1));
|
||||
call("ListContainerInstances", "{\"cluster\":\"" + cluster + "\",\"status\":\"ACTIVE\"}", 200)
|
||||
.then().body("containerInstanceArns", hasSize(0));
|
||||
call("ListContainerInstances", "{\"cluster\":\"" + cluster + "\",\"status\":\"nonsense\"}", 400);
|
||||
|
||||
call("UpdateContainerInstancesState", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"" + instance + "\"],\"status\":\"ACTIVE\"}", 200)
|
||||
.then().body("containerInstances[0].status", equalTo("ACTIVE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnknownContainerInstanceIsAFailureNotAnError() {
|
||||
String cluster = "edge-ci-missing";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
|
||||
call("DescribeContainerInstances", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"no-such-instance\"]}", 200)
|
||||
.then()
|
||||
.body("containerInstances", hasSize(0))
|
||||
.body("failures", hasSize(1))
|
||||
.body("failures[0].reason", equalTo("MISSING"));
|
||||
|
||||
call("UpdateContainerInstancesState", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstances\":[\"no-such-instance\"],\"status\":\"DRAINING\"}", 200)
|
||||
.then()
|
||||
.body("containerInstances", hasSize(0))
|
||||
.body("failures[0].reason", equalTo("MISSING"));
|
||||
}
|
||||
|
||||
// ── Derived compatibilities and requiresAttributes ────────────────────────
|
||||
|
||||
@Test
|
||||
@@ -619,6 +1206,65 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
.then().body("message", containsString("containerInstances"));
|
||||
}
|
||||
|
||||
// ── The Service shape's own members ──────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void aServiceReportsItsEventsAndTaskSetsAndWhatItsDeploymentRunsOn() {
|
||||
String family = seed("edge-svc-shape-td");
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"edge-svc-shape\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"desiredCount\":0,"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
call("DescribeServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"services\":[\"edge-svc-shape\"]}", 200)
|
||||
.then()
|
||||
// Both members are always present, so a client can tell an empty answer from one
|
||||
// the emulator never wrote.
|
||||
.body("services[0].taskSets", hasSize(0))
|
||||
.body("services[0].events", hasSize(1))
|
||||
.body("services[0].events[0].message",
|
||||
containsString("(service edge-svc-shape) has reached a steady state."))
|
||||
.body("services[0].events[0].id", notNullValue())
|
||||
.body("services[0].events[0].createdAt", notNullValue())
|
||||
// The deployment carries the placement the service runs under, not just its id.
|
||||
.body("services[0].deployments[0].launchType", equalTo("FARGATE"))
|
||||
.body("services[0].deployments[0].platformVersion", equalTo("1.4.0"))
|
||||
.body("services[0].deployments[0].platformFamily", equalTo("Linux"))
|
||||
.body("services[0].deployments[0].networkConfiguration.awsvpcConfiguration.subnets",
|
||||
hasSize(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aServicesTaskSetsAreVisibleOnTheServiceItself() {
|
||||
String family = seedExternalService("edge-svc-tasksets");
|
||||
call("CreateTaskSet", "{\"cluster\":\"" + CLUSTER + "\",\"service\":\"edge-svc-tasksets\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"launchType\":\"FARGATE\"}", 200);
|
||||
|
||||
call("DescribeServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"services\":[\"edge-svc-tasksets\"]}", 200)
|
||||
.then()
|
||||
.body("services[0].taskSets", hasSize(1))
|
||||
.body("services[0].taskSets[0].status", equalTo("ACTIVE"));
|
||||
}
|
||||
|
||||
// ── Cluster deletion ─────────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void aClusterWithRegisteredContainerInstancesCannotBeDeleted() {
|
||||
String cluster = "edge-delete-with-instances";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
|
||||
call("DeleteCluster", "{\"cluster\":\"" + cluster + "\"}", 400)
|
||||
.then().body("__type", containsString("ClusterContainsContainerInstancesException"));
|
||||
|
||||
call("DeregisterContainerInstance", "{\"cluster\":\"" + cluster + "\","
|
||||
+ "\"containerInstance\":\"" + instance + "\"}", 200);
|
||||
call("DeleteCluster", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.then().body("cluster.status", equalTo("INACTIVE"));
|
||||
}
|
||||
|
||||
// ── Capacity providers ───────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
@@ -775,6 +1421,9 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
+ "\"networkMode\":\"AWSVPC\","
|
||||
+ "\"containerDefinitions\":[{\"name\":\"app\",\"image\":\"nginx:latest\"}]}", 400)
|
||||
.then().body("message", containsString("networkMode"));
|
||||
|
||||
call("ListContainerInstances", "{\"cluster\":\"" + CLUSTER + "\",\"status\":\"BOGUS\"}", 400)
|
||||
.then().body("message", containsString("status"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -791,4 +1440,95 @@ class EcsFargateEdgeCaseIntegrationTest {
|
||||
+ "\"tags\":[{\"key\":\"\",\"value\":\"v\"}]}", 400)
|
||||
.then().body("message", containsString("Tag keys"));
|
||||
}
|
||||
|
||||
// ── Container instance health ────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void containerInstanceHealthIsWithheldUntilTheRequestAsksForIt() {
|
||||
String cluster = "edge-ci-health";
|
||||
call("CreateCluster", "{\"clusterName\":\"" + cluster + "\"}", 200);
|
||||
String instance = call("RegisterContainerInstance", "{\"cluster\":\"" + cluster + "\"}", 200)
|
||||
.jsonPath().getString("containerInstance.containerInstanceArn");
|
||||
String describe = "{\"cluster\":\"" + cluster + "\",\"containerInstances\":[\""
|
||||
+ instance + "\"]";
|
||||
|
||||
call("DescribeContainerInstances", describe + "}", 200)
|
||||
.then().body("containerInstances[0].healthStatus", nullValue());
|
||||
|
||||
call("DescribeContainerInstances", describe + ",\"include\":[\"CONTAINER_INSTANCE_HEALTH\"]}", 200)
|
||||
.then()
|
||||
.body("containerInstances[0].healthStatus.overallStatus", equalTo("OK"))
|
||||
.body("containerInstances[0].healthStatus.details[0].type",
|
||||
equalTo("AGENT_CONNECTIVITY"));
|
||||
|
||||
call("DescribeContainerInstances", describe + ",\"include\":[\"NOPE\"]}", 400)
|
||||
.then().body("message", containsString("include"));
|
||||
}
|
||||
|
||||
// ── Service deployments and revisions ────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void aServiceDeploymentPointsAtTheRevisionItDeployed() {
|
||||
String family = seed("edge-deployment-td");
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"edge-deployment-svc\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"desiredCount\":0,"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
Response listed = call("ListServiceDeployments", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"service\":\"edge-deployment-svc\"}", 200);
|
||||
listed.then()
|
||||
.body("serviceDeployments", hasSize(1))
|
||||
.body("serviceDeployments[0].targetServiceRevisionArn",
|
||||
containsString("service-revision/"))
|
||||
.body("serviceDeployments[0].startedAt", notNullValue())
|
||||
.body("serviceDeployments[0].finishedAt", notNullValue());
|
||||
|
||||
String deploymentArn = listed.jsonPath().getString("serviceDeployments[0].serviceDeploymentArn");
|
||||
String revisionArn = listed.jsonPath().getString("serviceDeployments[0].targetServiceRevisionArn");
|
||||
|
||||
call("DescribeServiceDeployments", "{\"serviceDeploymentArns\":[\"" + deploymentArn + "\"]}", 200)
|
||||
.then()
|
||||
.body("serviceDeployments[0].status", equalTo("SUCCESSFUL"))
|
||||
.body("serviceDeployments[0].targetServiceRevision.arn", equalTo(revisionArn))
|
||||
.body("serviceDeployments[0].targetServiceRevision.requestedTaskCount", equalTo(0))
|
||||
// AWS's ServiceDeployment shape has no taskDefinition; the revision carries it.
|
||||
.body("serviceDeployments[0].taskDefinition", nullValue());
|
||||
|
||||
// The service points back at both, so a caller never has to list first.
|
||||
call("DescribeServices", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"services\":[\"edge-deployment-svc\"]}", 200)
|
||||
.then()
|
||||
.body("services[0].currentServiceDeployment", equalTo(deploymentArn))
|
||||
.body("services[0].currentServiceRevisions[0].arn", equalTo(revisionArn));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aServiceRevisionSnapshotsTheConfigurationItWasCreatedWith() {
|
||||
String family = seed("edge-revision-td");
|
||||
call("CreateService", "{\"cluster\":\"" + CLUSTER + "\",\"serviceName\":\"edge-revision-svc\","
|
||||
+ "\"taskDefinition\":\"" + family + "\",\"desiredCount\":0,"
|
||||
+ "\"launchType\":\"FARGATE\"," + NETWORK + "}", 200);
|
||||
|
||||
String revisionArn = call("ListServiceDeployments", "{\"cluster\":\"" + CLUSTER
|
||||
+ "\",\"service\":\"edge-revision-svc\"}", 200)
|
||||
.jsonPath().getString("serviceDeployments[0].targetServiceRevisionArn");
|
||||
|
||||
call("DescribeServiceRevisions", "{\"serviceRevisionArns\":[\"" + revisionArn + "\"]}", 200)
|
||||
.then()
|
||||
.body("serviceRevisions[0].taskDefinition", containsString(family))
|
||||
.body("serviceRevisions[0].launchType", equalTo("FARGATE"))
|
||||
.body("serviceRevisions[0].platformVersion", equalTo("1.4.0"))
|
||||
.body("serviceRevisions[0].platformFamily", equalTo("Linux"))
|
||||
.body("serviceRevisions[0].networkConfiguration.awsvpcConfiguration.subnets",
|
||||
hasSize(1))
|
||||
.body("serviceRevisions[0].containerImages[0].containerName", equalTo("app"))
|
||||
.body("serviceRevisions[0].containerImages[0].image", equalTo("nginx:latest"))
|
||||
.body("serviceRevisions[0].guardDutyEnabled", equalTo(false));
|
||||
|
||||
call("DescribeServiceRevisions", "{\"serviceRevisionArns\":[\"arn:aws:ecs:us-east-1:"
|
||||
+ "000000000000:service-revision/nope\"]}", 200)
|
||||
.then()
|
||||
.body("serviceRevisions", hasSize(0))
|
||||
.body("failures[0].reason", equalTo("MISSING"));
|
||||
}
|
||||
}
|
||||
@@ -420,8 +420,10 @@ class EcsIntegrationTest {
|
||||
@Test
|
||||
@Order(18)
|
||||
void listTaskDefinitions() {
|
||||
// Scoped by family: the unfiltered listing pages a hundred at a time, as it does on AWS,
|
||||
// and the rest of the suite registers more families than fit on one page.
|
||||
ecs("ListTaskDefinitions")
|
||||
.body("{}")
|
||||
.body("{\"familyPrefix\":\"" + TASK_DEF_FAMILY + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
@@ -432,8 +434,9 @@ class EcsIntegrationTest {
|
||||
@Test
|
||||
@Order(19)
|
||||
void listTaskDefinitionFamilies() {
|
||||
// Scoped for the same reason as listTaskDefinitions: this listing pages too.
|
||||
ecs("ListTaskDefinitionFamilies")
|
||||
.body("{}")
|
||||
.body("{\"familyPrefix\":\"" + TASK_DEF_FAMILY + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
@@ -1011,7 +1014,32 @@ class EcsIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(53)
|
||||
void deleteClusterRejectsAClusterThatStillHasServices() {
|
||||
ecs("DeleteCluster")
|
||||
.body("""
|
||||
{"cluster": "%s"}
|
||||
""".formatted(CLUSTER_NAME))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", containsString("ClusterContainsServicesException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(54)
|
||||
void deleteCluster() {
|
||||
// zero-count-svc outlives the service tests and keeps the cluster non-empty, which is
|
||||
// exactly what AWS refuses to delete over.
|
||||
ecs("DeleteService")
|
||||
.body("""
|
||||
{"cluster": "%s", "service": "zero-count-svc"}
|
||||
""".formatted(CLUSTER_NAME))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
ecs("DeleteCluster")
|
||||
.body("""
|
||||
{"cluster": "%s"}
|
||||
@@ -1025,7 +1053,7 @@ class EcsIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(54)
|
||||
@Order(55)
|
||||
void deleteClusterNotFound() {
|
||||
ecs("DeleteCluster")
|
||||
.body("""
|
||||
|
||||
+4
-1
@@ -92,7 +92,10 @@ class EcsServiceDaemonSchedulingTest {
|
||||
assertEquals(0, runningTasks(service).size());
|
||||
|
||||
service.reconcileServices();
|
||||
long attempts = service.describeTasks(null, service.listTasks(null, null, null, null, REGION), REGION).size();
|
||||
// Both attempts died on launch, so they are the STOPPED tasks: ListTasks only returns the
|
||||
// running ones unless a desired status is asked for, as on AWS.
|
||||
long attempts = service.describeTasks(null,
|
||||
service.listTasks(null, null, "STOPPED", null, REGION), REGION).size();
|
||||
assertEquals(2, attempts, "the uncovered instance is retried on the next tick");
|
||||
}
|
||||
|
||||
|
||||
+15
-9
@@ -51,9 +51,12 @@ class EcsServicePersistenceTest {
|
||||
Map.of("tier", "web"), REGION);
|
||||
EcsServiceModel svc = first.createService("app-cluster", "web-svc", td.getTaskDefinitionArn(),
|
||||
0, LaunchType.FARGATE, List.of(), awsvpcConfiguration(), Map.of("team", "payments"), REGION);
|
||||
// An attribute names a container instance of the cluster, as it must on AWS.
|
||||
String instanceArn = first.registerContainerInstance("app-cluster", null, List.of(), REGION)
|
||||
.getContainerInstanceArn();
|
||||
first.putAttributes("app-cluster",
|
||||
List.of(new Attribute("stack", "prod", "container-instance", "ci-1")), REGION);
|
||||
first.putAccountSetting("containerInsights", "enabled");
|
||||
List.of(new Attribute("stack", "prod", "container-instance", instanceArn)), REGION);
|
||||
first.putAccountSetting("containerInsights", "enabled", null);
|
||||
|
||||
// Simulate restart: a fresh instance reloading from the same shared store.
|
||||
EcsService reloaded = serviceWithStorage(storage);
|
||||
@@ -70,10 +73,10 @@ class EcsServicePersistenceTest {
|
||||
List.of(svc.getServiceArn()), REGION).getFirst();
|
||||
assertEquals("payments", reloadedSvc.getTags().get("team"));
|
||||
|
||||
assertEquals("prod", reloaded.listAttributes("app-cluster", null, "stack", null, REGION)
|
||||
.getFirst().value());
|
||||
assertEquals("enabled", reloaded.listAccountSettings("containerInsights", null)
|
||||
.getFirst().getValue());
|
||||
assertEquals("prod", reloaded.listAttributes("app-cluster", "container-instance", "stack",
|
||||
null, null, null, REGION).attributes().getFirst().value());
|
||||
assertEquals("enabled", reloaded.listAccountSettings("containerInsights", null, null,
|
||||
false, null, null).settings().getFirst().value());
|
||||
|
||||
// latestRevisions persisted: registering the same family again yields the next revision.
|
||||
assertEquals(2, reloaded.registerTaskDefinition("web", List.of(container("app", "nginx:latest")),
|
||||
@@ -88,15 +91,18 @@ class EcsServicePersistenceTest {
|
||||
EcsCluster cluster = first.createCluster("c1", Map.of(), REGION);
|
||||
first.tagResource(cluster.getClusterArn(), Map.of("env", "test", "owner", "qa"));
|
||||
first.untagResource(cluster.getClusterArn(), List.of("owner"));
|
||||
first.putAttributes("c1", List.of(new Attribute("a", "1", "container-instance", "t1")), REGION);
|
||||
first.deleteAttributes("c1", List.of(new Attribute("a", "1", "container-instance", "t1")), REGION);
|
||||
String instanceArn = first.registerContainerInstance("c1", null, List.of(), REGION)
|
||||
.getContainerInstanceArn();
|
||||
first.putAttributes("c1", List.of(new Attribute("a", "1", "container-instance", instanceArn)), REGION);
|
||||
first.deleteAttributes("c1", List.of(new Attribute("a", "1", "container-instance", instanceArn)), REGION);
|
||||
|
||||
EcsService reloaded = serviceWithStorage(storage);
|
||||
|
||||
Map<String, String> tags = reloaded.listTagsForResource(cluster.getClusterArn());
|
||||
assertEquals("test", tags.get("env"));
|
||||
assertFalse(tags.containsKey("owner"), "untagged key must not reappear after restart");
|
||||
assertTrue(reloaded.listAttributes("c1", null, "a", null, REGION).isEmpty(),
|
||||
assertTrue(reloaded.listAttributes("c1", "container-instance", "a", null, null, null, REGION)
|
||||
.attributes().isEmpty(),
|
||||
"deleted attribute must not reappear after restart");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user