fix: report real ECS capacity and status instead of placeholders - #83
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #43.
The placeholders
Three columns were wrong, not one:
Both were the instance count, so EC2s, CPU, and Memory rendered the same unrelated number. Separately, the Health column was a hardcoded
"OK"carrying aTODO(#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 reportregisteredResourcesandremainingResourcesin 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
0in all three columns.Change
DescribeClustersresponse already being made, so it costs nothing.-, not0. 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.
DescribeContainerInstancesis 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 failedcargo clippy --all-targets -- -D warnings: cleancargo fmt --check: clean-in both capacity columns andACTIVEread from the API, where it previously showed0,0, and a hardcodedOK.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
// placeholdercomments are gone. The remaining TODO in this area isTODO(#16), which references its ticket.