mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -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
@@ -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; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user