Skip to content

fix: return instead of panicking on an unparsable Fargate capacity - #551

Open
lbarrosby wants to merge 1 commit into
awslabs:mainfrom
lbarrosby:fix-fargate-capacity-parse-panic
Open

lbarrosby wants to merge 1 commit into
awslabs:mainfrom
lbarrosby:fix-fargate-capacity-parse-panic

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

Pod.FargateCapacityProvisioned logs unable to parse ... for fargate provisioner capacity when the CapacityProvisioned annotation does not match <n>vCPU <n>GB, but it does not return there. It goes on to read match[1] from the empty match and panics:

panic: runtime error: index out of range [1] with length 0

Node.InstanceType() and the Fargate pricing lookup call it for every single-pod Fargate node, so one pod with an unexpected value in that annotation takes the whole viewer down instead of showing the node as plain Fargate.

The fix returns 0, 0, false after the log line, like the two ParseFloat error paths below it already do.

Test: TestFargateCapacityUnparsable in pkg/model/pod_test.go. It panics on main and passes with the change.

$ go test ./pkg/...
ok  	github.com/awslabs/eks-node-viewer/pkg/model	0.601s
$ go vet ./pkg/model/

FargateCapacityProvisioned logged that it could not parse the
CapacityProvisioned annotation, then indexed the empty match anyway and
panicked with index out of range.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby
lbarrosby requested a review from a team as a code owner November 21, 2026 15:04
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.

1 participant