Skip to content

fix: report real ECS capacity and status instead of placeholders - #83

Merged
Bccorb merged 1 commit into
mainfrom
fix/ecs-cluster-capacity
Jul 20, 2026
Merged

fix: report real ECS capacity and status instead of placeholders#83
Bccorb merged 1 commit into
mainfrom
fix/ecs-cluster-capacity

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Closes #43.

The placeholders

Three columns were wrong, not one:

cpu: c.registered_container_instances_count(),    // placeholder
memory: c.registered_container_instances_count(), // placeholder

Both were the instance count, so EC2s, CPU, and Memory rendered the same unrelated number. Separately, the Health column was a hardcoded "OK" carrying a TODO(#43), so it is in scope here too.

What the API actually supports

I probed a live account before choosing an approach, and it changed the answer.

ECS has no cluster-level CPU or memory figure. Capacity comes from the container instances backing the cluster, via ListContainerInstances + DescribeContainerInstances, which report registeredResources and remainingResources in CPU units and memory MiB.

Fargate clusters have none of that. They provision per task, register zero container instances, and have no pool to measure utilization against. The probed cluster is Fargate-only: 0 instances, 4 running Fargate tasks. Under the old code that rendered 0 in all three columns.

Change

  • CPU Used / Mem Used: share of registered capacity in use, summed across the cluster's container instances.
  • Status: the lifecycle state ECS returns (ACTIVE, PROVISIONING, FAILED, ...), replacing the hardcoded OK. Anything other than ACTIVE is styled to stand out. This comes from the DescribeClusters response already being made, so it costs nothing.
  • Fargate clusters show -, not 0. A zero reads as an idle cluster, which is exactly the wrong impression and what the placeholder gave.

Capacity is fetched only when a cluster reports container instances, so a Fargate-only account makes no extra API calls. DescribeContainerInstances is chunked at its 100-identifier limit.

A failed capacity lookup leaves the columns blank rather than reporting a capacity that was never read, matching how tag lookups already degrade.

Verification

  • cargo test: 138 passed, 0 failed
  • cargo clippy --all-targets -- -D warnings: clean
  • cargo fmt --check: clean
  • Rendered the ECS view against a live account: the Fargate cluster shows - in both capacity columns and ACTIVE read from the API, where it previously showed 0, 0, and a hardcoded OK.
  • Unit tests cover utilization math, a fully idle cluster reading 0% rather than absent, a fully claimed cluster reading 100%, Fargate reporting no utilization, division by zero when nothing is registered, more-available-than-registered (which ECS can report while an instance drains) clamping to 0 rather than going negative, an unreported status not being claimed healthy, and a cluster cached before these fields existed still deserializing.

Not verified end to end: the account has no EC2-backed cluster, so the capacity path did not run against real data. The resource parsing and the math are unit-tested and the API shape was confirmed by probe, but a cluster with real container instances would be the true test.

AGENTS.md

The bare // placeholder comments are gone. The remaining TODO in this area is TODO(#16), which references its ticket.

Cluster CPU and memory were both assigned the registered container-instance
count, so EC2s, CPU, and Memory showed the same unrelated number in three
columns. The Health column was the string OK regardless of the cluster.

CPU and memory are now the share of registered capacity in use, summed from the
CPU and MEMORY resources the container instances backing the cluster report.
Status is the lifecycle state ECS returns, and a cluster that is not ACTIVE is
styled to stand out.

Fargate has no cluster-level capacity pool: it provisions per task, registers no
container instances, and has no total to divide against. Those clusters carry no
capacity and render a dash, because a zero would read as an idle cluster, which
is what the placeholder did. Capacity is only fetched when a cluster reports
container instances, so a Fargate-only account makes no extra calls.

A status that was not reported renders as unknown rather than being assumed
healthy, and both new fields default when absent so a cached cluster from an
older build still loads.
@Bccorb
Bccorb merged commit 4c70037 into main Jul 20, 2026
2 checks passed
@Bccorb
Bccorb deleted the fix/ecs-cluster-capacity branch July 20, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ECS overview shows placeholder CPU/memory values

1 participant